Aller au contenu

Mathc initiation/Fichiers c : c74c10

Un livre de Wikilivres.


Sommaire


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

c01j.c
/* ---------------------------------- */
/* save as c1j.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fj.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(      (csch(x))  dx = 0.634892
    (0.500



 With the antiderivative of f.

 F(x) = -acoth(cosh(x)) 


 F(1.000) -  F(0.500)  = 0.634892 


 Press return to continue.



Calculons la primitive :
Calculer la primitive de 

       
   /              /   1         
  | csch(x)  dx = | --------  dx     
  /               /  sinh(x)                             
    
    
                   /     1          
                = |  --------     (1)  dx      
                  /   sinh(x)            

                  /            sinh(x)   
                = |  --------  ------- dx      
                 /   sinh(x)   sinh(x)                 
                                        
                                                 ________________________________
                   /    sinh(x)                  | cosh**2(x) - sinh**2(x) = 1  |
                = |  ----------- dx              |                              |
                  /   sinh**2(x)                 | -sinh**2(x)= -cosh**2(x) + 1 |
                                                 |                              |
                                                 |  sinh**2(x)=  cosh**2(x) - 1 |
                                                 |______________________________|
                                                       
                                                 ___________________
                   /     1                       |  u = cosh(x)    |    
                = | --------------- sinh(x) dx   | du = sinh(x) dx | 
                  /  cosh**2(x) - 1              |_________________|                                           
       

                                                       
                       /     1                     
                =     |  ----------  du          u**2 > 1 
                      /   u**2 - 1                  
                                                   
                                                   
                =      - acoth(u)       + c                        
      
                =      - acoth(cosh(x)) + c    
                
                
                                   ___________________________
                                   |  acoth(x) = atanh(1/x)  | 
                
                =      - acoth(u)  + c         =    -atanh(1/u)     + c              
      
                =      - acoth(cosh(x)) + c    = -atanh(1/cosh(x))  + c