Sommaire


Installer et compiler ces fichiers dans votre répertoire de travail.

c1fs.c
/* ---------------------------------- */
/* save as c1fs.c                     */
/* ---------------------------------- */
#include "x_hfile.h"
/* ---------------------------------- */
#include      "f1.h"
/* ---------------------------------- */
int main(void)
{
double     T =  2.;
	
double omega = (2.*PI/T);

double     a =  -1;
double     b =  +1;

double     a0 =  1./T * fourier_a0(f, a,b);

double     a1 =  2./T * fourier_an(f, a,b, omega, 1);
double     a2 =  2./T * fourier_an(f, a,b, omega, 2);
double     a3 =  2./T * fourier_an(f, a,b, omega, 3);
double     a4 =  2./T * fourier_an(f, a,b, omega, 4);
double     a5 =  2./T * fourier_an(f, a,b, omega, 5);
double     a6 =  2./T * fourier_an(f, a,b, omega, 6);
double     a7 =  2./T * fourier_an(f, a,b, omega, 7);
double     a8 =  2./T * fourier_an(f, a,b, omega, 8);

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\n\n",a0);
 
 printf(" S(x) = %+.9f\\\n"  
        " %+.9f*cos(%.9f* 1*x)  %+.9f*sin(%.9f* 1*x)\\\n"
        " %+.9f*cos(%.9f* 2*x) %+.9f*sin(%.9f* 2*x)\\\n"
        " %+.9f*cos(%.9f* 3*x)  %+.9f*sin(%.9f* 3*x)\\\n"
        " %+.9f*cos(%.9f* 4*x)  %+.9f*sin(%.9f* 4*x)\\\n"
        " %+.9f*cos(%.9f* 5*x) %+.9f*sin(%.9f* 5*x)\\\n"
        " %+.9f*cos(%.9f* 6*x)  %+.9f*sin(%.9f* 6*x)\\\n"
        " %+.9f*cos(%.9f* 7*x)  %+.9f*sin(%.9f* 7*x)\\\n"               
        " %+.9f*cos(%.9f* 8*x) %+.9f*sin(%.9f* 8*x)\n\n",
                      a0,   
                      a1,omega,  b1,omega,
                      a2,omega,  b2,omega,
                      a3,omega,  b3,omega,
                      a4,omega,  b4,omega,   
                      a5,omega,  b5,omega,
                      a6,omega,  b6,omega,
                      a7,omega,  b7,omega,
                      a8,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 =  0.333333


 S(x) = +0.333333333\
 -0.405284728*cos(3.141592654* 1*x)  +0.636619776*sin(3.141592654* 1*x)\
 +0.101321157*cos(3.141592654* 2*x) -0.318309914*sin(3.141592654* 2*x)\
 -0.045031578*cos(3.141592654* 3*x)  +0.212206684*sin(3.141592654* 3*x)\
 +0.025330190*cos(3.141592654* 4*x)  -0.159155164*sin(3.141592654* 4*x)\
 -0.016211224*cos(3.141592654* 5*x) +0.127324386*sin(3.141592654* 5*x)\
 +0.011257671*cos(3.141592654* 6*x)  -0.106104043*sin(3.141592654* 6*x)\
 -0.008270792*cos(3.141592654* 7*x)  +0.090946870*sin(3.141592654* 7*x)\
 +0.006332148*cos(3.141592654* 8*x) -0.079579249*sin(3.141592654* 8*x)

 Press return to continue.
fourier serie in language c with gnuplot for my wikibook
Fichier de commande gnuplot :
# ---------------------
# Copy and past this file into the screen of gnuplot
#
#
plot [-1:1] [-.5:2.]\
(x*(x+1)),\
 +0.333333333\
 -0.405284728*cos(3.141592654* 1*x)  +0.636619776*sin(3.141592654* 1*x)\
 +0.101321157*cos(3.141592654* 2*x) -0.318309914*sin(3.141592654* 2*x)\
 -0.045031578*cos(3.141592654* 3*x)  +0.212206684*sin(3.141592654* 3*x)\
 +0.025330190*cos(3.141592654* 4*x)  -0.159155164*sin(3.141592654* 4*x)\
 -0.016211224*cos(3.141592654* 5*x) +0.127324386*sin(3.141592654* 5*x)\
 +0.011257671*cos(3.141592654* 6*x)  -0.106104043*sin(3.141592654* 6*x)\
 -0.008270792*cos(3.141592654* 7*x)  +0.090946870*sin(3.141592654* 7*x)\
 +0.006332148*cos(3.141592654* 8*x) -0.079579249*sin(3.141592654* 8*x)

reset