Mathc initiation/Fichiers h : x 20c1c

Sommaire

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

Crystal Clear mimetype source c.png c1c.c
'
/* ---------------------------------- */
/* save as c1c.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fc.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 =        0.0;
   b =        2.0;
  y0 =       -1.5;

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

 stop();
 return 0;
}


Calculons la solution numérique de l'équation

y' = -(y+1)*(y+3)  pour 0 < x <  2
avec comme condition initial y0 = -1.5 quand x = 0


Exemple de sortie écran 1 :

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

  y' = -(y+1)*(y+3)

  k  | x_k   | y_k         
 --------------------------
   1 | 0.200 | -1.3672500000
   2 | 0.400 | -1.2639392952
   3 | 0.600 | -1.1866271617
   4 | 0.800 | -1.1304109773
   5 | 1.000 | -1.0903665254
   6 | 1.200 | -1.0622511611
   7 | 1.400 | -1.0427086592
   8 | 1.600 | -1.0292188780
   9 | 1.800 | -1.0199513980
  10 | 2.000 | -1.0136053555
                    y_n = -1.0136053555

 The exact value is y   = -1.012136331

 Press return to continue.


Exemple de sortie écran : 2

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

  y' = -(y+1)*(y+3),

 with n = 10000 

                    y_n = -1.0121363321

 The exact value is y   = -1.012136331

 Press return to continue.