Aller au contenu

Mathc complexes/064

Un livre de Wikilivres.


Application

Installer et compiler ces fichiers dans votre répertoire de travail.

c00b.c
/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "w_a.h" 
#include    "d.h"
/* --------------------------------- */
int main(void)
{
double   xy[6] ={1, -9,
                 2,  8,
                 3, -8,   };

double **XY = ca_A_mRZ(xy,i_mZ(R3,C2));
double **A  =             i_mZ(R3,C3);
double **b =              i_mZ(R3,C1);
double **Ab =   i_Abr_Ac_bc_mZ(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_mRZ(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_mZ(XY,A,b);
  c_A_b_Ab_mZ(A,b,Ab);
  p_mRZ(Ab,S7,P2,C6);
  stop();

  clrscrn();
  printf(" The Gauss Jordan process will reduce this matrix to : \n");
  gj_mZ(Ab);
  p_mRZ(Ab,S7,P2,C6);
  printf("\n The coefficients a, b, c of the curve are :  \n\n");
  p_eq_poly_mZ(Ab);
  stop();

  clrscrn();
  printf("    x     y \n");
  p_mRZ(XY,S5,P0,C6);
  printf("\n");

  printf(" Verify the result : \n\n");
  verify_X_mZ(Ab,XY[R1][C1]);
  verify_X_mZ(Ab,XY[R2][C1]);
  verify_X_mZ(Ab,XY[R3][C1]);
  printf("\n\n\n");
  stop();

  f_mZ(XY);
  f_mZ(A);
  f_mZ(b);
  f_mZ(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.