Mathc initiation/Fichiers c : c38cd
Installer et compiler ces fichiers dans votre répertoire de travail.
c05a.c |
---|
/* ---------------------------------- */
/* save as c05d.c */
/* ---------------------------------- */
#include "x_hfile.h"
#include "fd.h"
/* ---------------------------------- */
int main(void)
{
double a = -1.5;
double b = 1.5;
double n = 2*5.;
clrscrn();
printf(" Verify with a software that g(x) >= h(x) on [%.3f,%.3f].\n\n\n", a, b);
printf(" g : x-> %s\n\n", geq);
printf(" h : x-> %s\n\n", heq);
stop();
clrscrn();
printf(" Draw a typical vertical rectangle on a graph.\n\n");
printf(" Upper boundary (g) : %s \n",geq);
printf(" lower boundary (h) : %s \n\n",heq);
printf(" The length of the rectangle is : (%s) - (%s) \n",geq, heq);
printf(" The width of the rectangle is : dx \n\n");
printf(" The Area of the rectangle is : ((%s) - (%s)) * dx\n",geq, heq);
printf(" \n\n\n\n\n");
stop();
clrscrn();
printf(" If we apply \n\n\n");
printf(" (%.3f\n", b);
printf(" int( \n");
printf(" (%.3f\n\n\n", a);
printf(" to : ((%s) - (%s)) * dx\n\n", geq, heq);
printf(" We obtain a limit of sums of areas of vertical rectangles.\n\n\n");
printf(" (%.3f\n", b);
printf(" int( [(%s) - (%s)] dx = %.5f\n",
geq,heq,simpson(gminuh,a,b,n));
printf(" (%.3f\n\n\n", a);
stop();
return 0;
}
/* ---------------------------------- */
Vous trouverez ci-dessous le code Gnuplot pour dessiner les fonctions et un rectangle caractèristique. Ainsi que le code pour Octave pour vérifier le calcul.
Exemple de sortie écran :
Verify with a software that g(x) >= h(x) on [-1.500,1.500].
g : x-> cos(x)
h : x-> -x*x-2
Press return to continue.
Copier ce code dans gnuplot :
set zeroaxis lt 8
set grid
set object rect from 1,(-1*1-2) to 1.3,cos(1.3)
plot [ -1.5:1.5] [-5.000:1.500] cos(x), (-x*x-2)
reset
Exemple de sortie écran :
Draw a typical vertical rectangle on a graph.
Upper boundary (g) : cos(x)
lower boundary (h) : -x*x-2
The length of the rectangle is : (cos(x)) - (-x*x-2)
The width of the rectangle is : dx
The Area of the rectangle is : ((cos(x)) - (-x*x-2)) * dx
Press return to continue.
Exemple de sortie écran :
If we apply
(1.500
int(
(-1.500
to : ((cos(x)) - (-x*x-2)) * dx
We obtain a limit of sums of areas of vertical rectangles.
(1.500
int( [(cos(x)) - (-x*x-2)] dx = 10.24508
(-1.500
Press return to continue.
Vérifier le résultat avec Octave 5.2 : I = quad (f, a, b)
>> I = quad (@(x) ((cos(x)) - (-x*x-2)), -1.5,1.5)
I = 10.245