Mathc gnuplot/Application : Tangente de f(x,y)

Un livre de Wikilivres.
Mathc gnuplot
Mathc gnuplot
Mathc gnuplot
Sommaire

I - Dessiner

Fichiers h partagés :

Application :

II - Animer

Application :

III - Géométrie de la tortue standard

Application :

IV - Géométrie de la tortue vectorielle

Application :

Annexe

Livre d'or



Préambule[modifier | modifier le wikicode]

La tangente dans Wikipedia.


Présentation[modifier | modifier le wikicode]

N'oubliez pas les fichiers *.h partagés et ceux de ce chapitre.

Dessiner la tangente[modifier | modifier le wikicode]

  • La méthode consiste à poser :
    • x = i (ici i=1).
    • D'utiliser la dérivée partielle par rapport à y.
    • Puis écrire l'équation de la tangente d'une fonction en y.


c01.c
Dessiner la tangente
/* ------------------------------------ */
/*  Save as :   c01.c                   */
/* ------------------------------------ */
#include "x_ahfile.h"
#include       "fa.h"
/* ------------------------------------ */
int main(void)
{
point2d p = i_point2d(1,2);
double  h = .001;

 printf(" Draw the equation of the tangent\n\n");
 printf(" at the point P(%.0f,%.0f),\n\n",p.x,p.y);
 printf(" on the plan x = %.0f for f(x,y).\n\n\n",p.x);
 printf(" f : (x,y)-> %s\n\n\n", feq);

 printf(" Cartesian form :\n\n"
        " z = %f y %+f\n\n",
        fxy_y(f,h,p),
        f(p.x,p.y)-fxy_y(f,h,p)*p.y);

       G_3d_p(i_WGnuplot(-10.,10.,-10.,10.),
              i_VGnuplot( 55.,57.,  1., 1.),
              feq,f,
              p);

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

 getchar();

 return 0;
}

Le résultat.


Résultat dans gnuplot
Tangente28


Les fichiers h de ce chapitre[modifier | modifier le wikicode]

x_ahfile.h
Appel des fichiers
/* ------------------------------------ */
/*  Save as :   x_ahfile.h              */
/* ------------------------------------ */
#include    <stdio.h>
#include   <stdlib.h>
#include    <ctype.h>
#include     <time.h>
#include     <math.h>
#include   <string.h>
/* ------------------------------------ */
#include     "xdef.h"
#include     "xspv.h"
#include     "xplt.h"
#include   "xfxy_x.h"
/* ------------------------------------ */
#include    "kg_3d.h"


fa.h
La fonction à dessiner
/* ------------------------------------ */
/*  Save as :   fa.h                    */
/* ------------------------------------ */
double f(
double x,
double y)
{
 return( (9-x*x-y*y) );
}
char  feq[] = "9-x**2-y**2";


kg_3d.h
La fonction graphique
/* ------------------------------------ */
/*  Save as :   kg_3d.h                  */
/* ------------------------------------ */
void G_3d_p(
W_Ctrl W,
View_Ctrl V,
  char feq[],
double (*P_f)(double x, double y),
point2d p
)
{
FILE   *fp;
double a,b;
double    h = .001;
double step = 0.2;

        fp = fopen("a_main.plt","w");
fprintf(fp,"set isosamples 50\n"
           "set hidden3d\n"
           "set xlabel \"X axis\"\n"
           "set ylabel \"Y axis\"\n"
           "set zlabel \"Z axis\" offset 1, 0\n"
           "set view %0.3f, %0.3f, %0.3f, %0.3f \n"
           "splot[%0.3f:%0.3f][%0.3f:%0.3f]\\\n"
           "\"a_tan.plt\" with linesp lt 1 pt 3,\\\n"
           "\"a_p.plt\" pt 20,\\\n"
           "%s \n\n",
        V.rot_x,V.rot_z,V.scale,V.scale_z,
        W.xmini,W.xmaxi,W.ymini,W.ymaxi, feq);
 fclose(fp);

         fp = fopen("a_p.plt","w");
 fprintf(fp," %6.3f %6.3f %6.3f\n",
          p.x,p.y, (*P_f)(p.x,p.y));
  fclose(fp);

  a=fxy_y((*P_f),h,p);
  b=((*P_f)(p.x,p.y)-fxy_y((*P_f),h,p)*p.y);

  fp = fopen("a_tan.plt","w");
    for(p.y=W.ymini; p.y<W.ymaxi;p.y+=step)
      fprintf(fp," %6.3f %6.3f %6.3f\n",
              p.x,p.y, a*p.y+b);
 fclose(fp);

  Pause();
}