#include #include #define MaxPts 100 float x_0=0.0; float y_0=1.0; float h=0.1; float ecuacion_dif(float x, float y) { float z; z=-x*x*y*y+y*cos(x); return z; } float calculo_de_ks(float x, float y, float h) { float k,k1,k2,k3,k4; k1=h*ecuacion_dif(x,y); k2=h*ecuacion_dif(x+h/2.0,y+k1/2.0); k3=h*ecuacion_dif(x+h/2.0,y+k2/2.0); k4=h*ecuacion_dif(x+h,y+k3); k=(k1+2*k2+2*k3+k4)/6.0; return k; } int main() { float x1,y1; int i; printf("%f %f\n",x_0,y_0); for(i=1;i<=MaxPts;i++){ y1=y_0+calculo_de_ks(x_0,y_0,h); x1=x_0+h; x_0=x1; y_0=y1; printf("%f %f\n",x_0,y_0); } return 0; }