#include "bsp_1_d.h"
#include <iostream>
#include <math.h>
// BSP 1_D
using namespace std;

int main()
{
    vector<int> nvec{100,500,1000,10000,100000,1000000,10000000,100000000}; // Vektor mit verschiedene n zum Testen
    double exact = M_PI*M_PI/6;
    for(size_t k = 0; k<nvec.size(); ++k)
    {
        vector<double> x;
        for(int i = 0; i<nvec[k]; ++i)
        {
            x.push_back(1.0/(i+1));
        }
        double sum = scalar(x,x);
        double sumkahan = Kahan_skalar(x,x);

        cout << "n = " << nvec[k] << endl;
        cout << "sum = " << sum << endl;
        cout << "sumkahan = " << sumkahan << endl;
        cout << "Differenz mit/ohne Kahan: " << abs(sum - sumkahan) << endl;
        cout << "Differenz zu exakt fuer n to inf (mit/ohne Kahan): " << abs(exact - sum) << " / " << abs(exact - sumkahan) << endl << endl;
    }
    return 0;
}
