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

c04a.c
'
/* ---------------------------------- */
/* save as c04a.c                     */
/* ---------------------------------- */
#include "x_hfile.h"
/* ---------------------------------- */
# define   DEGREE  4
# define   COEFF   DEGREE + 1
/* ---------------------------------- */
int main(void)
{
int    n = COEFF;
double x = -6.;

double *Px = I_p(n);
double *Pt = I_p(n);
double *Pa = I_p(n);
double *Pq = I_p((n-1));

double a[COEFF]={1.,3.,-30.,-6.,56.};

 clrscrn();
 x = -4.;
 c_a_P(a,Px);
 printf(" If P(x) is : \n\n");
 p_P(Px);
 printf(" Find an lower bound for the zeros of P(x).\n\n");
 printf(" If we divide P(x) by : x - (%+.2f)\n\n",x);
 compute_horner(x,Px,Pt,Pa,Pq);
 p_horner(Px,Pt,Pa);
 printf(" The third row does not alternate in sign\n\n");
 printf(" So %+.3f is not a lower bound for the zeros of P(x)\n\n",x);
 stop();

 clrscrn();
 x = -8.;
 printf(" If we divide P(x) by : x - (%+.2f)\n\n",x);
 compute_horner(x,Px,Pt,Pa,Pq);
 p_horner(Px,Pt,Pa);
 printf(" The third row alternates in sign.\n\n");
 printf(" So %+.2f is a lower bound for the zeros of P(x).\n\n",x);
 
 stop();
 
 free(Px);
 free(Pt);
 free(Pa);
 free(Pq);
 
 return 0;
}


Vérifier les calculs à la main. (Voir le premier exemple pour apprendre la méthode de Horner)


Exemple de sortie écran 1 :

 If p_A is : 

   + x**4  +3.00*x**3  -30.00*x**2  -6.00*x  +56.00  


 Find an lower bound for the zeros of p_A.

 If we divide p_A by : x - (-4.00)


     +1.00     +3.00    -30.00     -6.00    +56.00   
     +0.00     -4.00     +4.00   +104.00   -392.00   
   --------------------------------------------------
     +1.00     -1.00    -26.00    +98.00   -336.00   


 The third row does not alternate in sign

 So -4.000 is not a lower bound for the zeros of p_A

 Press return to continue.


Exemple de sortie écran 2 :

 If we divide p_A by : x - (-8.00)


     +1.00     +3.00    -30.00     -6.00    +56.00   
     +0.00     -8.00    +40.00    -80.00   +688.00   
   --------------------------------------------------
     +1.00     -5.00    +10.00    -86.00   +744.00   


 The third row alternates in sign.

 So -8.00 is a lower bound for the zeros of p_A.

 Press return to continue.
Cet article est issu de Wikibooks. Le texte est sous licence Creative Commons - Attribution - Partage dans les Mêmes. Des conditions supplémentaires peuvent s'appliquer aux fichiers multimédias.