Mathc initiation/Fichiers c : 81b

Un livre de Wikilivres.


Sommaire

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

c_b.c
/* ---------------------------------- */
/* save as c_b.c                      */
/* ---------------------------------- */
#include "x_hfile.h"

#include      "fb.h"
/* ---------------------------------- */
int main(void)
{
int      n =  2*300;
double   a =  -100;
double   b =  1.;
double   M =  simpson(f,a,b,n);

 printf(" Improper integral with the Simpson's rule.\n\n");
 printf("      / b = %+.2f\n", b);
 printf("     |\n");
 printf("     |   %s dx = %.6f\n", feq, M);
 printf("     |\n");
 printf("    /  a = -oo\n\n");

 printf("                  e = %.6f\n\n", exp(1));

 for(a=1000; a>1;a/=10)
     printf(" a = %-6.0f  M = %.6f\n", -a, simpson(f,-a,b,n));

 printf(" \n\n" 
        "   In c language  -100 < -oo < -10 \n\n"); 
        
 stop();
 
 return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */



Exemple de sortie écran :

 Improper integral with the Simpson's rule.

      / b = +1.00
     |
     |   exp(x) dx = 2.718294
     |
    /  a = -oo

                  e = 2.718282

 a = -1000   M = 2.805325
 a = -100    M = 2.718294
 a = -10     M = 2.718236
 

   In c language  -100 < -oo < -10 

 Press return to continue.