/******************************************************************* * Differential equations of order N * * by Runge-Kutta method of order 4 * * ---------------------------------------------------------------- * * Reference: "Analyse en Turbo Pascal versions 5.5 et 6.0" By Marc * * DUCAMP et Alain REVERCHON - Eyrolles, Paris 1991. * * [BIBLI 03]. * * * * C++ Version By J-P Moreau, Paris * * (use with teqdifn1.mak and graph2d.cpp) * * (www.jpmoreau.fr) * * ---------------------------------------------------------------- * * SAMPLE DATA: * * * * Example: integrate y"=(2y'y'+yy)/y from x=4 to x=6 * * with initial conditions: y(4)=2 and y'(4)=-2tan(1) * * * * Exact solution is: y = 2cos(1)/cos(x-5) * * * * DIFFERENTIAL EQUATION WITH 1 VARIABLE OF ORDER N * * of type y(n) = f(y(n-1),...,y"",y,x) * * * * order of equation: 2 * * begin value x : 4 * * end value x : 6 * * y0 value at x0 : 2 * * y1 value at x0 : -3.114815 * * number of points : 11 * * finesse : 20 * * * * X Y * * --------------------------- * * 4.000000 2.000000 * * 4.200000 1.551018 * * 4.400000 1.309291 * * 4.600000 1.173217 * * 4.800000 1.102583 * * 5.000000 1.080605 * * 5.200000 1.102583 * * 5.400000 1.173217 * * 5.600000 1.309291 * * 5.800000 1.551018 * * 6.000000 2.000000 * * * *******************************************************************/ #include #include #include #include HDC hdc; RECT rect; HPEN hpen, hpenOld; //Functions used here of Graph2D.cpp void CourbeXY (int,int,float *,double,double); void Legendes (int,char *,char *,char *,int,int,char *,int,int,char *); //"home made" graphic commands for hdc environment used by above functions void DrawPixel(int ix,int iy) { //sorry, no other available command found Rectangle(hdc,rect.left+ix,rect.top+iy, rect.left+ix+2,rect.top+iy+1); } void Swap(int *i1,int *i2) { int it; it=*i1; *i1=*i2; *i2=it; } void DrawLine(int ix1,int iy1,int ix2,int iy2) { int i,il,ix,iy; double dx,dy; if (ix2