Mathc initiation/Fichiers h : c22a3


Sommaire


Installer ce fichier dans votre répertoire de travail.

x_nwtn.h
utilitaire
/* --------------------------------- */
/* save as x_nwtn.h                   */
/* --------------------------------- */

/* ---------------------------------
                 f(x_n)
   x_n+1 = x_n - ------
                 f'(x_n) 
  --------------------------------- */
double Newton_s_Method(
double x,
   int imax,
double (*P_f)(double x),
double (*PDf)(double x)
)
{
   int i;

       for(i=1; i<imax; i++)
 
           x -=    ((*P_f)(x)) / ((*PDf)(x));
           
        /* x = x - ((*P_f)(x)) / ((*PDf)(x)); */

 return(x);
}
/* --------------------------------- */
double p_Newton_s_Method(
double x,
   int imax,
double (*P_f)(double x),
double (*PDf)(double x)
)
{
   int i;

       for(i=1; i<(imax+1); i++)
          {
           printf(" x[%d] = %.15f\n",i,x);
           x -=    ((*P_f)(x)) / ((*PDf)(x));
          }
          
        /* x = x - ((*P_f)(x)) / ((*PDf)(x)); */
         
    printf("\n\n");  
           
 return(x);
}
/* ---------------------------------- */
/* ---------------------------------- */


Dans ce fichier il y a les fonctions pour calculer la méthode de newton.