/* calculation of integral euler */ #include #include #include using namespace std; int main() { double t = 0.; double y = 1.; double h = 0.001; double k1; while(t<1.) { k1 = y; y += h*k1; t += h; } double y_exact = exp(t); cout << "Euler: " << setprecision(18) << y << " Exact: " << setprecision(18) << y_exact << \ " diff: " << fabs(y-y_exact) << endl; // printf("Euler: %.16f, exact: %.16f, diff: %.16f\n",y,y_exact,fabs(y-y_exact)); }