Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168759
Image: ubuntu2004

This first block of code comes from the Linear Tranformation unit.  It is a reminder of how a linear transformation transforms the plane.  Most of the examples in this unit take the code below and modify it slightly to illustrate change of bases.

A=matrix(QQ, [[2,1], [0,3]]) EV=A.eigenvectors_right() e1=vector([1,0]) e2=vector([0,1]) c1,c2=A.columns() z=(0,0) boxplot=arrow(z,e1,color='red',aspect_ratio=1) boxplot+=arrow(z,e2,color='blue') boxplot+=arrow(e2,e2+e1,color='red',linestyle='dashed') boxplot+=arrow(e1,e1+e2,color='blue',linestyle='dashed') boxplot+=arrow(z,c1,color='red',aspect_ratio=1) boxplot+=arrow(z,c2,color='blue') boxplot+=arrow(c2,c2+c1,color='red',linestyle='dashed') boxplot+=arrow(c1,c1+c2,color='blue',linestyle='dashed') evplot=arrow(z,z) for i in range(len(EV)): for j in range( len( EV[i][1] ) ): if EV[i][0]==EV[i][0].conjugate(): evplot+=arrow(z,EV[i][0]*(EV[i][1][j])/EV[i][1][j].norm(),color='purple') evplot+=arrow(z,(EV[i][1][j])/EV[i][1][j].norm(),color='green') evplot+=arrow(z,-EV[i][0]*(EV[i][1][j])/EV[i][1][j].norm(),color='purple') evplot+=arrow(z,-(EV[i][1][j])/EV[i][1][j].norm(),color='green') var('t') r=vector([cos(t),sin(t)]) circleplot=parametric_plot(r,(t,0,2*pi)) circleplot+=parametric_plot(A*r,(t,0,2*pi)) r=1/3*vector([(1 - sin(t))*cos(t)+1.5, (1 - sin(t))*sin(t)+2.5]) heart=parametric_plot( r, (t, pi/2, 3*pi/2),color='black') heart+=parametric_plot( r, (t, -pi/2, pi/2),color='brown') heart+=parametric_plot( A*r, (t, pi/2, 3*pi/2),color='black') heart+=parametric_plot( A*r, (t, -pi/2, pi/2),color='brown') html.table([["Matrix",A],["Determinant",A.det()],["Eigenvalues and Eigenvectors","Under the table"],[ boxplot+heart,boxplot+evplot+circleplot ]]) EV
Matrix \left(2103\begin{array}{rr} 2 & 1 \\ 0 & 3 \end{array}\right)
Determinant 6
Eigenvalues and Eigenvectors Under the table
[(3, [ (1, 1) ], 1), (2, [ (1, 0) ], 1)]

The code below shows how a basis for R2\mathbb{R}^2 is really just a way of defining a new coordinate system (xyxy axes) in 2D. The coordinates of (a,b)(a,b) relative to this new system satisfy A[(a,b)]=(a,b)A [(a,b)] = (a,b), so the coordinates are [(a,b)]=A1(a,b)[(a,b)]=A^{-1}(a,b).

Basis=[[1,2],[2,-3]] A=matrix(QQ, Basis).transpose() e1=vector([1,0]) e2=vector([0,1]) c1,c2=A.columns() z=(0,0) boxplot=arrow(z,c1,color='red',aspect_ratio=1) boxplot+=arrow(z,c2,color='blue') for n in [-2,-1,0,1,2]: for m in [-2,-1,0,1,2]: boxplot+=arrow(m*c1+n*c2,m*c1+n*c2+c1,color='red',linestyle='dashed') boxplot+=arrow(m*c2+n*c1,m*c2+n*c1+c2,color='blue',linestyle='dashed') var('a,b') html.table([ ["Basis",Basis], ["Matrix",A], ["Inverse",A.inverse()], ["Determinant",A.det()], ["vector (a,b) has coordinates [(a,b)]_S = ",A.inverse()*vector([a,b])], [ boxplot ] ])
Basis \left[\left[1, 2\right], \left[2, -3\right]\right]
Matrix \left(1223\begin{array}{rr} 1 & 2 \\ 2 & -3 \end{array}\right)
Inverse \left(37272717\begin{array}{rr} \frac{3}{7} & \frac{2}{7} \\ \frac{2}{7} & -\frac{1}{7} \end{array}\right)
Determinant -7
vector (a,b) has coordinates [(a,b)]_S = \left(\frac{3}{7} \, a + \frac{2}{7} \, b,\frac{2}{7} \, a - \frac{1}{7} \, b\right)

The code below shows how a basis for R3\mathbb{R}^3 is really just a way of defining a new coordinate system (xyzxyz axes) in 3D. The coordinates of (a,b,c)(a,b,c) relative to this new system satisfy A[(a,b,c)]=(a,b,c)A [(a,b,c)] = (a,b,c), so the coordinates are [(a,b,c)]=A1(a,b,c)[(a,b,c)]=A^{-1}(a,b,c).

Basis=[[1,2,0],[2,-3,0],[0,-1,1]] A=matrix(QQ, Basis).transpose() e1=vector([1,0,0]) e2=vector([0,1,0]) e3=vector([0,0,1]) c1,c2,c3=A.columns() z=(0,0,0) boxplot=arrow3d(z,c1,color='red',aspect_ratio=1) boxplot+=arrow3d(z,c2,color='blue') boxplot+=arrow3d(z,c3,color='green') for n in [-1,0,1]: for m in [-1,0,1]: for p in [-1,0,1]: boxplot+=arrow3d(m*c1+n*c2+p*c3,m*c1+n*c2+p*c3+c1,color='red',linestyle='dashed') boxplot+=arrow3d(m*c2+n*c1+p*c3,m*c2+n*c1+p*c3+c2,color='blue',linestyle='dashed') boxplot+=arrow3d(m*c2+n*c1+p*c3,m*c2+n*c1+p*c3+c3,color='green',linestyle='dashed') var('a,b,c') html.table([ ["Basis",Basis], ["Matrix",A], ["Inverse",A.inverse()], ["Determinant",A.det()], ["vector (a,b,c) has coordinates [(a,b)]_S = ",A.inverse()*vector([a,b,c])] ]) boxplot
Basis \left[\left[1, 2, 0\right], \left[2, -3, 0\right], \left[0, -1, 1\right]\right]
Matrix \left(120231001\begin{array}{rrr} 1 & 2 & 0 \\ 2 & -3 & -1 \\ 0 & 0 & 1 \end{array}\right)
Inverse \left(372727271717001\begin{array}{rrr} \frac{3}{7} & \frac{2}{7} & \frac{2}{7} \\ \frac{2}{7} & -\frac{1}{7} & -\frac{1}{7} \\ 0 & 0 & 1 \end{array}\right)
Determinant -7
vector (a,b,c) has coordinates [(a,b)]_S = \left(\frac{3}{7} \, a + \frac{2}{7} \, b + \frac{2}{7} \, c,\frac{2}{7} \, a - \frac{1}{7} \, b - \frac{1}{7} \, c,c\right)

The following code illustrates how the exact same vector has different coordinates relative to different bases.  Remember that the vector always satisfies B[v]S=v.B[\vec v]_S=\vec v. So if SS and SS' are two different bases, with matrices BB and BB' formed by placing the basis vectors in columns, then B[v]S=B[v]S.B[\vec v]_S = B'[\vec v]_{S'}. We can then compute two change of bases matrices P[v]S=[v]SandQ[v]S=[v]SP[\vec v]_S = [\vec v]_{S'}\quad \text{and}\quad Q[\vec v]_{S'} = [\vec v]_{S} where P=B1BP = B'^{-1}B and Q=B1BQ = B^{-1} B'.

 

Basis1=[[1,2],[2,-3]] Basis2=[[1,0],[2,1]] v=vector([5,1]) A1=matrix(QQ, Basis1).transpose() A2=matrix(QQ, Basis2).transpose() e1=vector([1,0]) e2=vector([0,1]) b11,b12=A1.columns() b21,b22=A2.columns() z=(0,0) boxplot1=arrow(z,b11,color='red',aspect_ratio=1) boxplot1+=arrow(z,b12,color='blue') for n in [-2,-1,0,1,2]: for m in [-2,-1,0,1,2]: boxplot1+=arrow(m*b11+n*b12,m*b11+n*b12+b11,color='red',linestyle='dashed') boxplot1+=arrow(m*b12+n*b11,m*b12+n*b11+b12,color='blue',linestyle='dashed') boxplot1+=arrow(z,v,color='black') boxplot2=arrow(z,b21,color='red',aspect_ratio=1) boxplot2+=arrow(z,b22,color='blue') for n in [-2,-1,0,1,2]: for m in [-2,-1,0,1,2]: boxplot2+=arrow(m*b21+n*b22,m*b21+n*b22+b21,color='red',linestyle='dashed') boxplot2+=arrow(m*b22+n*b21,m*b22+n*b21+b22,color='blue',linestyle='dashed') boxplot2+=arrow(z,v,color='black') var('a,b') html.table([ ["Basis"],[Basis1,Basis2], ["Matrix"],[A1,A2], ["Inverse"],[A1.inverse(),A2.inverse()], ["Determinant"],[A1.det(),A2.det()], ["P = (B2)^{-1} B1 and Q = B1^{-1} B2"], [A2.inverse()*A1, A1.inverse()*A2], ["The coordinates of v relative to each basis",v],[A1.inverse()*v,A2.inverse()*v], [ boxplot1,boxplot2 ] ])
Basis
\left[\left[1, 2\right], \left[2, -3\right]\right] \left[\left[1, 0\right], \left[2, 1\right]\right]
Matrix
\left(1223\begin{array}{rr} 1 & 2 \\ 2 & -3 \end{array}\right) \left(1201\begin{array}{rr} 1 & 2 \\ 0 & 1 \end{array}\right)
Inverse
\left(37272717\begin{array}{rr} \frac{3}{7} & \frac{2}{7} \\ \frac{2}{7} & -\frac{1}{7} \end{array}\right) \left(1201\begin{array}{rr} 1 & -2 \\ 0 & 1 \end{array}\right)
Determinant
-7 1
P = (B2)^{-1} B1 and Q = B1^{-1} B2
\left(3823\begin{array}{rr} -3 & 8 \\ 2 & -3 \end{array}\right) \left(37872737\begin{array}{rr} \frac{3}{7} & \frac{8}{7} \\ \frac{2}{7} & \frac{3}{7} \end{array}\right)
The coordinates of v relative to each basis \left(5,1\right)
\left(\frac{17}{7},\frac{9}{7}\right) \left(3,1\right)

The words "change of basis matrix from SS to SS'" are used in two opposite ways in different places. The matrix PP in P[v]S=[v]SP[\vec v]_S = [\vec v]_{S'} can be call the change of basis matrix from SS to SS' or the change of basis matrix from SS' to SS (notice the reversal).  It depends on the context and the use the author wished to emphasize.

  1. If we start with coordinates [v]S[\vec v]_S relative to SS, then multiplying by PP on the left transforms these to coordinates [v]S[\vec v]_{S'} relative to SS'.  We say that PP is a change of basis matrix from SS to SS', as inputing coordinates relative to SS outputs coordinates relative to SS'. Think of multiplication by PP as a way to transform us from what we know SS to what we want SS'.
  2. If we start with coordinates [v]S[\vec v]_{S'} relative to SS', then replacing [v]S[\vec v]_{S'} with P[v]SP[\vec v]_{S} transform equations written relative to S{S'} into equations written relative to SS.  We then say that PP is a change of basis matrix from SS' to SS, as it transforms equation from SS' to SS.

The following code shows how to change equations from one coordinate system to another. In the example below, the set SS is the standard basis, whereas the set SS' is the standard basis rotated 45 degrees counterclockwise.  Here are some things to notice:

  • If you know the coordinates (u,v)(u,v) and want the coordinates (x,y)(x,y), then you compute B1B(u,v)B'^{-1}B(u,v).
  • To change the equation u24+v2=1\dfrac{u^2}{4}+v^2=1 to an equation in (x,y)(x,y) coordinates, you replace (u,v)(u,v) with B1B(x,y)B^{-1}B'(x,y). The change of basis matrix is different.

The xyxy axes are marked in red and blue.The uvuv axes are marked in orange and green. You can modify the xy basis, the uv basis, as well as any of the equations. If you need to adjust the viewing bounds to include more than [-3,3] in each window, feel free to adjust these.

var('x,y,u,v,a,b') xybasis = [[1,0],[0,1]] uvbasis = [[1/sqrt(2),1/sqrt(2)],[-1/sqrt(2),1/sqrt(2)]] uv_eqn = u^2/4+v^2/9==1 xy_eqn = y==sin(pi*x) B1 = matrix(xybasis).transpose() B2 = matrix(uvbasis).transpose() xycoordinates = B1.inverse()*vector([a,b]) uvcoordinates = B2.inverse()*vector([a,b]) P1 = B1.inverse()*B2 #Solve for [v]_S1 P2 = B2.inverse()*B1 #Solve for [v]_S2 uv_in_terms_of_xy = P2*vector([x,y]) xy_in_terms_of_uv = P1*vector([u,v]) uv_eqn_to_xy = uv_eqn.subs(u=uv_in_terms_of_xy[0],v=uv_in_terms_of_xy[1]) xy_eqn_to_uv = xy_eqn.subs(x=xy_in_terms_of_uv[0],y=xy_in_terms_of_uv[1]) html.table([ ["Basis", xybasis, uvbasis], ["Basis Matrix", B1, B2], ["Inverse", B1.inverse(), B2.inverse()], ["Coordinates of (a,b)", xycoordinates, uvcoordinates], ["(x,y) = some function of (u,v)",xy_in_terms_of_uv,vector([u,v])], ["(u,v) = some function of (x,y)",vector([x,y]),uv_in_terms_of_xy], ["Changing an equation from uv to xy", uv_eqn_to_xy, uv_eqn], ["Changing an equation from xy to uv", xy_eqn, xy_eqn_to_uv], ]) html.table([ [implicit_plot(uv_eqn_to_xy,(x,-3,3),(y,-3,3),aspect_ratio=1,axes_labels=["x - axis","y - axis"])+implicit_plot(xy_eqn,(x,-3,3),(y,-3,3))+arrow((-3*P1).column(0),(3*P1).column(0),color='orange')+arrow((-3*P1).column(1),(3*P1).column(1),color='green')+arrow([-3,0],[3,0],color='red')+arrow([0,-3],[0,3],color='blue') , implicit_plot(xy_eqn_to_uv,(u,-3,3),(v,-3,3),aspect_ratio=1,axes_labels=["u - axis","v - axis"])+implicit_plot(uv_eqn,(u,-3,3),(v,-3,3))+arrow((-3*P2).column(0),(3*P2).column(0),color='red')+arrow((-3*P2).column(1),(3*P2).column(1),color='blue')+arrow([-3,0],[3,0],color='orange')+arrow([0,-3],[0,3],color='green') ] ])
Basis \left[\left[1, 0\right], \left[0, 1\right]\right] \left[\left[\frac{1}{2} \, \sqrt{2}, \frac{1}{2} \, \sqrt{2}\right], \left[-\frac{1}{2} \, \sqrt{2}, \frac{1}{2} \, \sqrt{2}\right]\right]
Basis Matrix \left(1001\begin{array}{rr} 1 & 0 \\ 0 & 1 \end{array}\right) \left(122122122122\begin{array}{rr} \frac{1}{2} \, \sqrt{2} & -\frac{1}{2} \, \sqrt{2} \\ \frac{1}{2} \, \sqrt{2} & \frac{1}{2} \, \sqrt{2} \end{array}\right)
Inverse \left(1001\begin{array}{rr} 1 & 0 \\ 0 & 1 \end{array}\right) \left(122122122122\begin{array}{rr} \frac{1}{2} \, \sqrt{2} & \frac{1}{2} \, \sqrt{2} \\ -\frac{1}{2} \, \sqrt{2} & \frac{1}{2} \, \sqrt{2} \end{array}\right)
Coordinates of (a,b) \left(a,b\right) \left(\frac{1}{2} \, \sqrt{2} a + \frac{1}{2} \, \sqrt{2} b,-\frac{1}{2} \, \sqrt{2} a + \frac{1}{2} \, \sqrt{2} b\right)
(x,y) = some function of (u,v) \left(\frac{1}{2} \, \sqrt{2} u - \frac{1}{2} \, \sqrt{2} v,\frac{1}{2} \, \sqrt{2} u + \frac{1}{2} \, \sqrt{2} v\right) \left(u,v\right)
(u,v) = some function of (x,y) \left(x,y\right) \left(\frac{1}{2} \, \sqrt{2} x + \frac{1}{2} \, \sqrt{2} y,-\frac{1}{2} \, \sqrt{2} x + \frac{1}{2} \, \sqrt{2} y\right)
Changing an equation from uv to xy \frac{1}{36} \, {\left(\sqrt{2} x - \sqrt{2} y\right)}^{2} + \frac{1}{16} \, {\left(\sqrt{2} x + \sqrt{2} y\right)}^{2} = 1 \frac{1}{4} \, u^{2} + \frac{1}{9} \, v^{2} = 1
Changing an equation from xy to uv y = \sin\left(\pi x\right) \frac{1}{2} \, \sqrt{2} u + \frac{1}{2} \, \sqrt{2} v = \sin\left(\frac{1}{2} \, {\left(\sqrt{2} u - \sqrt{2} v\right)} \pi\right)

In the previous worksheet, we saw how a linear transformation tells us how to map the unit square to a parallelogram.  When you pick a different basis, the "unit square" is really a parallelogram whose edges are formed by the basis vectors.  This parallelogram representing the unit square is then mapped to the range and we have to find its coordinates relative to the new basis. In what follows below, we use the following color scheme:

  1. In the left picture, which represents the domain:
    • domain basis = {red, blue}
    • standard basis = {black,brown}
  2. In the right picture, which represents the range
    • image of domain basis vectors = {red, blue}
    • image of standard basis vectors = {black, brown} (which provides the columns of AA)
    • range basis vectors = {orange, green}

The columns of [T]S,S[T]_{S,S'} are precisely the coordinates of the images of the red and blue vectors relative to the orange and green vectors.

domain_basis=[[-1,1],[2,1]] range_basis=[[3,0],[0,2]] standard_matrix=matrix(QQ, [[2,1], [0,3]]) A=standard_matrix B1=matrix(QQ,domain_basis).transpose() B2=matrix(QQ,range_basis).transpose() e1=vector([1,0]) e2=vector([0,1]) c1,c2=A.columns() d1,d2=B1.columns() r1,r2=B2.columns() z=(0,0) boxplot1=arrow(z,e1,color='black',aspect_ratio=1) boxplot1+=arrow(z,e2,color='brown') boxplot1+=arrow(e2,e2+e1,color='black',linestyle='dashed') boxplot1+=arrow(e1,e1+e2,color='brown',linestyle='dashed') boxplot1+=arrow(z,d1,color='red',aspect_ratio=1) boxplot1+=arrow(z,d2,color='blue') boxplot1+=arrow(d2,d2+d1,color='red',linestyle='dashed') boxplot1+=arrow(d1,d1+d2,color='blue',linestyle='dashed') boxplot2=arrow(z,c1,color='black',aspect_ratio=1) boxplot2+=arrow(z,c2,color='brown') boxplot2+=arrow(c2,c2+c1,color='black',linestyle='dashed') boxplot2+=arrow(c1,c1+c2,color='brown',linestyle='dashed') boxplot2+=arrow(z,A*d1,color='red',aspect_ratio=1) boxplot2+=arrow(z,A*d2,color='blue') boxplot2+=arrow(A*d2,A*(d2+d1),color='red',linestyle='dashed') boxplot2+=arrow(A*d1,A*(d1+d2),color='blue',linestyle='dashed') for n in [-2,-1,0,1,2]: for m in [-2,-1,0,1,2]: boxplot2+=arrow(m*r1+n*r2,m*r1+n*r2+r1,color='orange',linestyle='dashed') boxplot2+=arrow(m*r2+n*r1,m*r2+n*r1+r2,color='green',linestyle='dashed') var('x,y,a,b') html.table([ ["$S$ - Basis for Domain",domain_basis], ["$S'$ - Basis for Range",range_basis], ["$B$ - matrix of domain basis vectors",B1], ["$B'$ - matrix of range basis vectors",B2], ["$B'^{-1}$", B2.inverse() ], ["$T(x,y)$ - The linear transformation ",A*vector([x,y])], ["$[T]_{E_2}$ - The standard matrix representation ",A], ["$[T]_{S,S'}$ - The matrix representation relative to $S$ and $S'$",B2.inverse()*A*B1], ["$[T(s,y)]_{S_'} = [T]_{S,S'}[(a,b)]_S$",B2.inverse()*A*vector([a,b])], [boxplot1,boxplot2], ])
S - Basis for Domain \left[\left[-1, 1\right], \left[2, 1\right]\right]
S' - Basis for Range \left[\left[3, 0\right], \left[0, 2\right]\right]
B - matrix of domain basis vectors \left(1211\begin{array}{rr} -1 & 2 \\ 1 & 1 \end{array}\right)
B' - matrix of range basis vectors \left(3002\begin{array}{rr} 3 & 0 \\ 0 & 2 \end{array}\right)
B'^{-1} \left(130012\begin{array}{rr} \frac{1}{3} & 0 \\ 0 & \frac{1}{2} \end{array}\right)
T(x,y) - The linear transformation \left(2 \, x + y,3 \, y\right)
[T]_{E_2} - The standard matrix representation \left(2103\begin{array}{rr} 2 & 1 \\ 0 & 3 \end{array}\right)
[T]_{S,S'} - The matrix representation relative to S and S' \left(13533232\begin{array}{rr} -\frac{1}{3} & \frac{5}{3} \\ \frac{3}{2} & \frac{3}{2} \end{array}\right)
[T(s,y)]_{S_'} = [T]_{S,S'}[(a,b)]_S \left(\frac{2}{3} \, a + \frac{1}{3} \, b,\frac{3}{2} \, b\right)

The code below repeats what was done above, but without drawing any pictures. This way you can work with the code for any linear transformation of the form T:RnRmT:\mathbb{R}^n\to \mathbb{R}^m. As long as your vector spaces are finite dimensional, then the code below will help you see how to create a matrix representation relative to any basis.

domain_basis=[[-1,1,0],[2,1,2],[3,-2,1]] range_basis=[[3,1],[-1,3]] var('a,b,c') v=vector([a,b,c]) #The vector you wish to transform - relative to a standard or 'usual' basis standard_matrix=matrix(QQ, [[2,1,0], [0,3,-2]]) A=standard_matrix B1=matrix(QQ,domain_basis).transpose() B2=matrix(QQ,range_basis).transpose() html.table([ ["$S$ - Basis for Domain",domain_basis], ["$S'$ - Basis for Range",range_basis], ["$B$ - matrix of domain basis vectors",B1], ["$B'$ - matrix of range basis vectors",B2], ["$B'^{-1}$", B2.inverse() ], ["$A=[T]$ - Standard matrix representation ",A], ["$[T]_{S,S'} = B'^{-1}AB$ - Matrix representation relative to $S$ and $S'$",B2.inverse()*A*B1], ["$v$ - standard coordinates",v], ["$[v]_S$ - coordinates relative to $S$",B1.inverse()*v], ["$T(v)$ - standard coordinates of $T(v)$",A*v], ["$[T(v)]_{S_'} = [T]_{S,S'}[v]_S$ - coordinates of $T(v)$ relative to $S'$",B2.inverse()*A*v], ])
S - Basis for Domain \left[\left[-1, 1, 0\right], \left[2, 1, 2\right], \left[3, -2, 1\right]\right]
S' - Basis for Range \left[\left[3, 1\right], \left[-1, 3\right]\right]
B - matrix of domain basis vectors \left(123112021\begin{array}{rrr} -1 & 2 & 3 \\ 1 & 1 & -2 \\ 0 & 2 & 1 \end{array}\right)
B' - matrix of range basis vectors \left(3113\begin{array}{rr} 3 & -1 \\ 1 & 3 \end{array}\right)
B'^{-1} \left(310110110310\begin{array}{rr} \frac{3}{10} & \frac{1}{10} \\ -\frac{1}{10} & \frac{3}{10} \end{array}\right)
A=[T] - Standard matrix representation \left(210032\begin{array}{rrr} 2 & 1 & 0 \\ 0 & 3 & -2 \end{array}\right)
[T]_{S,S'} = B'^{-1}AB - Matrix representation relative to S and S' \left(07525145145\begin{array}{rrr} 0 & \frac{7}{5} & \frac{2}{5} \\ 1 & -\frac{4}{5} & -\frac{14}{5} \end{array}\right)
v - standard coordinates \left(a,b,c\right)
[v]_S - coordinates relative to S \left(-5 \, a - 4 \, b + 7 \, c,a + b - c,-2 \, a - 2 \, b + 3 \, c\right)
T(v) - standard coordinates of T(v) \left(2 \, a + b,3 \, b - 2 \, c\right)
[T(v)]_{S_'} = [T]_{S,S'}[v]_S - coordinates of T(v) relative to S' \left(\frac{3}{5} \, a + \frac{3}{5} \, b - \frac{1}{5} \, c,-\frac{1}{5} \, a + \frac{4}{5} \, b - \frac{3}{5} \, c\right)

I still need to give an example of what happens if you choose the null space as part of your basis, and the image of the other vectors in your basis as a basis for the range.  Then the map is simply the identity. Maybe I won't visualize this, rather just show how to do it.

Then I need to show what happens if I use eigenvectors as the basis vectors.  This provides a really nice way to view the matrix transformation.

standard_matrix=matrix(QQ, [[2,1], [0,3]]) EV=standard_matrix.right_eigenmatrix()[1] A=standard_matrix B1=EV B2=EV e1=vector([1,0]) e2=vector([0,1]) c1,c2=A.columns() d1,d2=B1.columns() r1,r2=B2.columns() z=(0,0) boxplot1=arrow(z,e1,color='black',aspect_ratio=1) boxplot1+=arrow(z,e2,color='brown') boxplot1+=arrow(e2,e2+e1,color='black',linestyle='dashed') boxplot1+=arrow(e1,e1+e2,color='brown',linestyle='dashed') boxplot1+=arrow(z,d1,color='red',aspect_ratio=1) boxplot1+=arrow(z,d2,color='blue') boxplot1+=arrow(d2,d2+d1,color='red',linestyle='dashed') boxplot1+=arrow(d1,d1+d2,color='blue',linestyle='dashed') boxplot2=arrow(z,c1,color='black',aspect_ratio=1) boxplot2+=arrow(z,c2,color='brown') boxplot2+=arrow(c2,c2+c1,color='black',linestyle='dashed') boxplot2+=arrow(c1,c1+c2,color='brown',linestyle='dashed') for n in [-2,-1,0,1,2]: for m in [-2,-1,0,1,2]: boxplot2+=arrow(m*r1+n*r2,m*r1+n*r2+r1,color='orange',linestyle='dashed') boxplot2+=arrow(m*r2+n*r1,m*r2+n*r1+r2,color='green',linestyle='dashed') boxplot2+=arrow(z,A*d1,color='red',aspect_ratio=1) boxplot2+=arrow(z,A*d2,color='blue') boxplot2+=arrow(A*d2,A*(d2+d1),color='red',linestyle='dashed') boxplot2+=arrow(A*d1,A*(d1+d2),color='blue',linestyle='dashed') var('x,y,a,b') html.table([ ["$P$ - matrix of basis vectors",B1], ["$P^{-1}$", B2.inverse() ], ["$T(x,y)$ - The linear transformation ",A*vector([x,y])], ["$[T]_{E_2}$ - The standard matrix representation ",A], ["$[T]_{P}$ - The matrix representation relative to eigenvectors",B2.inverse()*A*B1], ["$[T(a,b)]_{P} = [T]_{P}[(a,b)]_P$",B2.inverse()*A*vector([a,b])], [boxplot1,boxplot2], ])
P - matrix of basis vectors \left(1110\begin{array}{rr} 1 & 1 \\ 1 & 0 \end{array}\right)
P^{-1} \left(0111\begin{array}{rr} 0 & 1 \\ 1 & -1 \end{array}\right)
T(x,y) - The linear transformation \left(2 \, x + y,3 \, y\right)
[T]_{E_2} - The standard matrix representation \left(2103\begin{array}{rr} 2 & 1 \\ 0 & 3 \end{array}\right)
[T]_{P} - The matrix representation relative to eigenvectors \left(3002\begin{array}{rr} 3 & 0 \\ 0 & 2 \end{array}\right)
[T(a,b)]_{P} = [T]_{P}[(a,b)]_P \left(3 \, b,2 \, a - 2 \, b\right)
A=matrix(QQ, [[2,1], [0,3]]) EV=A.eigenvectors_right() print(EV) P=A.eigenmatrix_right()[1] e1=vector([1,0]) e2=vector([0,1]) c1,c2=(A*P).columns() ev1,ev2=P.columns() z=(0,0) boxplot=arrow(z,ev1,color='red',aspect_ratio=1) boxplot+=arrow(z,ev2,color='blue') boxplot+=arrow(ev2,ev2+ev1,color='red',linestyle='dashed') boxplot+=arrow(ev1,ev1+ev2,color='blue',linestyle='dashed') boxplot+=arrow(z,c1,color='red',aspect_ratio=1) boxplot+=arrow(z,c2,color='blue') boxplot+=arrow(c2,c2+c1,color='red',linestyle='dashed') boxplot+=arrow(c1,c1+c2,color='blue',linestyle='dashed') var('t') r=vector([cos(t),sin(t)]) circleplot=parametric_plot(P*r,(t,0,2*pi)) circleplot+=parametric_plot(A*P*r,(t,0,2*pi)) r=1/3*vector([(1 - sin(t))*cos(t)+1.5, (1 - sin(t))*sin(t)+2.5]) heart=parametric_plot( P*r, (t, pi/2, 3*pi/2),color='black') heart+=parametric_plot( P*r, (t, -pi/2, pi/2),color='brown') heart+=parametric_plot( A*P*r, (t, pi/2, 3*pi/2),color='black') heart+=parametric_plot( A*P*r, (t, -pi/2, pi/2),color='brown') html.table([ ["Eigenvalues",A.eigenvalues()], ["$P$ - matrix of basis vectors",P], ["$P^{-1}$", P.inverse() ], ["$T(x,y)$ - The linear transformation ",A*vector([x,y])], ["$[T]_{E_2}$ - The standard matrix representation ",A], ["$[T]_{P}$ - The matrix representation relative to eigenvectors",P.inverse()*A*P], ["$[T(a,b)]_{P} = [T]_{P}[(a,b)]_P$",P.inverse()*A*vector([a,b])], [ boxplot+heart,boxplot+circleplot ], ])
[(3, [ (1, 1) ], 1), (2, [ (1, 0) ], 1)]
Eigenvalues \left[3, 2\right]
P - matrix of basis vectors \left(1110\begin{array}{rr} 1 & 1 \\ 1 & 0 \end{array}\right)
P^{-1} \left(0111\begin{array}{rr} 0 & 1 \\ 1 & -1 \end{array}\right)
T(x,y) - The linear transformation \left(2 \, x + y,3 \, y\right)
[T]_{E_2} - The standard matrix representation \left(2103\begin{array}{rr} 2 & 1 \\ 0 & 3 \end{array}\right)
[T]_{P} - The matrix representation relative to eigenvectors \left(3002\begin{array}{rr} 3 & 0 \\ 0 & 2 \end{array}\right)
[T(a,b)]_{P} = [T]_{P}[(a,b)]_P \left(3 \, b,2 \, a - 2 \, b\right)

When you choose as your basis a set of eigenvectors of AA, the matrix PP whose columns are eigenvectors allows us to diagonalize AA.  We have the equation AP=PDAP=PD where DD is the diagonal matrix whose diagonal entries are the eigenvectors.  The code below illustrates how to do this for any matrix.  If the matrix is not diagonalizable, it is precisely because there are not enough linearly independent eigenvectors. In this case, Jordan form provides a simple way to view the transformation.  We'll be looking at Jordan form more in the next unit.

A=matrix(QQ, [[5,1,4], [0,5,3], [0,0,7] ]) EV=A.eigenvectors_right() P=A.eigenmatrix_right()[1] print(EV) html.table([ ["Eigenvalues - if there is a repeat, does P contain a column of zeros?",A.eigenvalues()], ["$P$ - matrix of basis vectors - does it contain a column of zeros?",P], ]) J, P = A.jordan_form(transformation = True) print("When there is not basis of eigenvectors, the matrix is not diagonalizable") html.table([ ["$P$ - matrix of basis vectors using generalized eigenvectors",P], ["$J=P^{-1}AP$ - Jordan Form",P.inverse()*A*P], ["$J$ - Jordan Form with an emphasis on the Jordan blocks",J], ])
[(7, [ (1, 6/11, 4/11) ], 1), (5, [ (1, 0, 0) ], 2)]
Eigenvalues - if there is a repeat, does P contain a column of zeros? \left[7, 5, 5\right]
P - matrix of basis vectors - does it contain a column of zeros? \left(1106110041100\begin{array}{rrr} 1 & 1 & 0 \\ \frac{6}{11} & 0 & 0 \\ \frac{4}{11} & 0 & 0 \end{array}\right)
When there is not basis of eigenvectors, the matrix is not diagonalizable
P - matrix of basis vectors using generalized eigenvectors \left(1106110141100\begin{array}{rrr} 1 & 1 & 0 \\ \frac{6}{11} & 0 & 1 \\ \frac{4}{11} & 0 & 0 \end{array}\right)
J=P^{-1}AP - Jordan Form \left(700051005\begin{array}{rrr} 7 & 0 & 0 \\ 0 & 5 & 1 \\ 0 & 0 & 5 \end{array}\right)
J - Jordan Form with an emphasis on the Jordan blocks \left(ParseError: KaTeX parse error: Expected '\right', got 'EOF' at end of input: …} 7 \end{array}\right) & \left(00\begin{array}{rr} 0 & 0 \end{array}\right) \\ \left(00\begin{array}{r} 0 \\ 0 \end{array}\right) & \left(5105\begin{array}{rr} 5 & 1 \\ 0 & 5 \end{array}\right) \end{array}\right)