Mathc initiation/Fichiers c : 81a
Installer et compiler ces fichiers dans votre répertoire de travail.
c_a.c |
---|
/* ---------------------------------- */
/* save as c_a.c */
/* ---------------------------------- */
#include "x_hfile.h"
#include "fa.h"
/* ---------------------------------- */
int main(void)
{
int n = 2*300;
double a = 0;
double b = 100;
double M = simpson(f,a,b,n);
printf(" Improper integral with the Simpson's rule.\n\n");
printf(" / b = oo\n");
printf(" |\n");
printf(" | %s dx = %.6f\n", feq, M);
printf(" |\n");
printf(" / a = %+.2f\n\n\n\n", a);
printf(" (mathematica) exact value = %.6f\n\n", 0.886227);
for(b=10;b<10000;b*=10)
printf(" b = %-12.0f M = %.6f\n", b, simpson(f,a,b,n));
printf(" \n\n"
" In c language 10 < oo < 100 \n\n");
stop();
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
Exemple de sortie écran :
Improper integral with the Simpson's rule.
/ b = oo
|
| exp(-x^2) dx = 0.886227
|
/ a = +0.00
(mathematica) exact value = 0.886227
b = 10 M = 0.886227
b = 100 M = 0.886227
b = 1000 M = 0.693742
In c language 10 < oo < 100
Press return to continue.