Mathc initiation/Fichiers c : c72c09


Sommaire



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

c01c.c
/* ---------------------------------- */
/* save as c1g.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fg.h"
/* ---------------------------------- */
int main(void)
{
int      n =  2*50;
double   a =  2.;
double   b =  3.;

 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)

    (3.000
 int(      (exp(3*x)/(exp(x)+1))  dx = 162.640500
    (2.000



 With the antiderivative of f.

 F(x) = 1/2 exp(x) (exp(x)-2) + ln(exp(x)+1) 


 F(3.000) -  F(2.000)  = 162.640500 


 Press return to continue.



Calculons la primitive :
                           /
Calculer la primitive de  | e**(3*x)/(e**x+1) dx 

  / e**(3x)         /           e**x  
 | --------  dx  = | e**(2x) [ ------ ] dx            
 /  e**x+1         /           e**x+1

       
                    /          e**x +1-1                       (+0 = +1-1)
                 = | e**(2x) [ --------- ] dx            
                   /            e**x+1
 
 
                    /           e**x+1      1
                 = |  e**(2x) [ ------  - ------ ] dx            
                   /            e**x+1    e**x+1
 
 
                    /                  1
                 = |  e**(2x) [ 1  - ------]   dx            
                   /                 e**x+1 
 
 
                    /                   e**x
                 = |     e**x [ e**x  - ------]   dx            
                   /                    e**x+1 
  
 
                    /                   e**x +1-1              (+0 = +1-1)         
                 = |     e**x [ e**x  - --------- ]   dx            
                   /                    e**x+1  
 

                    /                  ( e**x+1     1    )
                 = |     e**x [ e**x  -( ------ - ------ ) ] dx            
                   /                   ( e**x+1   e**x+1 )
                   
                   
                    /                              1
                 = |     e**x [ e**x  -   1     + ------ ]   dx            
                   /                              e**x+1                   
                   
                   
                    /                             e**x
                 = |       [ e**(2x)  -   e**x  + ------ ]   dx            
                   /                              e**x+1                    
                    
                    
                    /              /           / e**x
                 = | e**(2x) dx - | e**x dx + | ------ dx            
                   /              /           / e**x+1                      
                    
                         ___________________
                        |      u =  e**x+1  |            
                        |     du =  e**x dx |                    
                        |___________________|
                        
                        
                   e**(2x)           / 1
                 = ------- - e**x + | --- du
                     2              /  u
       
       
                   e**(2x)            
                 = ------- - e**x + ln(u) + c
                     2              
                            
                   e**(2x)            
                 = ------- - e**x + ln(e**x+1) + c
                     2          
                     
                                                 
                    e**(2x)-2 e**x            
                 = --------------- + ln(e**x+1) + c
                           2                                            
                                     
                    1              
                 = --- e**x (e**x-2) + ln(e**x+1) + c
                    2