Mathc initiation/Fichiers h : x 19c1b

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(" Euler's method to approximate the solution\n" 
        " of the differential equation.\n\n" 
        "  y' = %s\n\n",Ypeq);

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

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

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

 stop();
 
 
 clrscrn();
 
 n = 100000;
  
 printf(" Euler'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",
         Euler_s_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 :

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

  y' = 1 + y/x

  k  | x_k   | y_k         
 --------------------------
   1 | 1.100 | +3.4000000000
   2 | 1.200 | +3.8090909091
   3 | 1.300 | +4.2265151515
   4 | 1.400 | +4.6516317016
   5 | 1.500 | +5.0838911089
   6 | 1.600 | +5.5228171828
   7 | 1.700 | +5.9679932567
   8 | 1.800 | +6.4190516836
   9 | 1.900 | +6.8756656660
  10 | 2.000 | +7.3375428064


                    y_n = 7.3375428064

 The exact value is y   = 7.38629

 Press return to continue.


Exemple de sortie écran : 2

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

  y' = 1 + y/x,

 with n = 100000 

                    y_n = 7.3862893611

 The exact value is y   = 7.38629

 Press return to continue.