Aller au contenu

Mathc complexes/07h

Un livre de Wikilivres.


Application

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

c00c.c
/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RA  R4
#define   CA  C4
#define   Cb  C1 
#define   CXY C2
/* ------------------------------------ */
int main(void)
{
double ta[RA*CA]={
/* x**3    x**2     x**1   x**0  */
 -125,    +25,     -5,     +1,      
   -8,     +4,     -2,     +1,        
   +8,     +4,     +2,     +1,        
  +27,     +9,     +3,     +1,    
};

double tb[RA*C1]={
/*     y  */
   -3.00 ,
   +0.00,
   +3.00,
   -2.00,
};

double xy[RA*CXY] ={  -5,      -3,
                      -2,       0,
                       2,       3,
                       3,      -2     };
                    
double **XY   = ca_A_mRZ(xy,i_mZ(RA,CXY));
double **A    = ca_A_mRZ(ta,i_mZ(RA,CA));
double **b    = ca_A_mRZ(tb,i_mZ(RA,C1));
double **Inv  =             i_mZ(CA,RA);          
double **Invb =             i_mZ(CA,C1);         

  clrscrn();
  printf(" Fitting a linear Curve to Data :\n\n");
  printf("    x     y \n");
  p_mRZ(XY,S5,P0,C6);
  printf(" A :\n x**3     x**2     x**1    x**0");
  p_mRZ(A,S7,P2,C7);
  printf(" b :\n   y ");
  p_mRZ(b,S7,P2,C7);
  stop();
  
  clrscrn(); 
  printf(" Inv : ");
  invgj_mZ(A,Inv); 
  pE_mRZ(Inv,S12,P4,C10);    
  
  printf(" x = Inv * b ");   
  mul_mZ(Inv,b,Invb); 
  p_mRZ(Invb,S10,P2,C10);
  printf("\n The coefficients a, b, c of the curve are :  \n\n" 
         " y = %+.2fx**3 %+.2fx**2  %+.2fx %+.2f\n\n"
            ,Invb[R1][C1],Invb[R2][C1],Invb[R3][C1],Invb[R4][C1]);         
  stop();  

  f_mZ(XY);
  f_mZ(b);     
  f_mZ(A); 
  f_mZ(Inv);
  f_mZ(Invb); 

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
 Fitting a linear Curve to Data :

    x     y 

   -5    -3 
   -2    +0 
   +2    +3 
   +3    -2 

 A :
 x**3     x**2     x**1    x**0
-125.00  +25.00   -5.00   +1.00 
  -8.00   +4.00   -2.00   +1.00 
  +8.00   +4.00   +2.00   +1.00 
 +27.00   +9.00   +3.00   +1.00 

 b :
   y 
  -3.00 
  +0.00 
  +3.00 
  -2.00 

 Press return to continue. 


 Inv : 
 -5.9524e-03  +1.6667e-02  -3.5714e-02  +2.5000e-02 
 +1.7857e-02  +0.0000e+00  -1.4286e-01  +1.2500e-01 
 +2.3810e-02  -3.1667e-01  +3.9286e-01  -1.0000e-01 
 -7.1429e-02  +5.0000e-01  +1.0714e+00  -5.0000e-01 

 x = Inv * b 
     -0.14 
     -0.73 
     +1.31 
     +4.43 


 The coefficients a, b, c of the curve are :  

 y = -0.14x**3 -0.73x**2  +1.31x +4.43

 Press return to continue.