Linear Algebra and the C Language/a0hq


The Maclaurin series of the exponential function is :

      Exp(A) = Ide + A + (1/2) A2 + (1/6) A3 + ... + 1/(n-1)! A(n-1)

Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RCA        RC4
/* ------------------------------------ */
void fun(void)
{
double **A    = rE_mR(i_mR(RCA,RCA),999,+1.E-3); 
double **ExpA =       i_mR(RCA,RCA);   
      
   clrscrn();   
   printf(" Copy/Paste into the octave window.\n");
   p_Octave_mR(A, "A", P4);
   printf(" expm (A)\n\n");
   
   Exp_mR(A,ExpA);
     
   printf(" ExpA:");
   p_mR(ExpA, S8,P4,C6);

   f_mR(A);
   f_mR(ExpA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

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

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */

Screen output example:

                                                                                       
 Copy/Paste into the octave window.
 A=[
-0.6060,-0.5590,+0.6880,-0.1010;
-0.9200,+0.8710,+0.5820,+0.4660;
-0.0840,+0.7260,-0.9740,-0.6660;
+0.2270,+0.2980,+0.7020,-0.4010]

 expm (A)

 ExpA:
 +0.7286  -0.6210  +0.1630  -0.2698 
 -1.3082  +3.1928  +0.5956  +0.6177 
 -0.3536  +0.8186  +0.3923  -0.1726 
 -0.0834  +0.6438  +0.4606  +0.6218 


 Press   return to continue
 Press X return to stop