Mathc initiation/Fichiers h : x 18c02b
Installer et compiler ces fichiers dans votre répertoire de travail.
c02b.c |
---|
/* ---------------------------------- */
/* save as c02b.c */
/* ---------------------------------- */
#include "x_hfile.h"
/* ---------------------------------- */
# define DEGREE 4
# define COEFF DEGREE + 1
/* ---------------------------------- */
int main(void)
{
int n = COEFF;
double x = 4.;
double remainder;
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();
c_a_P(a,Px);
printf("\n If P(x) is : \n\n");
p_P(Px);
printf(" Verify if %+.3f is a root of P(x) \n\n",x);
printf(" If we divide P(x) by : x - (%+.3f)\n\n\n",x);
remainder = compute_horner(x,Px,Pt,Pa,Pq);
p_horner(Px,Pt,Pa);
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(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 :
If p_A is :
+ x**4 +3.00*x**3 -30.00*x**2 -6.00*x +56.00
Verify if +4.000 is a root of p_A
If we divide p_A by : x - (+4.000)
+1.00 +3.00 -30.00 -6.00 +56.00
+0.00 +4.00 +28.00 -8.00 -56.00
--------------------------------------------------
+1.00 +7.00 -2.00 -14.00 +0.00
The synthetic division indicates that p_A(+4.000) = +0.000
So +4.000 is a root of p_A
Press return to continue.