// Forward Euler Integration #include #include double f(double t, double y); double analyticalsol(double x); void euler(double dt, double t0, double y0, double tmax); void plotfunction(double x0, double x1, int N); // Driver program int main() { // Initial values euler(1.0,0.0,1.0,50); plotfunction(0.00, 50,500); return 0; } // Prints root of func(x) with error of EPSILON void euler(double dt, double t0, double y0, double tmax) { double y,t; FILE *output; output = fopen("forwardeuler.dat", "w");//opening file. t=t0; y=y0; fprintf(output,"%.15f\t%.15f\n",t0,y0); while (t <= tmax) { y=y+dt*f(t,y); t=t+dt; fprintf(output,"%.15f\t%.15f\n",t,y); } fclose(output);//closing file. } void plotfunction(double x0, double x1,int N) { int i; double x,dx; FILE *output; dx=(x1-x0)/N; output = fopen("function.dat", "w");//opening file. for(i=0;i