Mathc initiation/Fichiers c : 81c

Un livre de Wikilivres.
Aller à la navigation Aller à la recherche


Sommaire

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

Crystal Clear mimetype source c.png c_c.c
/* ---------------------------------- */
/* save as c_c.c                      */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fc.h"
/* ---------------------------------- */
int main(void)
{
int      n =  2*300000;
double   a =  3.;
double   b =  0.;
double   M =  0.;

 printf(" Improper integral with the Simpson's rule. (with discontinuity)\n\n");
 
      n =  2*30000;
      a =  0.;
      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");
 
      n =  2*900000;
      a =  0;
      b =  2.9999999;
      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.9999999
    |
    |    1/sqrt(3-x) dx = 3.464125
    |
   /   a = +0.0000000

 (mathematica)  exact value = 3.464102

 Press return to continue.