Mathc initiation/Fichiers h : x 21c1b

Sommaire

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

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

   n =       10.0;
   a =        1.0;
   b =        2.0;
  y0 =        3.0;

 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   = 7.38629\n\n");

 stop();
 
 
 clrscrn();
 
 n = 9.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  = 7.38629\n\n");

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


Calculons la solution numérique de l'équation

y' = 1 + y/x  pour 1 < x <  2
avec comme condition initial y0 = 3. quand x = 1


Exemple de sortie écran 1 :

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

  y' = 1 + y/x

  k  | x_k   | y_k         
 --------------------------
   1 | 1.100 | 3.4048
   2 | 1.200 | 3.8188
   3 | 1.300 | 4.2411
   4 | 1.400 | 4.6711
   5 | 1.500 | 5.1082
   6 | 1.600 | 5.5520
   7 | 1.700 | 6.0021
   8 | 1.800 | 6.4580
   9 | 1.900 | 6.9195
  10 | 2.000 | 7.3863
                    y_n = 7.3862928864

 The exact value is y   = 7.38629

 Press return to continue.


Exemple de sortie écran : 2

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

  y' = 1 + y/x,

 with n = 9 

                   y_n = 7.3862921293

 The exact value is y  = 7.38629

 Press return to continue.