Mathc initiation/Fichiers h : x 18c03a


Sommaire



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

c03a.c
/* ---------------------------------- */
/* save as c03a.c                     */
/* ---------------------------------- */
#include "x_a.h"
/* ---------------------------------- */
# define   DEGREE     4
# define   COEFF_NB   DEGREE + 1
/* ---------------------------------- */
int main(void)
{
double x = 3.;

double *Pa  = I_Px( COEFF_NB);
double *Pt  = I_Px( COEFF_NB);
double *Pqr = I_Px( COEFF_NB);
double *Pq  = I_Px((COEFF_NB-1));

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

 clrscrn();
 
 x = 3.;
 c_a_Px(a,Pa);
 printf("\n If P(x) is : \n\n");
 p_Px(Pa);
 
 printf(" Find an upper bound for the zeros of P(x).\n\n");
 printf(" If we divide P(x) by : x - (%+.2f)\n\n",x);
 compute_horner(x,Pa,Pt,Pqr,Pq);
 p_horner(Pa,Pt,Pqr);
 
 printf(" The third row have some negative numbers\n\n");
 printf(" So %+.3f is not an upper bound for the zeros of P(x)\n\n",x);
 stop();

 clrscrn();
 
 x = 5.;
 printf(" If we divide P(x) by : x - (%+.2f)\n\n",x);
 compute_horner(x,Pa,Pt,Pqr,Pq);
 p_horner(Pa,Pt,Pqr);
 
 printf(" The third row are nonnegative numbers.\n\n");
 printf(" So %+.2f is an upper bound for the zeros of P(x).\n\n",x);
 
 stop();
 
 free(Pa);
 free(Pt);
 free(Pqr);
 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 upper bound for the zeros of p_A.

 If we divide p_A by : x - (+3.00)


     +1.00     +3.00    -30.00     -6.00    +56.00   
     +0.00     +3.00    +18.00    -36.00   -126.00   
   --------------------------------------------------
     +1.00     +6.00    -12.00    -42.00    -70.00   


 The third row have some negative numbers

 So +3.000 is not an upper bound for the zeros of p_A

 Press return to continue.


Exemple de sortie écran 2 :

 If we divide p_A by : x - (+5.00)


     +1.00     +3.00    -30.00     -6.00    +56.00   
     +0.00     +5.00    +40.00    +50.00   +220.00   
   --------------------------------------------------
     +1.00     +8.00    +10.00    +44.00   +276.00   


 The third row are nonnegative numbers.

 So +5.00 is an upper bound for the zeros of p_A.

 Press return to continue.


Fichier de commande gnuplot :
# ---------------------
# Copy and past this file into the screen of gnuplot
#
#
set zeroaxis lt 3 lw 1
plot [-8.:5.] [-450.:100.]\
      + x**4  +3.00*x**3  -30.00*x**2  -6.00*x  +56.00
reset
# ---------------------