Mathc complexes/a130

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"
/* ------------------------------------ */
#define   RCA        RC4
/* ------------------------------------ */
void fun(void)
{
int n = 10; 
int i =  0; 

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

double **ExpA      = i_mZ(RCA,RCA);   
double **NewExpA   = i_mZ(RCA,RCA);   
       
   clrscrn();   
   printf(" Copy/Past into the octave window.       \n\n");
   p_Octave_mZ(A, "A", P3, P3);
   printf(" expm (A)\n\n");
   stop();  
   
   clrscrn();    
   printf(" A :");
   p_mZ(A,S4,P4,S8,P6,C6);
  
  for(i = 0; i <= n; i++)
   {
     pow_mZ(i, A, A_n);    
    smul_mZ(1./factorial(i), A_n, sA);    
     add_mZ(ExpA,sA,NewExpA);
     
     printf(" NewExpA   n = %d :",i);
     p_mZ(NewExpA,S8,P6,S8,P6,C6);       
     c_mZ(NewExpA,ExpA);
     stop();
   }

  clrscrn();    
  printf(" ExpA :");
  p_mZ(ExpA,S8,P6,S8,P6,C6);

  f_mZ(A);
  f_mZ(A_n);
  f_mZ(sA);
  f_mZ(ExpA);
  f_mZ(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.517-0.056*i,+0.243+0.401*i,+0.138+0.308*i,-0.852-0.852*i;
-0.237-0.979*i,-0.476+0.812*i,-0.873-0.975*i,+0.938+0.887*i;
-0.125-0.106*i,+0.153-0.682*i,+0.349+0.618*i,-0.045-0.753*i;
+0.226+0.907*i,-0.081-0.716*i,+0.414+0.571*i,+0.074-0.525*i]

 expm (A)

 Press return to continue. 


 ------------------------------------
 A :
+0.5170-0.056000i +0.2430+0.401000i +0.1380+0.308000i -0.8520-0.852000i 
-0.2370-0.979000i -0.4760+0.812000i -0.8730-0.975000i +0.9380+0.887000i 
-0.1250-0.106000i +0.1530-0.682000i +0.3490+0.618000i -0.0450-0.753000i 
+0.2260+0.907000i -0.0810-0.716000i +0.4140+0.571000i +0.0740-0.525000i 

 NewExpA   n = 0 :
+1.000000+0.000000i +0.000000+0.000000i +0.000000+0.000000i +0.000000+0.000000i 
+0.000000+0.000000i +1.000000+0.000000i +0.000000+0.000000i +0.000000+0.000000i 
+0.000000+0.000000i +0.000000+0.000000i +1.000000+0.000000i +0.000000+0.000000i 
+0.000000+0.000000i +0.000000+0.000000i +0.000000+0.000000i +1.000000+0.000000i 

 Press return to continue. 
 NewExpA   n = 1 :
+1.517000-0.056000i +0.243000+0.401000i +0.138000+0.308000i -0.852000-0.852000i 
-0.237000-0.979000i +0.524000+0.812000i -0.873000-0.975000i +0.938000+0.887000i 
-0.125000-0.106000i +0.153000-0.682000i +1.349000+0.618000i -0.045000-0.753000i 
+0.226000+0.907000i -0.081000-0.716000i +0.414000+0.571000i +1.074000-0.525000i 

 ...


 ------------------------------------
 ExpA :
+2.119712-1.154057i +0.042849+0.812418i +0.552870-0.393331i -2.067558-0.359511i 
-0.669493-0.490951i +0.608939+0.227871i -0.456034-0.964534i +0.454646+1.477771i 
-0.001853-0.283301i +0.293496-0.519407i +1.088740+0.767773i +0.306629-0.947963i 
+0.798707+1.282303i -0.148751-0.501495i +0.256848+1.118903i +1.580383-1.818201i 


 Press return to continue
 Press X      to stop