Mathc initiation/a615
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c0fsN.c |
---|
/* ---------------------------------- */
/* save as c0fsN.c */
/* ---------------------------------- */
#include "x_hfile.h"
/* ---------------------------------- */
#define N 50
/* ---------------------------------- */
#include "f0.h"
/* ---------------------------------- */
int main(void)
{
double T = PI;
double omega = (2.*PI/T);
double a = 0.;
double b = PI;
double A[N+1];
double B[N+1];
int n = 0;
A[0] = 1./T * fourier_a0(f, a,b);
for( n=1; n<=N; n++)
B[n] = 2./T * fourier_bn(f, a,b, omega, n);
clrscrn();
printf(" S(x) = %.9f\\\n", A[0]);
for( n=1; n<N; n++)
printf(" %.9f*sin(%.9f* %d*x)\\\n", B[n], omega, n);
printf(" %.9f*sin(%.9f* %d*x)\n\n\n", B[n], omega, n);
stop();
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
Exemple de sortie écran :
S(x) = 1.570796327\
-1.000000005*sin(2.000000000* 1*x)\
-0.500000043*sin(2.000000000* 2*x)\
-0.333333480*sin(2.000000000* 3*x)\
...
-0.021644202*sin(2.000000000* 48*x)\
-0.021283386*sin(2.000000000* 49*x)\
-0.020943951*sin(2.000000000* 50*x)
Press return to continue.
Fichier de commande gnuplot :
# ---------------------
# Copy and past this file into the screen of gnuplot
#
#
plot [0.:pi] [0.:pi]\
x,\
1.570796327\
-1.000000005*sin(2.000000000* 1*x)\
-0.500000043*sin(2.000000000* 2*x)\
-0.333333480*sin(2.000000000* 3*x)\
-0.250000347*sin(2.000000000* 4*x)\
-0.200000678*sin(2.000000000* 5*x)\
-0.166667841*sin(2.000000000* 6*x)\
-0.142859010*sin(2.000000000* 7*x)\
-0.125002792*sin(2.000000000* 8*x)
reset