Aller au contenu

Mathc initiation/a616

Un livre de Wikilivres.


Sommaire


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

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

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

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++)
    {
     A[n] = 2./T * fourier_an(f, a,b, omega, 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*cos(%.9f* %d*x)  %+.9f*sin(%.9f* %d*x)\\\n", 
         A[n], omega, n,
         B[n], omega, n);

 printf(" %+.9f*cos(%.9f* %d*x)  %+.9f*sin(%.9f* %d*x)\n", 
         A[n], omega, n,
         B[n], omega, n); 
          
 stop();

 return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */

Exemple de sortie écran :

  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.000150672*cos(3.141592654* 48*x)  -0.013779127*sin(3.141592654* 48*x)\
 -0.000141849*cos(3.141592654* 49*x)  +0.013549424*sin(3.141592654* 49*x)\
 +0.000133333*cos(3.141592654* 50*x)  -0.013333333*sin(3.141592654* 50*x)


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