Mathc initiation/Fichiers h : x 20c1a
Apparence
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 = 10.0;
double a = 1.0;;
double b = 2.4;
double y0 = 1.59;
clrscrn();
printf(" Heun's method to approximate the solution\n"
" of the differential equation.\n\n"
" y' = %s\n\n",Yeq);
p_Heun_s_Method(a,
b,
n,
y0,
Y);
printf(" y_n = %.10f\n\n",
Heun_s_Method(a,
b,
n,
y0,
Y)
);
printf(" The exact value is y = 5.790805\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",Yeq, n);
printf(" y_n = %.10f\n\n",
Heun_s_Method(a,
b,
n,
y0,
Y)
);
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 :
Heun's method to approximate the solution
of the differential equation.
y' = 1.0 + (y-x)**2
k | x_k | y_k
--------------------------
+0 | +1.000 | +1.5900000000
+1 | +1.140 | +1.7829256786
+2 | +1.280 | +1.9862383884
+3 | +1.420 | +2.2033120261
+4 | +1.560 | +2.4391496429
+5 | +1.700 | +2.7014939903
+6 | +1.840 | +3.0029808154
+7 | +1.980 | +3.3656740723
+8 | +2.120 | +3.8316934726
+9 | +2.260 | +4.4919519386
+10 | +2.400 | +5.5813521807
y_n = 5.5813521807
The exact value is y = 5.790805
Press return to continue.
Heun's method to approximate the solution
of the differential equation
y' = 1.0 + (y-x)**2,
with n = 10000
y_n = 5.7908042822
The exact value is y = 5.790805
Press return to continue.