Mathc initiation/Fichiers h : x 18c01b
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c01b.c |
---|
/* ---------------------------------- */
/* save as c01b.c */
/* ---------------------------------- */
#include "x_a.h"
/* ---------------------------------- */
# define DEGREE 5
# define COEFF_NB DEGREE + 1
/* ---------------------------------- */
int main(void)
{
double x = -5;
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] = {3,0,-38,5,0,-1};
clrscrn();
c_a_Px(a,Pa);
printf("\n If P(x) is : \n\n");
p_Px(Pa);
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 the quotien is :\n\n");
p_Px(Pq);
printf(" The synthetic division indicates that P(%+.3f) = %+.3f\n\n",
x, remainder);
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 :
+3.00*x**5 -38.00*x**3 +5.00*x**2 -1.00
If we divide p_A by : x - (+3.000)
+3.00 +0.00 -38.00 +5.00 +0.00 -1.00
+0.00 +9.00 +27.00 -33.00 -84.00 -252.00
------------------------------------------------------------
+3.00 +9.00 -11.00 -28.00 -84.00 -253.00
The synthetic division indicates that the quotien is :
+3.00*x**4 +9.00*x**3 -11.00*x**2 -28.00*x -84.00
The synthetic division indicates that p_A(+3.000) = -253.000
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 [-1.:1.] [-10.:10.]\
+3.00*x**5 -38.00*x**3 +5.00*x**2 -1.00
reset
# ---------------------