Mathc initiation/Fichiers h : x 21c1a

Sommaire

Installer et compiler ces fichiers dans votre répertoire de travail.

c1a.c
/* ---------------------------------- */
/* save as c1a.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fa.h"
/* --------------------------------- */
int main(void)
{
double                  n;
double                  a;
double                  b;
double                 y0;

   n =       10.0;
   a =        1.0;
   b =        2.4;
  y0 =        1.59;

 clrscrn();
 
 printf(" Runge Kutta's method to approximate the solution\n" 
        " of the differential equation.\n\n" 
        "  y' = %s\n\n",Ypeq);

 p_RungeKutta_Method(a,
                        b,
                        n,
                        y0,
                        Yp);

 printf("                    y_n = %.10f\n\n",
      RungeKutta_Method(a,
                        b,
                        n,
                        y0,
                        Yp)
        );

 printf(" The exact value is y   = 5.790805\n\n");

 stop();
 
 
 clrscrn();
 
 n = 50.0;
  
 printf(" Runge Kutta's method to approximate the solution\n" 
        " of the differential equation\n\n" 
        "  y' = %s,\n\n with n = %.0f \n\n",Ypeq, n);


 printf("                    y_n = %.10f\n\n",
      RungeKutta_Method(a,
                        b,
                        n,
                        y0,
                        Yp)
        );

 printf(" The exact value is y   = 5.790805\n\n");

 stop();
 return 0;
}
/* --------------------------------- */
/* --------------------------------- */


Calculons la solution numérique de l'équation

y' = 1.0 + (y-x)**2  pour 1 < x <  2.4
avec comme condition initial y0 = 1.59 quand x = 1


Exemple de sortie écran 1 :

  
 Runge Kutta's method to approximate the solution
 of the differential equation.

  y' = 1.0 + (y-x)**2

  k  | x_k   | y_k         
 --------------------------
   1 | 1.140 | 1.7831
   2 | 1.280 | 1.9868
   3 | 1.420 | 2.2044
   4 | 1.560 | 2.4411
   5 | 1.700 | 2.7051
   6 | 1.840 | 3.0097
   7 | 1.980 | 3.3787
   8 | 2.120 | 3.8593
   9 | 2.260 | 4.5590
  10 | 2.400 | 5.7889
                    y_n = 5.7889039379

 The exact value is y   = 5.790805

 Press return to continue.


Exemple de sortie écran : 2

  
 Runge Kutta's method to approximate the solution
 of the differential equation

  y' = 1.0 + (y-x)**2,

 with n = 50 

                    y_n = 5.7908008408

 The exact value is y   = 5.790805

 Press return to continue.