TP Intégration Numérique
Main Page
Files
File List
Globals
All
Files
Functions
essai03.c
Go to the documentation of this file.
1
9
#include <math.h>
10
11
#include "
mesh1D.h
"
12
#include "
quad.h
"
13
#include "
utils.h
"
14
15
double
f(
double
x){
16
return
8.*sqrt(x*(1-x));
17
}
18
19
int
main(){
20
int
i,nini=100,pas=100,nfin,N,nb,n;
21
double
*ph,*pError,Exact=M_PI,val;
22
printf(
"nfin="
);scanf(
"%d"
,&nfin);
23
nb=(nfin-nini)/pas+1;
24
ph=(
double
*)
Malloc
(nb*
sizeof
(
double
));
25
pError=(
double
*)
Malloc
(nb*
sizeof
(
double
));
26
for
(i=0;i<nb;i++){
27
N=nini+i*pas;
28
val=
quadPMAlloc
(f,0.,1,N,&ph[i]);
29
pError[i]=fabs(val-Exact)/Exact;
30
printf(
"N=%8d, val=%.16lf, error=%.16e\n"
,N,val,pError[i]);
31
}
32
saveTwoDoubleDynArray
(ph,pError,nb,
"essai03.out"
,
"%.16e %.16e"
);
33
Free
(ph);
34
Free
(pError);
35
return
EXIT_SUCCESS;
// return 0
36
}
essai03.c
Generated on Mon Nov 18 2013 14:58:05 for TP Intégration Numérique by
1.8.2