Aller au contenu

Mathc matrices/a77

Un livre de Wikilivres.


Série de Taylor


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


c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA        RC4
/* ------------------------------------ */
void fun(void)
{
int n = 10; 
int i =  0; 

double **A   = rE_mR(i_mR(RCA,RCA),999,+1.E-3); 
double **A_n =       i_mR(RCA,RCA);
double **sA  =       i_mR(RCA,RCA);

double **ExpA      = i_mR(RCA,RCA);   
double **NewExpA   = i_mR(RCA,RCA);   
       
   clrscrn();   
   printf(" Copy/Past into the octave window.       \n\n");
   p_Octave_mR(A, "A", P3);
   printf(" expm (A)\n\n\n");
  
   for(i = 0; i <= n; i++)
    {
     pow_mR(i, A, A_n);    
    smul_mR(1./factorial(i), A_n, sA);    
     add_mR(ExpA,sA,NewExpA);        
       c_mR(NewExpA,ExpA);
    }
    
  printf(" ExpA :");
  p_mR(ExpA,S8,P6,C6);

  f_mR(A);
  f_mR(A_n);
  f_mR(sA);
  f_mR(ExpA);
  f_mR(NewExpA);  
}
/* ------------------------------------ */
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)

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

 A=[
-0.275,+0.505,-0.220,+0.732;
+0.893,-0.871,-0.249,-0.251;
+0.803,+0.152,-0.659,-0.776;
-0.689,+0.150,-0.932,+0.664]

 expm (A)


 ExpA :
+0.469595 +0.281641 -0.498660 +0.989235 
+0.473987 +0.521426 -0.182876 +0.115416 
+0.815081 +0.198096 +0.657846 -0.544365 
-1.216594 -0.106370 -0.910987 +1.927402 


 Press return to continue
 Press X      to stop