Mathc matrices/c26b5
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* ------------------------------------ */
/* Save as : c02.c */
int main(void)
double xy[8] ={
 1, 1,
 2, 4,
 3, 9,
 4, 16 };
double **XY = ca_A_mR(xy,i_mR(R4,C2));
double **A = i_mR(R5,C5);
double **b = i_mR(R5,C1);
double **Ab = i_Abr_Ac_bc_mR(R5,C5,C1);
 clrscrn();
 printf("\n");
 printf(" Find the coefficients a, b, c, d, e, of the curve \n\n");
 printf(" ax**2 + by**2 + cx + dy + e = 0 \n\n");
 printf(" that passes through these four points. \n\n");
 printf(" x y");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Using the given points, we obtain this matrix.\n");
 printf(" (a = 1. This is my choice)\n\n");
 printf(" x**2 y**2 x y ");
 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(" The coefficients a, b, c, d, e, of the curve are : \n\n");
 p_eq_conica_mR(Ab);
 stop();
 clrscrn();
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Verify the result : \n\n");
 verify_XY_mR(Ab,XY[R1][C1],XY[R1][C2]);
 verify_XY_mR(Ab,XY[R2][C1],XY[R2][C2]);
 verify_XY_mR(Ab,XY[R3][C1],XY[R3][C2]);
 verify_XY_mR(Ab,XY[R4][C1],XY[R4][C2]);
 printf("\n\n\n");
 stop();
 f_mR(XY);
 f_mR(A);
 f_mR(b);
 f_mR(Ab);
 return 0;
/* ------------------------------------ */
 Le même problème résolue avec la méthode des Méthode des moindres carrés
 Exemple de sortie écran :
 Find the coefficients a, b, c, d, e, of the curve 
 ax**2 + by**2 + cx + dy + e = 0 
 that passes through these four points. 
 x y
 +1 +1 
 +2 +4 
 +3 +9 
 +4 +16 
 Using the given points, we obtain this matrix.
 (a = 1. This is my choice)
 x**2 y**2 x y 
 +1.00 +0.00 +0.00 +0.00 +0.00 +1.00 
 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 
 +4.00 +16.00 +2.00 +4.00 +1.00 +0.00 
 +9.00 +81.00 +3.00 +9.00 +1.00 +0.00 
 +16.00 +256.00 +4.00 +16.00 +1.00 +0.00 
 Press return to continue. 
 The Gauss Jordan process will reduce this matrix to : 
 +1.00 +0.00 +0.00 +0.00 +0.00 +1.00 
 +0.00 +1.00 +0.00 +0.00 +0.00 +0.00 
 +0.00 +0.00 +1.00 +0.00 +0.00 +0.00 
 -0.00 -0.00 +0.00 +1.00 +0.00 -1.00 
 +0.00 +0.00 +0.00 +0.00 +1.00 +0.00 
 The coefficients a, b, c, d, e, of the curve are : 
 +1.00x**2 -1.00y = 0 
 Press return to continue. 
 x y 
 +1 +1 
 +2 +4 
 +3 +9 
 +4 +16 
 Verify the result : 
 With x = +1.0 and y = +1.0 ax**2 + by**2 + cx+ dy + e = +0.00000 
 With x = +2.0 and y = +4.0 ax**2 + by**2 + cx+ dy + e = +0.00000 
 With x = +3.0 and y = +9.0 ax**2 + by**2 + cx+ dy + e = +0.00000 
 With x = +4.0 and y = +16.0 ax**2 + by**2 + cx+ dy + e = +0.00000 
 Press return to continue.

Mathc matrices/26c
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 a, b, c, d d'un cercle,
 ax**2 + ay**2 + bx + cy + d = 0 
 Qui passe par ces trois points. 
 (x[1],y[1]) (x[2],y[2]) (x[3],y[3]) 
 En utilisant ces trois points nous avons cette matrice.
 (a)x**2 (a)y**2 (b)x (c)y (d) = 0 
 x[1]**2 y[1]**2 x[1] y[1] 1 0
 x[2]**2 y[2]**2 x[2] y[2] 1 0
 x[3]**2 y[3]**2 x[3] y[3] 1 0
 Ce système a trois lignes et quatre inconnues.
 Il est homogène, donc il a une infinité de solution.
 Pour trouver une solution j'ai choisi que a = 1.
 Nous obtenons cette matrice.
 (a)x**2 (a)y**2
 1 0 0 0 0 1 
 0 1 0 0 0 1 
 x[1]**2 y[1]**2 x[1] y[1] 1 0 
 x[2]**2 y[2]**2 x[2] y[2] 1 0 
 x[3]**2 y[3]**2 x[3] y[3] 1 0 
 Il suffit de resoudre le système.
Deux exemples :

Mathc matrices/h26c
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 rXY;
int r;
int c;
 c_s_mR(1.,A,R1,C1);
 c_s_mR(1.,A,R2,C2);
 for(r=R3,rXY=R1; r<A[R_SIZE][C0]; r++,rXY++)
 c=C1; A[r][c]=pow(XY[rXY][C1],2); /* x**2 */
 c++; A[r][c]=pow(XY[rXY][C2],2); /* y**2 */
 c++; A[r][c]= XY[rXY][C1]; /* x */
 c++; A[r][c]= XY[rXY][C2]; /* y */
 c++; A[r][c]= 1.; /* c */
 c_s_mR(1.,b,R1,C1);
 c_s_mR(1.,b,R2,C1);
/* --------------------------------- */
void p_eq_circle_mR(
double **Ab
int cL = csize_R(Ab);
int r = R1;
 if((Ab[r][cL]))printf(" %+.2fx**2 " ,Ab[r][cL]);
 r++;if((Ab[r][cL]))printf(" %+.2fy**2 " ,Ab[r][cL]);
 r++;if((Ab[r][cL]))printf(" %+.2fx " ,Ab[r][cL]);
 r++;if((Ab[r][cL]))printf(" %+.2fy " ,Ab[r][cL]);
 r++;if((Ab[r][cL]))printf(" %+.2f = 0\n\n\n",Ab[r][cL]);
 else printf(" = 0\n\n\n");
/* --------------------------------- */
void verify_XY_mR(
double **Ab,
double x,
double y
int cL = csize_R(Ab);
double p = 0.;
int r = R1;
 p+= Ab[r][cL]*pow(x,2);
 r++;p+= Ab[r][cL]*pow(y,2);
 r++;p+= Ab[r][cL]* x ;
 r++;p+= Ab[r][cL]* y ;
 r++;p+= Ab[r][cL] ;
 printf(" With x = %+5.1f, y = %+5.1f ",x,y);
 printf(" p = ax**2 + ay**2 + cx+ dy + e = %+5.5f\n",p);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc matrices/c26c1
Application ou Résoudre avec ...
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : c01.c */
int main(void)
double xy[6] ={
 1, -2,
 2, -3,
 3, 6 };
double **XY = ca_A_mR(xy,i_mR(R3,C2));
double **A = i_mR(R5,C5);
double **b = i_mR(R5,C1);
double **Ab = i_Abr_Ac_bc_mR(R5,C5,C1);
 clrscrn();
 printf("\n");
 printf(" Find the coefficients a, b, c, d, of a circle \n\n");
 printf(" ax**2 + ay**2 + bx + cy + d = 0 \n\n");
 printf(" that passes through these three XY. \n\n");
 printf(" x y");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Using the given XY, we obtain this matrix.\n");
 printf(" (a = 1. This is my choice)\n\n");
 printf(" x**2 y**2 x y ");
 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(" The coefficients a, b, c, d, e, of the curve are : \n\n");
 p_eq_circle_mR(Ab);
 stop();
 clrscrn();
 printf(" x y \n");
 p_mR(XY,S5,P0,C6);
 printf("\n");
 printf(" Verify the result : \n\n");
 verify_XY_mR(Ab,XY[R1][C1],XY[R1][C2]);
 verify_XY_mR(Ab,XY[R2][C1],XY[R2][C2]);
 verify_XY_mR(Ab,XY[R3][C1],XY[R3][C2]);
 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, d, of a circle 
 ax**2 + ay**2 + bx + cy + d = 0 
 that passes through these three points. 
 x y
 +1 -2 
 +2 -3 
 +3 +6 
 Using the given points, we obtain this matrix.
 (a = 1. This is my choice)
 x**2 y**2 x y 
 +1.00 +0.00 +0.00 +0.00 +0.00 +1.00 
 +0.00 +1.00 +0.00 +0.00 +0.00 +1.00 
 +1.00 +4.00 +1.00 -2.00 +1.00 +0.00 
 +4.00 +9.00 +2.00 -3.00 +1.00 +0.00 
 +9.00 +36.00 +3.00 +6.00 +1.00 +0.00 
 Press return to continue. 
 The Gauss Jordan process will reduce this matrix to : 
 +1.00 +0.00 +0.00 +0.00 +0.00 +1.00 
 +0.00 +1.00 +0.00 +0.00 +0.00 +1.00 
 -0.00 -0.00 +1.00 -0.00 -0.00 -10.40 
 +0.00 +0.00 +0.00 +1.00 +0.00 -2.40 
 +0.00 +0.00 +0.00 +0.00 +1.00 +0.60 
 The coefficients a, b, c, d, e, of the curve are : 
 +1.00x**2 +1.00y**2 -10.40x -2.40y +0.60 = 0
 Press return to continue. 
 x y 
 +1 -2 
 +2 -3 
 +3 +6 
 Verify the result : 
 With x = +1.0 and y = -2.0 ax**2 + ay**2 + cx+ dy + e = +0.00000 
 With x = +2.0 and y = -3.0 ax**2 + ay**2 + cx+ dy + e = +0.00000 
 With x = +3.0 and y = +6.0 ax**2 + ay**2 + cx+ dy + e = -0.00000 
 Press return to continue.