/******************************************************************* * Differential equations with p variables of order 1 * * 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++ in API style Version By J-P Moreau, Paris * * (use with teqdifp1.mak and graph2d.cpp) * * (www.jpmoreau.fr) * * ---------------------------------------------------------------- * * SAMPLE DATA: * * * * Example: integrate system of equations from x=0 to x=3: * * y1' = y2 + y3 - 3*y1 * * y2' = y1 + y3 - 3*y2 * * y3' = y1 + y2 - 3*y3 * * with initial conditions: y1(0)=1, y2(0)=2 and y3(0)=-1 * * * * * * DIFFERENTIAL EQUATION WITH P VARIABLE OF ORDER 1 * * of type yi' = f(y1,y2,...,yn), i=1..n * * * * number of variables: 3 * * begin value x : 0 * * end value x : 3 * * y1 value at x0 : 1 * * y2 value at x0 : 2 * * y3 value at x0 : -1 * * number of points : 7 * * finesse : 100 * * * * X Y1 Y2 * * -------------------------------------- * * 0.000000 1.000000 2.000000 * * 0.500000 0.449466 0.584801 * * 1.000000 0.251358 0.269674 * * 1.500000 0.149580 0.152058 * * 2.000000 0.090335 0.090671 * * 2.500000 0.054738 0.054784 * * 3.000000 0.033193 0.033200 * * * *******************************************************************/ #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