Mathc initiation/Fichiers h : x 20c1b

Sommaire

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

Crystal Clear mimetype source c.png c1b.c
'
/* ---------------------------------- */
/* save as c1b.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fb.h"
/* --------------------------------- */
int main(void)
{
double (*P_f)(double x, double y);

double                  n;
double                  a;
double                  b;
double                 y0;

 P_f = Y_p;
   n =       10.0;
   a =        1.0;
   b =        2.0;
  y0 =        3.0;
  
 clrscrn();
 
 printf(" Heun's method to approximate the solution\n" 
        " of the differential equation.\n\n" 
        "  y' = %s\n\n",Y_peq);

 p_Heun_s_Method(a,
                        b,
                        n,
                        y0,
                        (*P_f));

 printf("                    y_n = %.10f\n\n",
          Heun_s_Method(a,
                        b,
                        n,
                        y0,
                        (*P_f))
        );

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

 stop();
 
 
 clrscrn();
 
 n = 100.0;
  
 printf(" Heun's method to approximate the solution\n" 
        " of the differential equation\n\n" 
        "  y' = %s,\n\n with n = %.0f \n\n",Y_peq, n);


 printf("                    y_n = %.10f\n\n",
          Heun_s_Method(a,
                        b,
                        n,
                        y0,
                        (*P_f))
        );

 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 :

 Heun's method to approximate the solution
 of the differential equation.

  y' = 1 + y/x

  k  | x_k   | y_k         
 --------------------------
   1 | 1.100 | 3.4045454545
   2 | 1.200 | 3.8182162534
   3 | 1.300 | 4.2402470951
   4 | 1.400 | 4.6699913771
   5 | 1.500 | 5.1068955231
   6 | 1.600 | 5.5504802246
   7 | 1.700 | 6.0003264152
   8 | 1.800 | 6.4560645703
   9 | 1.900 | 6.9173664031
  10 | 2.000 | 7.3839383191
                    y_n = 7.3839383191

 The exact value is y   = 7.38629

 Press return to continue.


Exemple de sortie écran : 2

  
 Heun's method to approximate the solution
 of the differential equation

  y' = 1 + y/x,

 with n = 100 

                    y_n = 7.3862695068

 The exact value is y   = 7.38629

 Press return to continue.