# Linear Transformations and LaTeX

I had planned on doing a post about linear dynamical systems and Markov chains, but that will have to wait. In the mean time, I have been reading about linear transformations and change of basis. This took me a little time to wrap my head around; I’m still working on it. One of the best resources I have found on the subject is here.

My discussion below follows this one very closely, but I have altered the notation slightly, as I find it helpful to express things as unit basis vectors $\begin{array}{ccc} e_{1}, & e_{2}, & e_{3}\end{array}$ and transformed basis vectors $\begin{array}{ccc} f_{1}, & f_{2}, & f_{3}\end{array}$. I will also use $\begin{array}{ccc} a_{1}, & a_{2}, & a_{3}\end{array}$ and $\begin{array}{ccc} b_{1}, & b_{2}, & b_{3}\end{array}$ to represent vector coefficients for two different sets of basis vectors.

This has been a useful exercise in $\LaTeX$, which I have also been learning about. If you want to get started with $\LaTeX$ to display math formulas in blog pages, go here.

Note: This is *not* how you do regular $\LaTeX$ which is slightly more complicated, but it does allow you easily add well-formed math symbols to blog pages, which otherwise would require the use of either description or simulation in text, or images.

Here’s a brief summary:  $\begin{array}{lll} v & = & \left ( \begin{array}{ccc} e_{1} & e_{2} & e_{3} \end{array} \right) \left ( \begin{array}{c} a_{1} \\ a_{2} \\ a_{3} \end{array} \right) = a_{1}e_1 + a_{2}e_2 + a_{3}e_3 \\ \\ \\ u & = & \left ( \begin{array}{ccc} f_{1} & f_{2} & f_{3} \end{array} \right) \left ( \begin{array}{c} b_{1} \\ b_{2} \\ b_{3} \end{array} \right) = b_{1}f_1 + b_{2}f_2 + b_{3}f_3 \\ \\ \\ v & = & e^{T}a = u = f^{T}b \\ \\ \\ f & = & e^{T}M, b = M^{-1}a \end{array}$ $\left ( \begin{array}{lll} v^{\prime} &= &e^{T}\left (Ma\right ) \end{array} \right )$

Note that $Ma$ can be used to express the coefficients of the transformed vector $v^{\prime}$ in the set of basis vectors $\begin{array}{ccc} e_{1}, & e_{2}, & e_{3}\end{array}$. $\begin{array}{lll} v & = & e^{T}a = u = f^{T}b = e^{T}Mb = e^{T}MM^{-1}a = e^{T}Ia = e^{T}a \\ \\ \\ & = & \left ( \begin{array}{ccc} e_{1} & e_{2} & e_{3} \end{array} \right) \left ( \begin{array}{c} a_{1} \\ a_{2} \\ a_{3} \end{array} \right) = \left ( \begin{array}{ccc} f_{1} & f_{2} & f_{3} \end{array} \right) \left ( \begin{array}{c} b_{1} \\ b_{2} \\ b_{3} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{ccc} e_{1} & e_{2} & e_{3} \end{array} \right) \left ( \begin{array}{ccc} m_{11} & m_{12} & m_{13} \\ m_{21} & m_{22} & m_{23} \\ m_{31} & m_{32} & m_{33} \end{array} \right) \left ( \begin{array}{c} b_{1} \\ b_{2} \\ b_{3} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{ccc} e_{1} & e_{2} & e_{3} \end{array} \right) \left ( \begin{array}{ccc} m_{11} & m_{12} & m_{13} \\ m_{21} & m_{22} & m_{23} \\ m_{31} & m_{32} & m_{33} \end{array} \right) M^{-1} \left ( \begin{array}{c} a_{1} \\ a_{2} \\ a_{3} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{ccc} e_{1} & e_{2} & e_{3} \end{array} \right) I \left ( \begin{array}{c} a_{1} \\ a_{2} \\ a_{3} \end{array} \right) = \left ( \begin{array}{ccc} e_{1} & e_{2} & e_{3} \end{array} \right) \left ( \begin{array}{c} a_{1} \\ a_{2} \\ a_{3} \end{array} \right) \end{array}$ $\begin{array}{lll} \left ( \begin{array}{lll} f_{1} & f_{2} & f_{3} \end{array} \right ) & = & \left ( \begin{array}{lll} e_{1} & e_{2} & e_{3} \end{array} \right) \left ( \begin{array}{ccc} m_{11} & m_{12} & m_{13} \\ m_{21} & m_{22} & m_{23} \\ m_{31} & m_{32} & m_{33} \end{array} \right ) = \left ( \begin{array}{l} m_{11}e_1 + m_{21}e_2 + m_{31}e_3 \\ m_{12}e_1 + m_{22}e_2 + m_{32}e_3 \\ m_{13}e_1 + m_{23}e_2 + m_{33}e_3 \end{array} \right)^T \\ \\ \\ f_1 &= &m_{11}e_1 + m_{21}e_2 + m_{31}e_3 \\ f_2 &= &m_{12}e_1 + m_{22}e_2 + m_{32}e_3 \\ f_3 &= &m_{13}e_1 + m_{23}e_2 + m_{33}e_3 \end{array} \\ \\ \\ \\ \\$

Note that the columns of $M$ can be seen as new (transformed) basis vectors $\begin{array}{ccc} f_{1}, & f_{2}, & f_{3}\end{array}$ when the standard unit basis vectors $\begin{array}{ccc} e_{1}, & e_{2}, & e_{3}\end{array}$ are used to formulate the $v$ vector initially. The matrix $M$ is the transforming matrix for unit basis vectors $\begin{array}{ccc} e_{1}, & e_{2}, & e_{3}\end{array}$.

As you can see, the two matrices $M$ and $M^{-1}$ cancel each other out, and the vectors $v$ and $u$ are equal to each other – there is a difference in basis ( $e$ vs $f$), and, for that reason, it is necessary for each vector to have different coefficients.

But the vectors are the same; they can be used to describe the same locations in a shared, common physical space, assuming you know the relationship between the two sets of basis vectors $\begin{array}{ccc} e_{1}, & e_{2}, & e_{3}\end{array}$ and $\begin{array}{ccc} f_{1}, & f_{2}, & f_{3}\end{array}$ for $v$ and $u$.

The point is that it is possible, using matrix $M$ and its inverse, matrix $M^{-1}$ to define a new set of basis vectors and to define a new set of coefficients for those basis vectors to be used to describe the same physical location. This can be useful, for example, in translating between systems that exist in the same physical space, such as the interior of a spacecraft orbiting the earth, and the earth-centered space around it.

Also, as you can see, the tools provided by $\LaTeX$ make it possible to describe all this in a much more elegant and instructive way than would be possible otherwise. See my previous blog post on the subject of $\LaTeX$ for additional details about this.

Here is an example in 2D, using, again, the standard basis vectors $\begin{array}{cc} e_{1}, & e_{2} \end{array}$ and transformed basis vectors $\begin{array}{cc} f_{1}, & f_{2} \end{array}$ for $v$ and $u$.

The vectors $v$ and $u$ are equal to each other, but make use of different sets of basis vectors and coefficients. We will also take a look at transforming the vector $v$ to $v^\prime$; note that the vectors $v$ and $v^\prime$ are *not* equivalent.  $v = e^{T}a = u = f^{T}b = e^{T}Mb = e^{T}MM^{-1}a = e^{T}Ia = e^{T}a \\ \\ \begin{array}{lll} \left ( \begin{array}{ll} f_{1} & f_{2} \end{array} \right ) & = & \left ( \begin{array}{ll} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} m_{11} & m_{12} \\ m_{21} & m_{22} \end{array} \right ) = \left ( \begin{array}{ll} m_{11}e_1 + m_{21}e_2 & m_{12}e_1 + m_{22}e_2 \end{array} \right) \\ \\ f_1 &= &m_{11}e_1 + m_{21}e_2 \\ f_2 &= &m_{12}e_1 + m_{22}e_2 \end{array} \\ \\ \\ \begin{array}{lll} \left ( \begin{array}{ll} f_{1} & f_{2} \end{array} \right ) & = & \left ( \begin{array}{ll} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{array} \right ) = \left ( \begin{array}{ll} \cos\theta e_1 + \sin\theta e_2 & -\sin\theta e_1 + \cos\theta e_2 \end{array} \right) \\ \\ & = & \left ( \begin{array}{cc} \left ( \begin{array}{c} \cos\theta \\ \sin\theta \end{array} \right ) \left ( \begin{array}{c} -\sin\theta \\ \cos\theta \end{array} \right ) \end{array} \right ) \\ \\ f_1 &= &\left ( \begin{array}{c} \cos\theta \\ \sin\theta \end{array} \right ) \\ \\ f_2 &= &\left ( \begin{array}{c} -\sin\theta \\ \cos\theta \end{array} \right ) \\ \\ \left ( \begin{array}{c} b_{1} \\ b_{2} \end{array} \right) & = & M^{-1} \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \\ \\ & = & \left ( \begin{array}{cc} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{array} \right ) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \\ \\ \\ \end{array}$ $\begin{array}{lll} v & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) = \left ( \begin{array}{cc} f_{1} & f_{2} \end{array} \right) \left ( \begin{array}{c} b_{1} \\ b_{2} \\ \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} m_{11} & m_{12}\\ m_{21} & m_{22} \end{array} \right) \left ( \begin{array}{c} b_{1} \\ b_{2} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) M M^{-1} \left ( \begin{array}{c} a_{1} \\ a_{2} \\ a_{3} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{array} \right ) \left ( \begin{array}{cc} \cos\theta & \sin\theta \\ -\sin\theta & \cos\theta \end{array} \right ) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} \cos^2\theta + \sin^2\theta & \cos\theta\sin\theta - \sin\theta\cos\theta\\ \sin\theta\cos\theta - \cos\theta\sin\theta & \sin^2\theta - \cos^2\theta \end{array} \right ) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right ) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) I \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) = \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \end{array}$ $\\ \\ \\ \left ( \begin{array}{lll} v^{\prime} &= &e^{T}\left (Ma\right ) \end{array} \right) \\ \\ \\$

Note that $v^{\prime}$ is different from $v$ because the coefficients $\begin{array}{lll} a_{1} & a_{2} & a_{3} \end{array}$ rather than the standard unit basis vectors $\begin{array}{lll} e_{1} & e_{2} & e_{3} \end{array}$ have been transformed by the $M$ matrix. $\begin{array}{lll} v^{\prime} & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{cc} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{array} \right ) \left ( \begin{array}{c} a_{1} \\ a_{2} \end{array} \right) \\ \\ \\ & = & \left ( \begin{array}{cc} e_{1} & e_{2} \end{array} \right) \left ( \begin{array}{c} a_{1}\cos\theta - a_{2}\sin\theta \\ a_{1}\sin\theta + a_{2}\cos\theta \end{array} \right) \\ \\ \\ \end{array}$

If you would rather read this in a printable format and see what else is possible to do with $\LaTeX$ (and $\textrm {Ti}k \textrm {Z}$, which is the graphics package I used to generate the coordinate and vector images above), I’ve attached a downloadable pdf below.

TeXLinearTransform2