Aller au contenu

Mathc initiation/0014

Un livre de Wikilivres.


Sommaire


Installer ce fichier dans votre répertoire de travail.

g_tanmu.h
/* ------------------------------------ */
/*  Save as :   g_tanmu.h               */
/* ------------------------------------ */
void G_TanA(
CTRL_splot w,
tvalue     Time,
  char    fEQ[],
double (*P_f)(double x),
double (*PDf)(double x)
)
{
FILE *fp = fopen("a_main.plt","w");
double t;

fprintf(fp,"# Gnuplot file : load \"a_main.plt\"\n"
           " set zeroaxis\n"
           " unset key\n"
           " plot [%0.3f:%0.3f] [%0.3f:%0.3f] \\\n"
           " %s, \\\n",
           w.xmin,w.xmax,w.ymin,w.ymax,
                 fEQ);

  for(t = Time.min;t<Time.max;t+=Time.step)
  
    fprintf(fp," %0.6f*x %+0.6f, \\\n",
           (*PDf)(t), (-(*PDf)(t)*t+(*P_f)(t)) );

  fprintf(fp," %0.6f*x %+0.6f\n",
         (*PDf)(t), (-(*PDf)(t)*t+(*P_f)(t)) );

fprintf(fp," reset");

 fclose(fp);
}
/* ------------------------------------ */
/* ------------------------------------ */
void G_NorA(
CTRL_splot w,
tvalue     Time,
  char     fEQ[],
double (*P_f)(double x),
double (*PDf)(double x)
)
{
FILE *fp = fopen("a_main.plt","w");
double t;

fprintf(fp,"# Gnuplot file : load \"a_main.plt\"\n"
           " set size ratio -1\n"
           " set zeroaxis\n\n"
           " unset key\n\n"
           " plot [%0.3f:%0.3f] [%0.3f:%0.3f] \\\n"
           " %s, \\\n",
           w.xmin,w.xmax,w.ymin,w.ymax,
           fEQ);

  for(t = Time.min;t<Time.max;t+=Time.step)
  
    fprintf(fp," %0.6f*x %+0.6f, \\\n",
           (-1/(*PDf)(t)), (1/(*PDf)(t)*t+(*P_f)(t)) );

  fprintf(fp," %0.6f*x %+0.6f\n",
         (-1/(*PDf)(t)), (1/(*PDf)(t)*t+(*P_f)(t)) );

fprintf(fp," reset");
 fclose(fp);
}
/* ------------------------------------ */
/* ------------------------------------ */

Dans ce fichier il y a la déclaration des fichiers h.