/******************************************************************* * Differential equations of order 1 * * by Runge-Kutta method of order 4 * * * * C++ version by J-P Moreau, Paris * * (www.jpmoreau.fr) * * ---------------------------------------------------------------- * * Reference: "Analyse en Turbo Pascal versions 5.5 et 6.0 By Marc * * DUCAMP et Alain REVERCHON - Eyrolles, Paris 1991" * * [BIBLI 03]. * * ---------------------------------------------------------------- * * SAMPLE RUN: * * * * Example: integrate y"=4x*(y+sqrt(y))/1+x^2 from x=0 to x=1 * * * * DIFFERENTIAL EQUATION WITH 1 VARIABLE OF ORDER 1 * * of type y" = f(x,y) * * * * begin value x : 0 * * end value x : 1 * * y value at x0 : 1 * * number of points: 11 * * finesse : 10 * * * * X Y * * ------------------------- * * 0.000000 1.000000 * * 0.100000 1.040400 * * 0.200000 1.166400 * * 0.300000 1.392400 * * 0.400000 1.742400 * * 0.500000 2.250000 * * 0.600000 2.958400 * * 0.700000 3.920400 * * 0.800000 5.198400 * * 0.900000 6.864400 * * 1.000000 9.000000 * * * ******************************************************************** See explanation fike rkutta.txt ------------------------------- } #include #include #define SIZE 50 int fi,m; double xi,xf,yi,T[SIZE]; double fp(double x, double y) { //Example: y'=4x(y+rac(y))/(1+x²) return 4*x*(y+sqrt(y))/(1+x*x); } void Affiche(double *t,int m,double xi,double xf) { double h,x; int i; h=(xf-xi)/(m-1); x=xi-h; printf("\n X Y \n"); printf("------------------------\n"); for (i=1; i