Mathc initiation/Fichiers h : x 18c04b
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c04b.c |
---|
/* ---------------------------------- */
/* save as c04b.c */
/* ---------------------------------- */
#include "x_a.h"
/* ---------------------------------- */
# define DEGREE 6
# define COEFF_NB DEGREE + 1
/* ---------------------------------- */
int main(void)
{
double x = -1;
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]={5,3,-2,6,5,-2,-9};
clrscrn();
x = -1;
c_a_Px(a,Pa);
printf(" If P(x) is : \n\n");
p_Px(Pa);
printf(" Find an lower bound for the zeros of P(x).\n\n");
printf(" If we divide P(x) by : x - (%+.2f)\n\n\n",x);
compute_horner(x,Pa,Pt,Pqr,Pq);
p_horner(Pa,Pt,Pqr);
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 = -2.;
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 alternates in sign.\n\n");
printf(" So %+.2f is a lower 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 :
If p_A is :
+5.00*x**6 +3.00*x**5 -2.00*x**4 +6.00*x**3 +5.00*x**2 -2.00*x -9.00
Find an lower bound for the zeros of p_A.
If we divide p_A by : x - (-1.00)
+5.00 +3.00 -2.00 +6.00 +5.00 -2.00 -9.00
+0.00 -5.00 +2.00 -0.00 -6.00 +1.00 +1.00
----------------------------------------------------------------------
+5.00 -2.00 +0.00 +6.00 -1.00 -1.00 -8.00
The third row does not alternate in sign
So -1.000 is not a lower 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 [-2.:1.5] [-10.:20.]\
+5.00*x**6 +3.00*x**5 -2.00*x**4 +6.00*x**3 +5.00*x**2 -2.00*x -9.00
reset
# ---------------------