Aller au contenu

Mathc initiation/Fichiers c : c74c03

Un livre de Wikilivres.


Sommaire


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

c01c.c
/* ---------------------------------- */
/* save as c1c.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fc.h" 
/* ---------------------------------- */
int main(void)
{
int      n =  2*50;
double   a =  0.;
double   b =  .5;

 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)

    (0.500
 int(      (tan(x))  dx = 0.130584
    (0.000



 With the antiderivative of f.

 F(x) = - ln( |cos(x)| ) 


 F(0.500) -  F(0.000)  = 0.130584 


 Press return to continue.



Calculons la primitive :
             
Calculer la primitive de 

       
   /               /            
  | tan(x)  dx =  |  sin(x)/cos(x) dx     
  /               /                                         
                        
                                       ___________________________
                   /  sin(x) dx        |     u =       cos(x)    |
               =  |   -----            |     du = (-1) sin(x) dx |                       
                  /   cos(x)           |(-1) du =      sin(x) dx | 
                                       |_________________________|
                       
   /               /   (-1)  du      
  | tan(x)  dx =  |   -----     
  /               /     u                                    
                                   
                                   
   /                    /  1       
  | tan(x)  dx =  (-1) |  ----- du     
  /                    /   u                                    
                                                        
                                   
               =  - ln(   |u|    ) + c    
                                               _______________________________________            
               =  - ln( |cos(x)| ) + c        | (-1) ln(a )         = ln( 1/a)        |
                                              | (-1) ln(|cos(x)|)   = ln( |1/cos(x)|) |
               =    ln( |sec|    ) + c        |                     = ln( |sec(x)|)   | 
                                              |_______________________________________|