Mathc initiation/Fichiers c : c39cc

Un livre de Wikilivres.


Sommaire

En géométrie, la question de la longueur d'un arc est simple à concevoir (intuitive). L'idée d'arc correspond à celle d'une ligne, ou d'une trajectoire d'un point dans un plan ou l'espace par exemple. Sa longueur peut être vue comme la distance parcourue par un point matériel suivant cette trajectoire ou encore comme la longueur d'un fil prenant exactement la place de cette ligne. La longueur d'un arc est, soit un nombre positif, soit l'infini. [wikipedia]


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

c05c.c
/* ---------------------------------- */
/* save as c00c.c                     */
/* ---------------------------------- */
#include "x_hfile.h"
#include      "fc.h"
/* ---------------------------------- */
int main(void)
{
double    a =   0.;
double    b =PI/2.;
double step =  .01;

 clrscrn();

 printf(" Let f be smooth on [%.3f,%.3f].\n\n", a, b);
 printf("  f : x-> %s\n\n",   feq);
 printf(" Df : x-> %s\n\n\n", Dfeq);

 printf(" The arc length of the graph of f from A(a,f(a)) to B(b,f(b)) is :\n\n");
 printf("    (b\n");
 printf(" int(       sqrt( 1 + Df(x)**2 )* dx\n");
 printf("    (a\n\n");

 printf(" For f : \n\n"
        "    (%.3f\n"
        " int(        sqrt(1+(%s)**2) * dx = %.2f\n"
        "    (%.3f\n\n\n",

         b,
            Dfeq, simpson(ArcLength,a,b,2*30000),
         a);

 printf(" Open the file \"a_main.plt\" with Gnuplot.\n\n");

    G_ArcLength(-1.5,     /* xmin  */
                 2.5,     /* xmax  */
                -0.5,     /* ymin  */
                 1.5,     /* ymax  */
                   a,
                   b,
                step,
                 feq,
                   f);

 stop();

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


Cette fois nous utilisons les intégrales pour calculer la longueur d'une courbe de la forme f(x).

Résultat dans gnuplot
With Gnuplot and with the C Language


Exemple de sortie écran :

 Let f be smooth on [0.000,1.571].

  f : x-> sin(x)

 Df : x-> cos(x)


 The arc length of the graph of f from A(a,f(a)) to B(b,f(b)) is :

    (b
 int(       sqrt( 1 + Df(x)**2 )* dx
    (a

 For f : 

    (1.571
 int(        sqrt(1+(cos(x))**2) * dx = 1.91010
    (0.000


 Press return to continue.


Vérifier le résultat avec Octave 5.2 :

I = quad (f, a, b) 
>> I = quad (@(x) (sqrt(1+(cos(x).*cos(x)))), 0.000,1.571)
ans =  1.9103