Mathc initiation/Fichiers c : c79c04


Sommaire


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

c01d.c
/* ---------------------------------- */
/* save as c1d.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fd.h"
/* ---------------------------------- */
int main(void)
{
int      n =  2*50;
double   a =  .5;
double   b =   1.;

 clrscrn();

 printf(" With the Simpson's rule.    (n = %d)\n\n"
        "    (%.3f\n"
        " int(      (%s)  dx = %.6f\n"
        "    (%.3f\n\n\n\n",n,  b, feq, simpson(f,a,b,n), a);

 printf(" With the antiderivative of f.\n\n"
        " F(x) = %s \n\n\n" 
        " F(%.3f) -  F(%.3f)  = %.6f \n\n\n", Feq, b,a, F(b)-F(a));
 
 stop();

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


Calculons l'intégrale avec la fonction simpson(f,a,b,n); puis avec sa primitive F(x).


Exemple de sortie écran :
 With the Simpson's rule.    (n = 100)

    (1.000
 int(      (1/(1-sin(x))  dx = 1.722427
    (0.500



 With the antiderivative of f.

 F(x) =  tan(x) + sec(x) 


 F(1.000) -  F(0.500)  = 1.722427 


 Press return to continue.



Calculons la primitive :
                               /
                              |   1
 1)  Calculer la primitive de | -------- dx 
                              | 1-sin(x)
                              /

   /                 /                                  
  |      1          |   1        1+sin(x)
  |  -------- dx  = | --------   -------- dx 
  |  1-sin(x)       | 1-sin(x)   1+sin(x)
  /                 /           
                                                               

                     /                                  
                    |    1+sin(x)
                 =  | ------------ dx 
                    |  1-sin(x)**2   
                    /     
                                                          sin(x)**2+cos(x)**2 = 1
                                                                                      
                     /                                  
                    |  1+sin(x)
                 =  |  --------- dx 
                    |  cos(x)**2   
                    /   
                                 
                                 
                     /                 /                  
                    |      1          |  sin(x)
                 =  |  --------- dx + | --------- dx
                    |  cos(x)**2      | cos(x)**2 
                    /                 /                    
                                 
                                 
                     /                 /                  
                 =  |  sec(x)**2 dx + | tan(x) sec(x) dx
                    /                 /
                    
                                                                 
                   /                    
                  |  1/(1-sin(x)) dx  =  tan(x) + sec(x) + c    
                  /