Mathc initiation/Fichiers c : 81c


Sommaire

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

c_c.c
/* ---------------------------------- */
/* save as c_c.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fc.h"
/* ---------------------------------- */
int main(void)
{
int      n =  2*300;
double   a =  0.;
double   b =  0.;
double   M =  0.;

 printf(" Improper integral with the Simpson's rule. (with discontinuity)\n\n");
 
      b =  3.;
      M = simpson(f,a,b,n);
      
 printf("     / b = %+.7f\n", b);
 printf("    |\n");
 printf("    |    %s dx = %.6f\n", feq, M);
 printf("    |\n");
 printf("   /   a = %+.7f\n\n", a);
 printf("  Error (1/0) \n\n\n");


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

 printf(" (mathematica)  exact value = %.6f\n\n", 2*sqrt(3));

 stop();

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



Exemple de sortie écran :

 Improper integral with the Simpson's rule. (with discontinuity)

     / b = +3.0000000
    |
    |    1/sqrt(3-x) dx = inf
    |
   /   a = +0.0000000

  Error (1/0) 


 Improper integral with the Simpson's rule.

     / b = +2.9996930
    |
    |    1/sqrt(3-x) dx = 3.464144
    |
   /   a = +0.0000000

 (mathematica)  exact value = 3.464102

 Press return to continue.