Linear Algebra and the C Language/a09b


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00b.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
#define   RB R3
#define   CB C2

#define   RU R2
#define   CU C1
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double bu_s[RB*(CB+CU)]={
    +2,  2,      6,
    +2,  0,     14,
    +6,  2,     34, 
};

double **Bu_s = ca_A_mR(bu_s,i_Abr_Ac_bc_mR(RB,CB,CU));
double **B    = c_Ab_A_mR(Bu_s,i_mR(RB,CB));
double **U_s  = c_Ab_b_mR(Bu_s,i_mR(RB,CU));

  clrscrn();
  printf(" B is the change of basis matrix for \"B\" \n\n"
         " Find the coordinate of U in the \"B\" basis.\n\n"
         " B :   ");
  p_mR(B,S6,P2,C7);
  printf( " U_s :   The coordinate of U in the Standard basis");
  p_mR(U_s,S6,P2,C7);
  stop();
  
  clrscrn();
  printf("  B:   ");
  p_mR(B,S6,P2,C7);
  printf( " U_s:");
  p_mR(U_s,S6,P2,C7);
  printf("The system B|u_s:");
  p_mR(Bu_s,S6,P2,C7);
  printf(" B|u_s :             gj_PP_mR(Ab,YES):");
  gj_PP_mR(Bu_s,YES);
  p_mR(Bu_s,S6,P2,C7);
  stop();
  
  clrscrn();
  printf(" B|u_s :");
  p_mR(Bu_s,S6,P2,C7);
  printf( " U_s :   The coordinate of U in the Standard basis");
  p_mR(U_s,S6,P2,C7);
  printf(" U_b :   The coordinate of U in the \"B\" basis\n"
         "  %+.2f\n  %+.2f\n\n", Bu_s[R1][C3],Bu_s[R2][C3]);
  stop();
   
  f_mR(Bu_s);
  f_mR(U_s);
  f_mR(B);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Find the coordinates of U in basis B: 

You must create the system and resolve it:

             You have:      B U_b = U_s
  You can introduce X:      B  X  = U_s
 
 To find X you must resolve the system B|U_s = X = U_b  

Screen output example:

 B is the change of basis matrix for "B" 

 Find the coordinate of U in the "B" basis.

 B :   
 +2.00  +2.00 
 +2.00  +0.00 
 +6.00  +2.00 

 U_s :   The coordinate of U in the Standard basis
 +6.00 
+14.00 
+34.00 

 Press return to continue. 


  B:   
 +2.00  +2.00 
 +2.00  +0.00 
 +6.00  +2.00 

 U_s:
 +6.00 
+14.00 
+34.00 

The system B|u_s:
 +2.00  +2.00  +6.00 
 +2.00  +0.00 +14.00 
 +6.00  +2.00 +34.00 

 B|u_s :             gj_PP_mR(Ab,YES):
 +1.00  +0.00  +7.00 
 +0.00  +1.00  -4.00 
 +0.00  +0.00  +0.00 

 Press return to continue. 


 B|u_s :
 +1.00  +0.00  +7.00 
 +0.00  +1.00  -4.00 
 +0.00  +0.00  +0.00 

 U_s :   The coordinate of U in the Standard basis
 +6.00 
+14.00 
+34.00 

 U_b :   The coordinate of U in the "B" basis
  +7.00
  -4.00

 Press return to continue.