Mathematics Basics - Linear Algebra (Matrix Part 1)

Matrix

Intro

A lot of ideas in matrix are related to what we have already learned in vector. Recall that we can express a simultaneous equation as multiplication of a matrix and a vector.

2 a + 3 b = 12 5 a + b = 17 2a + 3b = 12\\ 5a + b = 17 2a+3b=125a+b=17

( 2 3 5 1 ) ∗ ( a b ) = ( 12 17 ) \begin{pmatrix}2&3\\5&1\end{pmatrix}*\begin{pmatrix}a\\b\end{pmatrix}=\begin{pmatrix}12\\17\end{pmatrix} (2531)(ab)=(1217)

In this chapter, we are going to look under the hood to understand what exactly happens during this multiplication operation. It’s intriguing to see how powerful matrices are in terms of transforming vectors. This concept is also at the heart of linear algebra.

We will then dive into the solution for simultaneous equations by calculating matrix inverse and determinant. Understanding matrix inverse then unlocks the way we convert a vector space in general. As compared to what we have learned previously on changing basis, now we are able to convert a vector to any space without being restricted to a space of orthogonal basis vectors.

We are also going to look at two interesting extensions of matrix. One is called orthogonal matrix. It is the most convenient kind of matrix when we need to perform matrix inverse operation. We will construct such a matrix by the Gram-Schmidt process. The other extension is Eigen vectors and Eigen values. Eigen vectors have some special properties during matrix transformation. Knowing the Eigen vectors for a matrix will also make repeated multiplication of this matrix by itself much simpler.

Let’s get started!

Matrix as a Transformation

We start by showing a matrix ( 2 3 5 1 ) \begin{pmatrix}2&3\\5&1\end{pmatrix} (2531) multiplied by the basis vector ( 1 0 ) \begin{pmatrix}1\\0\end{pmatrix} (10) and ( 0 1 ) \begin{pmatrix}0\\1\end{pmatrix} (01).

( 2 3 5 1 ) ∗ ( 1 0 ) = ( 2 5 ) \begin{pmatrix}2&3\\5&1\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}=\begin{pmatrix}2\\5\end{pmatrix} (2531)(10)=(25)

( 2 3 5 1 ) ∗ ( 0 1 ) = ( 3 1 ) \begin{pmatrix}2&3\\5&1\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}=\begin{pmatrix}3\\1\end{pmatrix} (2531)(01)=(31)

To read this result, we can see matrix ( 2 3 5 1 ) \begin{pmatrix}2&3\\5&1\end{pmatrix} (2531) transforms vector ( 1 0 ) \begin{pmatrix}1\\0\end{pmatrix} (10) into a new vector ( 2 5 ) \begin{pmatrix}2\\5\end{pmatrix} (25) and transforms vector ( 0 1 ) \begin{pmatrix}0\\1\end{pmatrix} (01) into a new vector ( 3 1 ) \begin{pmatrix}3\\1\end{pmatrix} (31). Graphically, we get below transformation from e 1 e_1 e1 to e 1 ′ e_1' e1 and from e 2 e_2 e2 to e 2 ′ e_2' e2.

Matrix Transformation

We learned from previous chapter on vector that e 1 e_1 e1 and e 2 e_2 e2 describe a basis vector space. After being multiplied by a matrix ( 2 3 5 1 ) \begin{pmatrix}2&3\\5&1\end{pmatrix} (2531), the original vector space changes to a new one described by e 1 ′ e_1' e1 and e 2 ′ e_2' e2. If we call e 1 e_1 e1 and e 2 e_2 e2 our input vectors and e 1 ′ e_1' e1 and e 2 ′ e_2' e2 our output vectors, what matrix multiplication does therefore is equivalent to a vector space transformation.

This part is tricky, but very critical for us to form a right intuition of matrix multiplication. Let’s do a matrix multiplication in a step-by-step manner to illustrate this idea of vector space transformation.

( 2 3 5 1 ) ∗ ( 3 2 ) = ( 2 3 5 1 ) ∗ ( 3 ∗ ( 1 0 ) + 2 ∗ ( 0 1 ) ) = ( 2 3 5 1 ) ∗ ( 3 ∗ e 1 + 2 ∗ e 2 ) = 3 ∗ ( 2 3 5 1 ) ∗ e 1 + 2 ∗ ( 2 3 5 1 ) ∗ e 2 = 3 ∗ ( 2 5 ) + 2 ∗ ( 3 1 ) = 3 ∗ e 1 ′ + 2 ∗ e 2 ′ \begin{aligned} \begin{pmatrix}2&3\\5&1\end{pmatrix}*\begin{pmatrix}3\\2\end{pmatrix}&=\begin{pmatrix}2&3\\5&1\end{pmatrix}*\left(3*\begin{pmatrix}1\\0\end{pmatrix}+2*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=\begin{pmatrix}2&3\\5&1\end{pmatrix}*(3*e_1+2*e_2)\\ &=3*\begin{pmatrix}2&3\\5&1\end{pmatrix}*e_1+2*\begin{pmatrix}2&3\\5&1\end{pmatrix}*e_2\\ &=3*\begin{pmatrix}2\\5\end{pmatrix}+2*\begin{pmatrix}3\\1\end{pmatrix}\\ &=3*e_1'+2*e_2' \end{aligned} (2531)(32)=(2531)(3(10)+2(01))=(2531)(3e1+2e2)=3(2531)e1+2(2531)e2=3(25)+2(31)=3e1+2e2

Note here we make use of the associative and distributive properties of matrix multiplication.

The vector ( 3 2 ) \begin{pmatrix}3\\2\end{pmatrix} (32) is originally expressed in basis vectors e 1 e_1 e1 and e 2 e_2 e2. After being multiplied by matrix ( 2 3 5 1 ) \begin{pmatrix}2&3\\5&1\end{pmatrix} (2531), we have projected it onto the new basis vectors e 1 ′ e_1' e1 and e 2 ′ e_2' e2, i.e., 3 e 1 ′ + 2 e 2 ′ 3e_1'+2e_2' 3e1+2e2. So we can think of matrix multiplication as the vector sum of the transformed basis vectors. Matrix ( 2 3 5 1 ) \begin{pmatrix}2&3\\5&1\end{pmatrix} (2531) tells us where the original basis vectors e 1 e_1 e1 and e 2 e_2 e2 should go after the transformation. In addition, we can see that columns of the transformation matrix are just the new basis vectors, e 1 ′ = ( 2 5 ) e_1'=\begin{pmatrix}2\\5\end{pmatrix} e1=(25), e 2 ′ = ( 3 1 ) e_2'=\begin{pmatrix}3\\1\end{pmatrix} e2=(31).

If we treat matrix as a way to transform vector space, how many ways can we transform it? Next, we will discuss some possible matrix transformation in a 2-dimensional space.

Identity Matrix

( 1 0 0 1 ) \begin{pmatrix}1&0\\0&1\end{pmatrix} (1001) is an identity matrix. It keeps the vector space unchanged. That means a vector is not altered at all when it is multiplied by an identity matrix. We can look at an example of vector ( 3 2 ) \begin{pmatrix}3\\2\end{pmatrix} (32).

( 1 0 0 1 ) ∗ ( 3 2 ) = ( 1 0 0 1 ) ∗ ( 3 ∗ ( 1 0 ) ) + ( 1 0 0 1 ) ∗ ( 2 ∗ ( 0 1 ) ) = 3 ∗ ( ( 1 0 0 1 ) ∗ ( 1 0 ) ) + 2 ∗ ( ( 1 0 0 1 ) ∗ ( 0 1 ) ) = 3 ∗ ( 1 0 ) + 2 ∗ ( 0 1 ) = ( 3 2 ) \begin{aligned} \begin{pmatrix}1&0\\0&1\end{pmatrix}*\begin{pmatrix}3\\2\end{pmatrix}&=\begin{pmatrix}1&0\\0&1\end{pmatrix}*\left(3*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}1&0\\0&1\end{pmatrix}*\left(2*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=3*\left(\begin{pmatrix}1&0\\0&1\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+2*\left(\begin{pmatrix}1&0\\0&1\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=3*\begin{pmatrix}1\\0\end{pmatrix}+2*\begin{pmatrix}0\\1\end{pmatrix}\\ &=\begin{pmatrix}3\\2\end{pmatrix} \end{aligned} (1001)(32)=(1001)(3(10))+(1001)(2(01))=3((1001)(10))+2((1001)(01))=3(10)+2(01)=(32)

Scaling Matrix

Scaling matrix has this form ( a 0 0 b ) \begin{pmatrix}a&0\\0&b\end{pmatrix} (a00b). It alters the area of basis vector space by a factor of a ∗ b a*b ab. Let’s look at an example below.

( 5 0 0 7 ) ∗ ( x y ) = ( 5 0 0 7 ) ∗ ( x ∗ ( 1 0 ) ) + ( 5 0 0 7 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( 5 0 0 7 ) ∗ ( 1 0 ) ) + y ∗ ( ( 5 0 0 7 ) ∗ ( 0 1 ) ) = x ∗ ( 5 0 ) + y ∗ ( 0 7 ) \begin{aligned} \begin{pmatrix}5&0\\0&7\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}5&0\\0&7\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}5&0\\0&7\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}5&0\\0&7\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}5&0\\0&7\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}5\\0\end{pmatrix}+y*\begin{pmatrix}0\\7\end{pmatrix} \end{aligned} (5007)(xy)=(5007)(x(10))+(5007)(y(01))=x((5007)(10))+y((5007)(01))=x(50)+y(07)

The basis vectors for ( x y ) \begin{pmatrix}x\\y\end{pmatrix} (xy) have shifted from ( 1 0 ) \begin{pmatrix}1\\0\end{pmatrix} (10) and ( 0 1 ) \begin{pmatrix}0\\1\end{pmatrix} (01) to ( 5 0 ) \begin{pmatrix}5\\0\end{pmatrix} (50) and ( 0 7 ) \begin{pmatrix}0\\7\end{pmatrix} (07). This stretches the vector space from a 1X1 square to a 5X7 rectangle as shown in the graph below.

Scaling Matrix

Similarly, we can also have a scaling matrix with fractional values. This squashes the original vector space into a smaller one.

Flipping Matrix

We can use matrix ( − 1 0 0 1 ) \begin{pmatrix}-1&0\\0&1\end{pmatrix} (1001) to flip the horizontal basis vector ( 1 0 ) \begin{pmatrix}1\\0\end{pmatrix} (10) to the other side. Here is an illustration.

( − 1 0 0 1 ) ∗ ( x y ) = ( − 1 0 0 1 ) ∗ ( x ∗ ( 1 0 ) ) + ( − 1 0 0 1 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( − 1 0 0 1 ) ∗ ( 1 0 ) ) + y ∗ ( ( − 1 0 0 1 ) ∗ ( 0 1 ) ) = x ∗ ( − 1 0 ) + y ∗ ( 0 1 ) \begin{aligned} \begin{pmatrix}-1&0\\0&1\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}-1&0\\0&1\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}-1&0\\0&1\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}-1&0\\0&1\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}-1&0\\0&1\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}-1\\0\end{pmatrix}+y*\begin{pmatrix}0\\1\end{pmatrix} \end{aligned} (1001)(xy)=(1001)(x(10))+(1001)(y(01))=x((1001)(10))+y((1001)(01))=x(10)+y(01)

Graphically, this flips the basis vectors along the vertical axis.

Flipping Matrix along Vertical Axis

Similarly, we can use matrix ( 1 0 0 − 1 ) \begin{pmatrix}1&0\\0&-1\end{pmatrix} (1001) to flip the basis vectors along the horizontal axis.

( 1 0 0 − 1 ) ∗ ( x y ) = ( 1 0 0 − 1 ) ∗ ( x ∗ ( 1 0 ) ) + ( 1 0 0 − 1 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( 1 0 0 − 1 ) ∗ ( 1 0 ) ) + y ∗ ( ( 1 0 0 − 1 ) ∗ ( 0 1 ) ) = x ∗ ( 1 0 ) + y ∗ ( 0 − 1 ) \begin{aligned} \begin{pmatrix}1&0\\0&-1\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}1&0\\0&-1\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}1&0\\0&-1\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}1&0\\0&-1\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}1&0\\0&-1\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}1\\0\end{pmatrix}+y*\begin{pmatrix}0\\-1\end{pmatrix} \end{aligned} (1001)(xy)=(1001)(x(10))+(1001)(y(01))=x((1001)(10))+y((1001)(01))=x(10)+y(01)
Flipping Matrix along Horizontal Axis

Inverse Matrix

When we flip the basis vectors in both vertical and horizontal direction, we get a new vector space that has inverted the values in both basis vectors. This inverse matrix is ( − 1 0 0 − 1 ) \begin{pmatrix}-1&0\\0&-1\end{pmatrix} (1001).

( − 1 0 0 − 1 ) ∗ ( x y ) = ( − 1 0 0 − 1 ) ∗ ( x ∗ ( 1 0 ) ) + ( − 1 0 0 − 1 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( − 1 0 0 − 1 ) ∗ ( 1 0 ) ) + y ∗ ( ( − 1 0 0 − 1 ) ∗ ( 0 1 ) ) = x ∗ ( − 1 0 ) + y ∗ ( 0 − 1 ) \begin{aligned} \begin{pmatrix}-1&0\\0&-1\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}-1&0\\0&-1\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}-1&0\\0&-1\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}-1&0\\0&-1\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}-1&0\\0&-1\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}-1\\0\end{pmatrix}+y*\begin{pmatrix}0\\-1\end{pmatrix} \end{aligned} (1001)(xy)=(1001)(x(10))+(1001)(y(01))=x((1001)(10))+y((1001)(01))=x(10)+y(01)
Inverse Matrix

Diagonal Mirroring Matrix

We can also do a mirroring of vector space along the 45° line with matrix ( 0 1 1 0 ) \begin{pmatrix}0&1\\1&0\end{pmatrix} (0110).

( 0 1 1 0 ) ∗ ( x y ) = ( 0 1 1 0 ) ∗ ( x ∗ ( 1 0 ) ) + ( 0 1 1 0 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( 0 1 1 0 ) ∗ ( 1 0 ) ) + y ∗ ( ( 0 1 1 0 ) ∗ ( 0 1 ) ) = x ∗ ( 0 1 ) + y ∗ ( 1 0 ) \begin{aligned} \begin{pmatrix}0&1\\1&0\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}0&1\\1&0\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}0&1\\1&0\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}0&1\\1&0\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}0&1\\1&0\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}0\\1\end{pmatrix}+y*\begin{pmatrix}1\\0\end{pmatrix} \end{aligned} (0110)(xy)=(0110)(x(10))+(0110)(y(01))=x((0110)(10))+y((0110)(01))=x(01)+y(10)

The basis vector ( 1 0 ) \begin{pmatrix}1\\0\end{pmatrix} (10) is shifted to ( 0 1 ) \begin{pmatrix}0\\1\end{pmatrix} (01) and basis vector ( 0 1 ) \begin{pmatrix}0\\1\end{pmatrix} (01) is shifted to ( 1 0 ) \begin{pmatrix}1\\0\end{pmatrix} (10) as shown in the graph.

Mirroring Matrix

If we combine the inverse matrix and diagonal mirroring matrix, we would get a mirroring of vector space along the -45° line. This matrix is ( 0 − 1 − 1 0 ) \begin{pmatrix}0&-1\\-1&0\end{pmatrix} (0110).

( 0 − 1 − 1 0 ) ∗ ( x y ) = ( 0 − 1 − 1 0 ) ∗ ( x ∗ ( 1 0 ) ) + ( 0 1 1 0 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( 0 − 1 − 1 0 ) ∗ ( 1 0 ) ) + y ∗ ( ( 0 − 1 − 1 0 ) ∗ ( 0 1 ) ) = x ∗ ( 0 − 1 ) + y ∗ ( − 1 0 ) \begin{aligned} \begin{pmatrix}0&-1\\-1&0\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}0&-1\\-1&0\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}0&1\\1&0\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}0&-1\\-1&0\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}0&-1\\-1&0\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}0\\-1\end{pmatrix}+y*\begin{pmatrix}-1\\0\end{pmatrix} \end{aligned} (0110)(xy)=(0110)(x(10))+(0110)(y(01))=x((0110)(10))+y((0110)(01))=x(01)+y(10)
Diagonal Mirroring Matrix

Sheering Matrix

Our basis vectors can also be transformed in more interesting ways like sheering when the vector space is no longer square or rectangle. Let’s see an example of sheering transformation matrix ( 1 1 0 1 ) \begin{pmatrix}1&1\\0&1\end{pmatrix} (1011).

( 1 1 0 1 ) ∗ ( x y ) = ( 1 1 0 1 ) ∗ ( x ∗ ( 1 0 ) ) + ( 1 1 0 1 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( 1 1 0 1 ) ∗ ( 1 0 ) ) + y ∗ ( ( 1 1 0 1 ) ∗ ( 0 1 ) ) = x ∗ ( 1 0 ) + y ∗ ( 1 1 ) \begin{aligned} \begin{pmatrix}1&1\\0&1\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}1&1\\0&1\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}1&1\\0&1\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}1&1\\0&1\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}1&1\\0&1\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}1\\0\end{pmatrix}+y*\begin{pmatrix}1\\1\end{pmatrix} \end{aligned} (1011)(xy)=(1011)(x(10))+(1011)(y(01))=x((1011)(10))+y((1011)(01))=x(10)+y(11)
Sheering Matrix

The new vector space after transformation is a parallelogram. Sheering transformation is not limited to just one basis vector. We can do a sheering transform for both e 1 e_1 e1 and e 2 e_2 e2 at the same time.

Rotation Matrix

Rotation is another common type of transformation. We can rotate the basis vectors by 90° anti-clockwise using the transformation matrix ( 0 − 1 1 0 ) \begin{pmatrix}0&-1\\1&0\end{pmatrix} (0110).

( 0 − 1 1 0 ) ∗ ( x y ) = ( 0 − 1 1 0 ) ∗ ( x ∗ ( 1 0 ) ) + ( 0 − 1 1 0 ) ∗ ( y ∗ ( 0 1 ) ) = x ∗ ( ( 0 − 1 1 0 ) ∗ ( 1 0 ) ) + y ∗ ( ( 0 − 1 1 0 ) ∗ ( 0 1 ) ) = x ∗ ( 0 1 ) + y ∗ ( − 1 0 ) \begin{aligned} \begin{pmatrix}0&-1\\1&0\end{pmatrix}*\begin{pmatrix}x\\y\end{pmatrix}&=\begin{pmatrix}0&-1\\1&0\end{pmatrix}*\left(x*\begin{pmatrix}1\\0\end{pmatrix}\right)+\begin{pmatrix}0&-1\\1&0\end{pmatrix}*\left(y*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\left(\begin{pmatrix}0&-1\\1&0\end{pmatrix}*\begin{pmatrix}1\\0\end{pmatrix}\right)+y*\left(\begin{pmatrix}0&-1\\1&0\end{pmatrix}*\begin{pmatrix}0\\1\end{pmatrix}\right)\\ &=x*\begin{pmatrix}0\\1\end{pmatrix}+y*\begin{pmatrix}-1\\0\end{pmatrix} \end{aligned} (0110)(xy)=(0110)(x(10))+(0110)(y(01))=x((0110)(10))+y((0110)(01))=x(01)+y(10)
Rotation Matrix

A more general case to rotate the basis vectors by any angle θ anti-clockwise is given by ( cos ⁡ θ sin ⁡ θ − sin ⁡ θ cos ⁡ θ ) \begin{pmatrix}\cos\theta&\sin\theta\\-\sin\theta&\cos\theta\end{pmatrix} (cosθsinθsinθcosθ).

Composite Transformation Matrix

It is also possible to apply transformation on the basis vectors more than once. For example, we can first do a 90° anti-clockwise rotation using ( 0 − 1 1 0 ) \begin{pmatrix}0&-1\\1&0\end{pmatrix} (0110), followed by a flipping along the vertical axis using ( − 1 0 0 1 ) \begin{pmatrix}-1&0\\0&1\end{pmatrix} (1001). The composite transformation is just the matrix product of the two basic transformation matrix.
( − 1 0 0 1 ) ∗ ( 0 − 1 1 0 ) = ( 0 1 1 0 ) \begin{pmatrix}-1&0\\0&1\end{pmatrix}*\begin{pmatrix}0&-1\\1&0\end{pmatrix}=\begin{pmatrix}0&1\\1&0\end{pmatrix} (1001)(0110)=(0110)
Composite Transformation Matrix

We can add on more matrices to the expression for more transformation steps. Note the order of operation in matrix multiplication matters. This is because matrix multiplications are not commutative, i.e. ( − 1 0 0 1 ) ∗ ( 0 − 1 1 0 ) ≠ ( 0 − 1 1 0 ) ∗ ( − 1 0 0 1 ) \begin{pmatrix}-1&0\\0&1\end{pmatrix}*\begin{pmatrix}0&-1\\1&0\end{pmatrix}\neq\begin{pmatrix}0&-1\\1&0\end{pmatrix}*\begin{pmatrix}-1&0\\0&1\end{pmatrix} (1001)(0110)=(0110)(1001). The later transformation matrix should always precede the earlier transformation matrix in multiplication expression.

Matrix transformation is a very important step in a lot of machine learning applications, especially image-related tasks. One good example is face recognition problem whereby you need to center and align the subject faces in the image captured.


(Inspired by Mathematics for Machine Learning lecture series from Imperial College London)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值