Mathc matrices/26a
Application
Copier la bibliothèque dans votre répertoire de travail avec les fichiers des parties précédentes :
Ne pas conserver le fichier d.h avec la librairie après avoir testé les exemples. 
 Présentation :
 Calculons les coefficients d'un polynôme.
 y = ax**2 + bx + c 
 qui passe par ces trois points. 
 x[1], y[1] 
 x[2], y[2] 
 x[3], y[3] 
 En utilisant les points nous obtenons la matrice :
 x**2 x**1 x**0 y
 x[1]**2 x[1]**1 x[1]**0 y[1]
 x[2]**2 x[2]**1 x[2]**0 y[2]
 x[3]**2 x[3]**1 x[3]**0 y[3]
 Que nous pouvons écrire :
 x**2 x 1 y
 x[1]**2 x[1] 1 y[1]
 x[2]**2 x[2] 1 y[2]
 x[3]**2 x[3] 1 y[3]
 Utilisons la fonction gj_TP_mR(Ab); pour résoudre 
 le système qui va nous donner les coefficients a,b,c
Les exemples :

Mathc matrices/h26a
Application
Installer ce fichier dans votre répertoire de travail.
/* Save as : d.h */
void i_A_b_with_XY_mR(
double **XY,
double **A,
double **b
int r = R1;
int c = C1;
int power = 0;
 for(r=R1; r<XY[R_SIZE][C0]; r++)
 power=rsize_R(XY)-R1; 
 for(c=C1; c<A[C_SIZE][C0]; c++)
 A[r][c]=pow(XY[r][C1],power--);
 b[r][C1]=XY[r][C2];
void p_eq_poly_mR(
double **Ab
int r = R1;
int power = rsize_R(Ab)-R1; 
int cL = csize_R(Ab);
 printf(" y = ");
 for(r=R1;r<Ab[R_SIZE][C0];r++)
 if(Ab[r][cL])
 if(!power) printf(" %+.3f", Ab[r][cL]);
 else printf(" %+.3fx**%d",Ab[r][cL], power--);

printf("\n\n\n");
/* --------------------------------- */
void verify_X_mR(
double **Ab,
double x
int r = R1;
int power = rsize_R(Ab)-R1;
int cL = csize_R(Ab);
double y = 0.;
 for(;r<Ab[R_SIZE][C0];r++)
 y+= Ab[r][cL]*pow(x,power--);
 printf(" With x = %+.3f, y = %+.3f \n",x,y);
/* --------------------------------- */
 Déclaration des fichiers h.

Mathc matrices/c26a1
Application 
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c01.c */
int main(void)
double xy[6] ={1, 6,
 2, 3,
 3, 5 };
double **XY = ca_A_mR(xy,i_mR(R3,C2));
double **A = i_mR(R3,C3);
double **b = i_mR(R3,C1);
double **Ab = i_Abr_Ac_bc_mR(R3,C3,C1);
 clrscrn();
 printf("\n");
 printf(" Find the coefficients a, b, c of the curve \n\n");
 printf(" y = ax**2 + bx + c (x**0 = 1) \n\n");
 printf(" that passes through the points. \n\n");
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n Using the given points, we obtain this matrix\n\n");
 printf(" x**2 x**1 x**0 y\n");
 i_A_b_with_XY_mR(XY,A,b);
 c_A_b_Ab_mR(A,b,Ab);
 p_mR(Ab,S7,P2,C6);
 stop();
 clrscrn();
 printf(" The Gauss Jordan process will reduce this matrix to : \n");
 gj_TP_mR(Ab);
 p_mR(Ab,S7,P2,C6);
 printf("\n The coefficients a, b, c of the curve are : \n\n");
 p_eq_poly_mR(Ab);
 stop();
 clrscrn();
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Verify the result : \n\n");
 verify_X_mR(Ab,XY[R1][C1]);
 verify_X_mR(Ab,XY[R2][C1]);
 verify_X_mR(Ab,XY[R3][C1]);
 printf("\n\n\n");
 stop();
 f_mR(XY);
 f_mR(A);
 f_mR(b);
 f_mR(Ab);
 return 0;
/* ------------------------------------ */

Exemple de sortie écran :
 Find the coefficients a, b, c of the curve 
 y = ax**2 + bx + c (x**0 = 1) 
 that passes through the points. 
 x y 
 +1 +6 
 +2 +3 
 +3 +5 
 Using the given points, we obtain this matrix
 x**2 x**1 x**0 y
 +1.00 +1.00 +1.00 +6.00 
 +4.00 +2.00 +1.00 +3.00 
 +9.00 +3.00 +1.00 +5.00 
 Press return to continue. 
 The Gauss Jordan process will reduce this matrix to : 
 +1.00 +0.00 +0.00 +2.50 
 +0.00 +1.00 +0.00 -10.50 
 +0.00 +0.00 +1.00 +14.00 
 The coefficients a, b, c of the curve are : 
 y = +2.500x**2 -10.500x +14.000
 Press return to continue. 
 x y 
 +1 +6 
 +2 +3 
 +3 +5 
 Verify the result : 
 With x = +1.000, y = +6.000 
 With x = +2.000, y = +3.000 
 With x = +3.000, y = +5.000 
 Press return to continue.

Mathc matrices/c26a2
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c02.c */
int main(void)
double xy[6] ={1, -9,
 2, 8,
 3, -8, };
double **XY = ca_A_mR(xy,i_mR(R3,C2));
double **A = i_mR(R3,C3);
double **b = i_mR(R3,C1);
double **Ab = i_Abr_Ac_bc_mR(R3,C3,C1);
 clrscrn();
 printf("\n");
 printf(" Find the coefficients a, b, c of the curve \n\n");
 printf(" y = ax**2 + bx + c (x**0 = 1) \n\n");
 printf(" that passes through the points. \n\n");
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n Using the given points, we obtain this matrix\n\n");
 printf(" x**2 x**1 x**0 y\n");
 i_A_b_with_XY_mR(XY,A,b);
 c_A_b_Ab_mR(A,b,Ab);
 p_mR(Ab,S7,P2,C6);
 stop();
 clrscrn();
 printf(" The Gauss Jordan process will reduce this matrix to : \n");
 gj_TP_mR(Ab);
 p_mR(Ab,S7,P2,C6);
 printf("\n The coefficients a, b, c of the curve are : \n\n");
 p_eq_poly_mR(Ab);
 stop();
 clrscrn();
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Verify the result : \n\n");
 verify_X_mR(Ab,XY[R1][C1]);
 verify_X_mR(Ab,XY[R2][C1]);
 verify_X_mR(Ab,XY[R3][C1]);
 printf("\n\n\n");
 stop();
 f_mR(XY);
 f_mR(A);
 f_mR(b);
 f_mR(Ab);
 return 0;
/* ------------------------------------ */

Exemple de sortie écran :
 Find the coefficients a, b, c of the curve 
 y = ax**2 + bx + c (x**0 = 1) 
 that passes through the points. 
 x y 
 +1 -9 
 +2 +8 
 +3 -8 
 Using the given points, we obtain this matrix
 x**2 x**1 x**0 y
 +1.00 +1.00 +1.00 -9.00 
 +4.00 +2.00 +1.00 +8.00 
 +9.00 +3.00 +1.00 -8.00 
 Press return to continue. 
 The Gauss Jordan process will reduce this matrix to : 
 +1.00 +0.00 +0.00 -16.50 
 +0.00 +1.00 +0.00 +66.50 
 +0.00 +0.00 +1.00 -59.00 
 The coefficients a, b, c of the curve are : 
 y = -16.500x**2 +66.500x -59.000
 Press return to continue. 
 x y 
 +1 -9 
 +2 +8 
 +3 -8 
 Verify the result : 
 With x = +1.000, y = -9.000 
 With x = +2.000, y = +8.000 
 With x = +3.000, y = -8.000 
 Press return to continue.

Mathc matrices/c26a3
Application ou Résoudre avec ...
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : c03.c */
int main(void)
double xy[8] ={ -5, -3,
 -2, 0,
 2, 3,
 3, -2 };
double **XY = ca_A_mR(xy,i_mR(R4,C2));
double **A = i_mR(R4,C4);
double **b = i_mR(R4,C1);
double **Ab = i_Abr_Ac_bc_mR(R4,C4,C1);
 clrscrn();
 printf("\n");
 printf(" Find the coefficients a, b, c of the curve \n\n");
 printf(" y = ax**3 + bx**2 + cx + d \n\n");
 printf(" that passes through the points. \n\n");
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n Using the given points, we obtain this matrix\n\n");
 printf(" x**3 x**2 x**1 x**0 y\n");
 i_A_b_with_XY_mR(XY,A,b);
 c_A_b_Ab_mR(A,b,Ab);
 p_mR(Ab,S7,P2,C6);
 stop();
 clrscrn();
 printf(" The Gauss Jordan process will reduce this matrix to : \n");
 gj_TP_mR(Ab);
 p_mR(Ab,S7,P2,C6);
 printf("\n The coefficients a, b, c of the curve are : \n\n");
 p_eq_poly_mR(Ab);
 stop();
 clrscrn();
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Verify the result : \n\n");
 verify_X_mR(Ab,XY[R1][C1]);
 verify_X_mR(Ab,XY[R2][C1]);
 verify_X_mR(Ab,XY[R3][C1]);
 verify_X_mR(Ab,XY[R4][C1]);
 printf("\n\n\n");
 stop();
 f_mR(XY);
 f_mR(A);
 f_mR(b);
 f_mR(Ab);
 return 0;
/* ------------------------------------ */
 Exemple de sortie écran :
 Find the coefficients a, b, c of the curve 
 y = ax**3 + bx**2 + cx + d 
 that passes through the points. 
 x y 
 -5 -3 
 -2 +0 
 +2 +3 
 +3 -2 
 Using the given points, we obtain this matrix
 x**3 x**2 x**1 x**0 y
-125.00 +25.00 -5.00 +1.00 -3.00 
 -8.00 +4.00 -2.00 +1.00 +0.00 
 +8.00 +4.00 +2.00 +1.00 +3.00 
 +27.00 +9.00 +3.00 +1.00 -2.00 
 Press return to continue. 
 The Gauss Jordan process will reduce this matrix to : 
 +1.00 +0.00 +0.00 +0.00 -0.14 
 +0.00 +1.00 +0.00 +0.00 -0.73 
 +0.00 +0.00 +1.00 +0.00 +1.31 
 +0.00 +0.00 +0.00 +1.00 +4.43 
 The coefficients a, b, c of the curve are : 
 y = -0.139x**3 -0.732x**2 +1.307x +4.429
 Press return to continue. 
 x y 
 -5 -3 
 -2 +0 
 +2 +3 
 +3 -2 
 Verify the result : 
 With x = -5.000, y = -3.000 
 With x = -2.000, y = +0.000 
 With x = +2.000, y = +3.000 
 With x = +3.000, y = -2.000 
 Press return to continue.