#include "mylib.h"
#include <cmath>
#include <iostream>
using namespace std;

int main(int argc, char **argv)
{
    for(size_t i = 1; i < 8; ++i)
    {
        size_t n = pow(10,i);
        vector<double> x(n);
        for (size_t k = 0; k < n; ++k)
            x[k] = 1.0/(k + 1);
            

        // compute scalar products
        double sum_1 = scalar(x, x);
        double sum_2 = Kahan_skalar(x, x);

        // compute error
        double err_1 = abs(sum_1 - pow(M_PI,2)/6);
        double err_2 = abs(sum_2 - pow(M_PI,2)/6);

        cout << "n = " << n << endl;
        cout << "Normal scalar product: " << sum_1 << "\terror: " << err_1 << endl;
        cout << "Kahan scalar product: " << sum_2 << "\terror: " << err_2 << endl;
        cout << endl;
    }
    
    

    return 0;
}
