Mathc initiation/Fichiers c : c14a2
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c2a.c |
|---|
/* ---------------------------------- */
/* save as c2a.c */
/* ---------------------------------- */
#include "x_hfile.h"
#include "fa.h"
/* ---------------------------------- */
int main(void)
{
int n = 2*500;
double a = 0.;
double b = 1.;
clrscrn();
printf(" With the Simpson's rule. (n = %d)\n\n"
" (%.3f\n"
" int( (%s) * dx = %.6f\n"
" (%.3f\n\n\n\n",n, b, feq, simpson(f,a,b,n), a);
printf(" With the antiderivative of f.\n\n"
" F(x) = %s \n\n\n"
" F(%.3f) - F(%.3f) = %.6f \n\n\n", Feq, b,a, F(b)-F(a));
stop();
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
Verifier avec mathematica : Free: wolframalpha.com
integral (sqrt(x)) dx from 0 to 1
Exemple de sortie écran :
With the Simpson's rule. (n = 1000)
(1.000
int( (sqrt(x)) * dx = 0.666664
(0.000
With the antiderivative of f.
F(x) = (2./3.)* x**(3./2.)
F(1.000) - F(0.000) = 0.666667
Press return to continue.