Mathc initiation/Fichiers c : c79c01
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c01a.c |
---|
/* ---------------------------------- */
/* save as c1a.c */
/* ---------------------------------- */
#include "x_hfile.h"
#include "fa.h"
/* ---------------------------------- */
int main(void)
{
int n = 2*50;
double a = 1.;
double b = 2.;
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;
}
/* ---------------------------------- */
Calculons l'intégrale avec la fonction simpson(f,a,b,n); puis avec sa primitive F(x).
Exemple de sortie écran :
With the Simpson's rule. (n = 100)
(2.000
int( (1/(cos(x)-1)) dx = -1.188395
(1.000
With the antiderivative of f.
F(x) = cot(x) + csc(x)
F(2.000) - F(1.000) = -1.188395
Press return to continue.
Calculons la primitive :
/
| 1
1) Calculer la primitive de | -------- dx
| cos(x)-1
/
/ /
| 1 | 1 cos(x)+1
| -------- dx = | -------- -------- dx
| cos(x)-1 | cos(x)-1 cos(x)+1
/ /
/
| cos(x)+1
= | ------------ dx
| cos(x)**2-1
/
cos(x)**2+sin(x)**2 = 1
/
| cos(x)+1
= | ------------- dx
| (-) sin(x)**2
/
/ /
| 1 | cos(x)
= | ------------- dx + | ------------- dx
| (-) sin(x)**2 | (-) sin(x)**2
/ /
/ /
= | (-) csc(x)**2 dx + | (-) cot(x) csc(x) dx
/ /
/
| 1/(cos(x)-1) dx = cot(x) + csc(x) + c
/