Linear Transformations

This post is the first in a 3-part series on building geometric intuition about key concepts in linear algebra.

  1. Linear Transformations (this)
  2. Eigendecomposition
  3. Singular Value Decomposition (SVD)
In [1]:

Linear Transformation by Matrix Multiplication

vector $x$ ( in pink ) and the unit circle ( in red )

$M x = y$

Dilation (stretch / shrink)

$$ \begin{pmatrix} 3 & 0 \\ 0 & 1 \\ \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} 3 \\ 1 \\ \end{pmatrix} $$
In [3]:

Reflection around y-axis

$$ \begin{pmatrix} -1 & 0 \\ 0 & 1 \\ \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} -1 \\ 1 \\ \end{pmatrix} $$
In [4]:

Projection

$$ \begin{pmatrix} 3 & 0 \\ 0 & 0 \\ \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} 3 \\ 0 \\ \end{pmatrix} $$
In [5]:

We've collapsed the vector from 2-D space onto the X axis.

What's the rank of the matrix M?

In [6]:
np.linalg.matrix_rank(M)
Out[6]:
1

Rotation

$$ \begin{pmatrix} 0 & -1 \\ 1 & 0 \\ \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} -1 \\ 1 \\ \end{pmatrix} $$
In [8]:

Can you spot the difference between the above picture and the reflection around y-axis?

Shear in the x-direction

$$ \begin{pmatrix} 1 & 1 \\ 0 & 1 \\ \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} 2 \\ 1 \\ \end{pmatrix} $$
In [9]:

Shear in the y-direction

$$ \begin{pmatrix} 1 & 0 \\ 1 & 1 \\ \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} 1 \\ 2 \\ \end{pmatrix} $$
In [10]:

Translation

Translation is not a linear transformation, but an affine transformation as it does not preserve the origin. However, by translating the problem from 2D to 3D (in homegenous coordinates), translation in 2D can be expressed as a shear in 3D. For details, please refer this .