Linear Algebra with Sage

<Matrix Representation>

Made by SKKU Linear Algebra Lab (2011)

Declare a variables and define a linear transformation. (변수 선언과 선형변환 정의)

 var('x,y,z,w') T(x,y,z,w)=(x+2*y, x-3*z+w, 2*y+3*z+4*w);T
(x, y, z, w) |--> (x + 2*y, w+ x - 3*z, 4*w + 2*y + 3*z)

$\{\textbf{e}_{1}$, $\textbf{e}_{2}$, $\textbf{e}_{3}$, $\textbf{e}_{4} \}$: standard ordered basis (표준 기저)

 e1=matrix(4,1,[1,0,0,0]) e2=matrix(4,1,[0,1,0,0]) e3=matrix(4,1,[0,0,1,0]) e4=matrix(4,1,[0,0,0,1])

Define a matrix $T(\textbf{e}_{i})$.

( $T(a$, $b$, $c$, $d) [ i ]$: ($i+1$)-th component of $T(a$, $b$, $c$, $d)$)

 M=matrix(3,1,[T(1,0,0,0)[0], T(1,0,0,0)[1], T(1,0,0,0)[2]]); M1=matrix(3,1,[T(0,1,0,0)[0], T(0,1,0,0)[1], T(0,1,0,0)[2]]); M2=matrix(3,1,[T(0,0,1,0)[0], T(0,0,1,0)[1], T(0,0,1,0)[2]]); M3=matrix(3,1,[T(0,0,0,1)[0], T(0,0,0,1)[1], T(0,0,0,1)[2]]); M, M1, M2, M3
(
[1]   [2]   [ 0]   [0]
[1]   [0]   [-3]   [1]
[0],  [2],  [ 3],  [4]
)

Find the Matrix Representation of $T$  (선형변환 $T$의 행렬표현 구하기)

(associated matrix, $[[T(\textbf{e}_{1})]:[T(\textbf{e}_{2})]:[T(\textbf{e}_{3})]:[T(\textbf{e}_{4})]]$)

 M=M.augment(M1)   # 3 by 2 행렬 M=M.augment(M2)  # 3 by 3 행렬 M=M.augment(M3); # 3 by 4 행렬 M
[ 1  2  0  0 ]
[ 1  0 -3  1 ]
[ 0  2  3  4 ]

Check the result   ($T \textbf{x}=M \textbf{x}$임을 확인)

 X=matrix(4,1,[x,y,z,w]) M*X
[         x + 2*y         ]
[   w + x           - 3*z]
[4*w +      2*y  + 3*z]

Find the Matrix Representation $[T]_{\alpha}^{\beta}$ with respected to standard ordered bases $\alpha$ and ordered bases $\beta = \{ \textbf{v}_1$, $\textbf{v}_2$, $\textbf{v}_3 \}$, where $\textbf{v}_1$, $\textbf{v}_2$, $\textbf{v}_3$ are as follows.

Define vectors. (벡터 생성)

 v1=matrix(3,1,[1,1,0]) v2=matrix(3,1,[0,1,1]) v3=matrix(3,1,[1,0,1])

Declare variables. (변수 선언)

 var('a,b,c')

To find matrix representation $[T( \textbf{e}_i ) ]_{\alpha}^{\beta}$,

we have to solve the LSE $T( \textbf{e}_i )=a_i \textbf{v}_1 + b_i \textbf{v}_2 + c_i \textbf{v}_3$.

To find $[T( \textbf{e}_1 ) ]_{\alpha}^{\beta}$

Make equations (eq$i$ is $i$-th component of $T( \textbf{e}_1 )-(a_1 \textbf{v}_1 + b_1 \textbf{v}_2 + c_1 \textbf{v}_3)$)

 eq1=(M*e1-(a*v1+b*v2+c*v3))[0,0] eq2=(M*e1-(a*v1+b*v2+c*v3))[1,0] eq3=(M*e1-(a*v1+b*v2+c*v3))[2,0] eq1, eq2, eq3
(-1-c+1, -a-b+1, -b-c)

Solve the LSE. (연립 방정식 풀기)

 solve([eq1==0, eq2==0, eq3==0], a,b,c)
[[a==1, b==0, c==0]]

$MM=[[T(\textbf{e}_1)]_{\alpha}^{\beta}]$

 MM=matrix(QQ,3,1,[1,0,0]); MM
[1]
[0]
[0]

To find $[T( \textbf{e}_2 ) ]_{\alpha}^{\beta}$

Make equations (eq$i$ is $i$-th component of $T( \textbf{e}_2 )-(a_2 \textbf{v}_1 + b_2 \textbf{v}_2 + c_2 \textbf{v}_3)$)

 eq1=(M*e2-(a*v1+b*v2+c*v3))[0,0] eq2=(M*e2-(a*v1+b*v2+c*v3))[1,0] eq3=(M*e2-(a*v1+b*v2+c*v3))[2,0] eq1, eq2, eq3
(-a-c+2, -a-b, -b-c+2)

Solve the LSE. (연립 방정식 풀기)

 solve([eq1==0, eq2==0, eq3==0], a,b,c)
[[a==0, b==0, c==2]]

$MM1=[[T(\textbf{e}_2)]_{\alpha}^{\beta}]$

 MM1=matrix(3,1,[0,0,2]); MM1
[0]
[0]
[
2]

To find $[T( \textbf{e}_3 ) ]_{\alpha}^{\beta}$

Make equations (eq$i$ is $i$-th component of $T( \textbf{e}_3 )-(a_3 \textbf{v}_1 + b_3 \textbf{v}_2 + c_3 \textbf{v}_3)$

 eq1=(M*e3-(a*v1+b*v2+c*v3))[0,0] eq2=(M*e3-(a*v1+b*v2+c*v3))[1,0] eq3=(M*e3-(a*v1+b*v2+c*v3))[2,0] eq1, eq2, eq3
(-a-c, -a-b-3, -b-c+3)

Solve the LSE. (연립 방정식 풀기)

 solve([eq1==0, eq2==0, eq3==0], a,b,c)
[[a==-3, b==0, c==3]]

$MM2=[[T(\textbf{e}_3)]_{\alpha}^{\beta}]$

 MM2=matrix(3,1,[-3,0,3]); MM2
[-3]
[0]
[
3]

To find $[T( \textbf{e}_4 ) ]_{\alpha}^{\beta}$

Make equations (eq$i$ is $i$-th component of $T( \textbf{e}_4 )-(a_4 \textbf{v}_1 + b_4 \textbf{v}_2 + c_4 \textbf{v}_3)$

 eq1=(M*e4-(a*v1+b*v2+c*v3))[0,0] eq2=(M*e4-(a*v1+b*v2+c*v3))[1,0] eq3=(M*e4-(a*v1+b*v2+c*v3))[2,0] eq1, eq2, eq3
(-a-c, -a-b+1, -b-c+4)

Solve the LSE. (연립 방정식 풀기)

 solve([eq1==0, eq2==0, eq3==0], a,b,c)
[[a==(-3/2), b==(5/2), c==(3/2)]]

$MM3=[[T(\textbf{e}_4)]_{\alpha}^{\beta}]$

 MM3=matrix(3,1,[(-3/2),(5/2),(3/2)]); MM3
[-3/2]
[
5/2]
[
3/2]

<Final> Augment each vector $MMi$ to $MM$ successively to make a associated matrix.

(선형변환 $T$의 행렬표현 구하기)

(Matrix Representation of $T=[[T(\textbf{e}_{1})]:[T(\textbf{e}_{2})]:[T(\textbf{e}_{3})]:[T(\textbf{e}_{4})]]=[MM:MM1:MM2:MM3]$)

 MM=MM.augment(MM1) MM=MM.augment(MM2) MM=MM.augment(MM3); MM
[ 1  0  -3 -3/2 ]
[ 0  0   0  5/2 ]
[ 0  2   3  3/2 ]