Mathc initiation/Fichiers h : x 18c02a
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c02a.c |
---|
/* ---------------------------------- */
/* save as c02a.c */
/* ---------------------------------- */
#include "x_a.h"
/* ---------------------------------- */
# define DEGREE 3
# define COEFF_NB DEGREE + 1
/* ---------------------------------- */
int main(void)
{
double x = -11;
double remainder;
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,8,-29,44};
clrscrn();
c_a_Px(a,Pa);
printf("\n If P(x) is : \n\n");
p_Px(Pa);
printf(" Verify if %+.3f is a root of P(x) \n\n",x);
printf(" If we divide P(x) by : x - (%+.3f)\n\n",x);
remainder = compute_horner(x,Pa,Pt,Pqr,Pq);
p_horner(Pa,Pt,Pqr);
printf(" The synthetic division indicates that P(%+.3f) = %+.3f\n\n",
x, remainder);
printf(" So %+.3f is a root 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 :
+ x**3 +8.00*x**2 -29.00*x +44.00
Verify if -11.000 is a root of p_A
If we divide p_A by : x - (-11.000)
+1.00 +8.00 -29.00 +44.00
+0.00 -11.00 +33.00 -44.00
----------------------------------------
+1.00 -3.00 +4.00 +0.00
The synthetic division indicates that p_A(-11.000) = +0.000
So -11.000 is a root 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 [-12.:7.] [-5.:400.]\
+ x**3 +8.00*x**2 -29.00*x +44.00
reset
# ---------------------
Fichier de commande gnuplot :
# ---------------------
# Copy and past this file into the screen of gnuplot
#
#
set zeroaxis lt 3 lw 1
plot [-12.:-10] [0.:20.]\
+ x**3 +8.00*x**2 -29.00*x +44.00
reset
# ---------------------