Mathc initiation/a598
Installer et compiler ces fichiers dans votre répertoire de travail.
c0fs.c |
---|
/* ---------------------------------- */
/* save as c0fs.c */
/* ---------------------------------- */
#include "x_hfile.h"
/* ---------------------------------- */
#include "f0.h"
/* ---------------------------------- */
int main(void)
{
double T = PI;
double omega = (2.*PI/T);
double a = 0.;
double b = PI;
double a0 = 1./T * fourier_a0(f, a,b);
double an = 2./T * fourier_an(f, a,b, omega, 1);
double b1 = 2./T * fourier_bn(f, a,b, omega, 1);
double b2 = 2./T * fourier_bn(f, a,b, omega, 2);
double b3 = 2./T * fourier_bn(f, a,b, omega, 3);
double b4 = 2./T * fourier_bn(f, a,b, omega, 4);
double b5 = 2./T * fourier_bn(f, a,b, omega, 5);
double b6 = 2./T * fourier_bn(f, a,b, omega, 6);
double b7 = 2./T * fourier_bn(f, a,b, omega, 7);
double b8 = 2./T * fourier_bn(f, a,b, omega, 8);
clrscrn();
printf(" _+oo_ \n"
" \\ \n"
" S(t) = a0 + | an cos(omega* n*t) + bn sin(omega *n*t)\n"
" /_____ \n"
" n = 1 \n\n\n\n");
printf(" a0 = %.6f \n",a0);
printf(" an = %.6f \n\n",an);
printf(" S(x) = %.9f\\\n"
" %.9f*sin(%.9f* 1*x)\\\n"
" %.9f*sin(%.9f* 2*x)\\\n"
" %.9f*sin(%.9f* 3*x)\\\n"
" %.9f*sin(%.9f* 4*x)\\\n"
" %.9f*sin(%.9f* 5*x)\\\n"
" %.9f*sin(%.9f* 6*x)\\\n"
" %.9f*sin(%.9f* 7*x)\\\n"
" %.9f*sin(%.9f* 8*x)\n"
" ... \n\n\n",
a0,
b1, omega,
b2, omega,
b3, omega,
b4, omega,
b5, omega,
b6, omega,
b7, omega,
b8, omega);
stop();
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
Exemple de sortie écran :
_+oo_
\
S(t) = a0 + | an cos(omega* n*t) + bn sin(omega *n*t)
/_____
n = 1
a0 = 1.570796
an = 0.000000
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.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)
...
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