Aller au contenu

Mathc matrices/a80

Un livre de Wikilivres.


Série de Taylor


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


c00d.c
/* ------------------------------------ */
/*  Save as :   c00d.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA        RC4
/* ------------------------------------ */
void fun(void)
{
double **A    =  i_mR(RCA,RCA) ; 
double **B    =  i_mR(RCA,RCA) ;
double **ExpA =  i_mR(RCA,RCA); 
double **ExpB =  i_mR(RCA,RCA);  

double **AplsB    = i_mR(RCA,RCA); 
double **ExpAplsB = i_mR(RCA,RCA);
        
   r_commute2_mR(A,B,9);
   add_mR(A,B,AplsB);
    
   clrscrn();   
   printf(" Copy/Past into the octave window.       \n\n");
   p_Octave_mR(A, "A", P12);
   printf(" expm (A)\n\n");
   
   p_Octave_mR(B, "B", P12);
   printf(" expm (B)\n\n");  
   stop();
   
   clrscrn();      
   p_Octave_mR(AplsB, "AplsB", P12);
   printf(" expm (AplsB)\n\n");
   
   printf(" expm (A)*expm (B)\n"); 
   printf(" expm (B)*expm (A)\n\n");   
   stop();
   
   clrscrn(); 
   Exp_mR(A, ExpA);
   Exp_mR(B, ExpB);
   Exp_mR(AplsB, ExpAplsB);
           
   printf(" ExpA :");
   p_mR(ExpA,S8,P6,C6);
   printf(" ExpB :");
   p_mR(ExpB,S8,P6,C6);
   stop();
   
   clrscrn();
   printf("  ExpAplsB=:");
   p_mR( ExpAplsB,S10,P6,C6);   
       
   printf(" ExpA * ExpB:");
   mul_mR(ExpA,ExpB,A);
   p_mR(A,S10,P6,C6); 

   printf(" ExpB * ExpA:");
   mul_mR(ExpB,ExpA,A);
   p_mR(A,S10,P6,C6); 
     
   f_mR(A);
   f_mR(ExpA);
   f_mR(B);
   f_mR(ExpB);
   f_mR(AplsB);
   f_mR(ExpAplsB);  
}    
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
    fun();
    
} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
      ExpA = Ide + A + (1/2) A**2 + (1/6) A**3 + ... + 1/(n-1)! A**(n-1)


 Dans cet exemple on vérifie une des propriétés de l'exponentielle     e^(a+b) = e^(a) e^(b) = e^(b) e^(a)
 

Exemple de sortie écran :
 ------------------------------------ 
 Copy/Past into the octave window.       

 A=[
+0.277,+1.072,+0.512,+0.144;
+0.118,+0.601,-0.109,-0.060;
-0.590,+1.227,+1.458,+0.255;
+0.493,-1.070,-0.549,+0.583]

 expm (A)

 B=[
-0.787,+1.109,-0.278,-0.510;
+0.337,-0.687,-0.785,-0.624;
-0.709,+1.197,+0.594,+0.669;
+0.318,-1.081,-0.241,-0.560]

 expm (B)

 Press return to continue. 


 ------------------------------------ 
 AplsB=[
-0.510,+2.181,+0.235,-0.366;
+0.455,-0.086,-0.893,-0.684;
-1.299,+2.424,+2.052,+0.924;
+0.811,-2.152,-0.790,+0.023]

 expm (AplsB)

 expm (A)*expm (B)
 expm (B)*expm (A)

 Press return to continue. 


 ------------------------------------ 
 ExpA :
+1.226483 +2.096233 +1.019268 +0.282423 
+0.213199 +1.878791 -0.198830 -0.119400 
-1.126863 +2.400553 +3.555163 +0.524578 
+0.934023 -2.091929 -1.101056 +1.783381 

 ExpB :
+0.614186 +0.599304 -0.571202 -0.611915 
+0.301209 +0.537695 -0.774294 -0.622448 
-0.448442 +0.609939 +1.431405 +0.553673 
+0.090545 -0.571959 +0.051631 +0.715039 

 Press return to continue. 


 ------------------------------------ 
  ExpAplsB=:
+0.953182 +2.322329 -0.850100 -1.289015 
+0.775205 +1.085006 -1.867286 -1.495372 
-1.515822 +2.483828 +3.900897 +1.538817 
+0.598793 -2.256653 -0.397727 +1.396136 

 ExpA * ExpB:
+0.953182 +2.322329 -0.850101 -1.289015 
+0.775205 +1.085006 -1.867287 -1.495372 
-1.515822 +2.483828 +3.900897 +1.538818 
+0.598793 -2.256653 -0.397727 +1.396136 

 ExpB * ExpA:
+0.953182 +2.322329 -0.850101 -1.289015 
+0.775205 +1.085006 -1.867287 -1.495372 
-1.515822 +2.483828 +3.900897 +1.538818 
+0.598793 -2.256653 -0.397727 +1.396136 


 Press return to continue
 Press X      to stop