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;
double a;
double b;
double y0;
n = 10.0;
a = 1.0;
b = 2.4;
y0 = 1.59;
clrscrn();
printf(" Heun's method to approximate the solution\n"
" of the differential equation.\n\n"
" y' = %s\n\n",Ypeq);
p_Heun_s_Method(a,
b,
n,
y0,
Yp);
printf(" y_n = %.10f\n\n",
Heun_s_Method(a,
b,
n,
y0,
Yp)
);
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",Ypeq, n);
printf(" y_n = %.10f\n\n",
Heun_s_Method(a,
b,
n,
y0,
Yp)
);
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
--------------------------
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.
Exemple de sortie écran : 2
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.