17. Matrix of a linear map

Matrix of a linear map

Matrices will be important for us for yet one more reason. It turns out that multiplying a matrix by a vector is actually the same as calculating a value of a linear map. Observe the following:

    \[\left[\begin{array}{ccc}1&0&-1\\2&3&-1\end{array}\right]\cdot \left[\begin{array}{c}x\\y\\z\end{array}\right]=\left[\begin{array}{c}x-z\\2x+3y-z\end{array}\right]\]

is exactly the same as \phi((x,y,z))=(x-z,2x+3y-z).

More precisely, given a linear map \varphi\colon V\to W, basis \mathcal{A} of V and basis \mathcal{B} of W, a matrix M(\varphi)_{\mathcal{A}}^{\mathcal{B}} which multiplied from the right by a (vertical) vector of coordinates of a vector v in basis \mathcal{A} will give the coordinates of \varphi(v) in \mathcal{B} will be called the matrix of \varphi in basis \mathcal{A} and \mathcal{B}.

In particular in the above example:

    \[M(\phi)_{st}^{st}=\left[\begin{array}{ccc}1&0&-1\\2&3&-1\end{array}\right]\]

is the matrix of \phiin standard basis — and can be easily written out of the formula defining \phi simply by writing its coefficients in rows.

Changing bases of a matrix — first method: calculate coordinates.

Assume that we are given a formula defining \phi, as above (or its matrix in the standard basis) and basis \mathcal{A} and \mathcal{B}. E.g.: \mathcal{A}=((1,1,1),(1,0,-1),(1,0,0)) and \mathcal{B}=((2,3),(-1,-1)). We would like to calculate M(\phi)_{\mathcal{A}}^{\mathcal{B}}.

Notice that if we multiply this matrix from the right by (vertical) vector (1,0,0), then I will get simply the first column of this matrix. On the other hand the first vector from \mathcal{A}, namely vector (1,1,1), has in this basis coordinates 1,0,0. Therefore the result of the multiplication are the coordinates of \phi((1,1,1)) in basis \mathcal{B} and this is the first column of M(\phi)_{\mathcal{A}}^{\mathcal{B}}.

So: \phi((1,1,1))=(1-1, 2+3-1)=(0,4) and we have to find the coordinates of this vector in \mathcal{B}: (0,4)=4(2,3)+8(-1,-1), so the coordinates are 4,8 and this is the first column of the matrix we would like to calculate.

Let us find the second column. We do the same as before but with the second vector from basis \mathcal{A}. \phi((1,0,-1))=(1-(-1),2-(-1))=(2,3) has coordinates 1,0 in \mathcal{B}.

The third column: \phi((1,0,0))=(1,2) has in \mathcal{B} coordinates (1,2)=(2,3)+(-1,-1), so 1,1

Therefore:

    \[M(\phi)_{\mathcal{A}}^{\mathcal{B}}=\left[\begin{array}{ccc}4&1&1\\8&0&1\end{array}\right]\]

Composing maps

Given two linear maps \phi\colon V\to W and \psi\colon W\to U we can compose them and consider a map which transforms a vector from V first via \phi and the result via \psi getting a vector form U.

Such a map is denoted as \psi\circ \phi. Given formulas defining \phi i \psi we can easily get the formula for \psi\circ \phi. E.g. consider \phi as above and \psi\colon\mathbb{R}^2\to\mathbb{R}^4 such that \psi((a,b))=(-b,a+b,-2a-b,3a). Therefore (\psi\circ\phi)((x,y,z))=\psi(\phi((x,y,z))=\psi(((x-z,2x+3y-z))=(-2x-3y+z,3x+3y-2z,-4x-3y+3z,3x-3z).

Now look at the matrices of those maps. If \mathcal{A} is basis of V, \mathcal{B} is basis W and \mathcal{C} is basis of U, then given coordinates of v in \mathcal{A} to get the coordinates of \psi\circ\phi(v)=\psi(\phi(v)) in \mathcal{C} we have to first multiply it by matrix M(\phi)_{\mathcal{A}}^{\mathcal{B}} (we will get coordinates \phi(v) in \mathcal{B}) and multiply the result by M(\psi)_{\mathcal{B}}^{\mathcal{C}}. Therefore we have multiplied the coordinates by M(\psi)_{\mathcal{B}}^{\mathcal{C}} \cdot M(\phi)_{\mathcal{A}}^{\mathcal{B}}, which means that:

    \[M(\psi\circ\phi)_{\mathcal{A}}^{\mathcal{C}} =M(\psi)_{\mathcal{B}}^{\mathcal{C}} \cdot M(\phi)_{\mathcal{A}}^{\mathcal{B}}.\]

Notice which bases have to agree in this formula!

In particular in our example:

    \[M(\psi\circ\phi)_{st}^{st} =M(\psi)_{st}^{st} \cdot M(\phi)_{st}^{st}=\left[\begin{array}{cc}0&-1\\1&1\\-2&-1\\3&0\end{array}\right]\cdot \left[\begin{array}{ccc}1&0&-1\\2&3&-1\end{array}\right] =\left[\begin{array}{ccc}-2&-3&1\\3&3&-2\\-4&-3&3\\3&0&-3\end{array}\right] \]

which is consistent with the formula we have calculated before.

Change-of-coordinates matrix

There is a special linear map, which we call the identity, which does nothing. For example, in \mathbb{R}^3 it is id((x,y,z))=(x,y,z). Therefore given two basis \mathcal{A} and \mathcal{B}, along with matrix M(id)_{\mathcal{A}}^{\mathcal{B}} if we multiply this matrix from the right by the coordinates of a vector v in basis \mathcal{A} we will get the coordinates also of v (as id(v)=v), but in basis \mathcal{B}. So matrix M(id)_{\mathcal{A}}^{\mathcal{B}} changes the basis from \mathcal{A} to \mathcal{B}.

Especially we will need matrices changing basis from the standard basis to the given one and from the given basis to the standard one. Let’s check how to calculate them.

It is easy to calculate the change-of-coordinates matrix change from a given basis to the standard basis. We will find M(id)_{\mathcal{A}}^{st} (basis is defined in the example above). After multiplying it from the right by 1,0,0 we will get its first column. On the other hand the first vector in \mathcal{A} has in it coordinates 1,0,0, so the result of multiplication are the coordinates of this vector in the standard basis, so simply it is this vector. So simply the i-th column of this matrix is the i-th vector from the basis. Therefore:

    \[M(id)_{\mathcal{A}}^{st}=\left[\begin{array}{ccc}1&1&1\\1&0&0\\1&-1&0\end{array}\right]\]

Now, the other case: from the standard basis to a given basis. We will calculate M(id)_{st}^{\mathcal{B}}. It can be easily seen that in columns we should put coordinates of vectors from the standard basis in the given basis. Let us calculate them: (1,0)=-(2,3)-3(-1,-1) and (0,1)=(2,3)+2(-1,-1). Therefore:

    \[M(id)_{st}^{\mathcal{B}}=\left[\begin{array}{cc}-1&1\\-3&2\end{array}\right].\]

Changing the basis of a matrix — the second method: multiplication by a change-of-coordinates matrix

We have a new tool to change basis of a matrix of a linear map. Because id\circ \phi\circ id =\phi, we have that:

    \[M(\phi)_{\mathcal{A}}^{\mathcal{D}}=M(id\circ\phi\circ id)_{\mathcal{A}}^{\mathcal{D}}=M(id)_{\mathcal C}^{\mathcal{D}}\cdot M(\phi)_{\mathcal{B}}^{\mathcal{C}}\cdot M(id)_{\mathcal{A}}^{\mathcal{B}}.\]

In particular:

    \[M(\phi)_{\mathcal{A}}^{\mathcal{B}}=M(id)_{st}^{\mathcal{B}}\cdot M(\phi)_{st}^{st}\cdot M(id)_{\mathcal{A}}^{st}\]

and in this way given a matrix of a linear map in standard basis we can calculate its matrix in basis from \mathcal{A} to \mathcal{B}. In our example:

    \[M(\phi)_{\mathcal{A}}^{\mathcal{B}}=\left[\begin{array}{cc}-1&1\\-3&2\end{array}\right]\cdot\left[\begin{array}{ccc}1&0&-1\\2&3&-1\end{array}\right]\cdot\left[\begin{array}{ccc}1&1&1\\1&0&0\\1&-1&0\end{array}\right]=\]

    \[=\left[\begin{array}{ccc}1&3&0\\1&6&1\end{array}\right] \cdot\left[\begin{array}{ccc}1&1&1\\1&0&0\\1&-1&0\end{array}\right]=\left[\begin{array}{ccc}4&1&1\\8&0&1\end{array}\right].\]

Obviously we get the same result as calculated by the first method.