Linear Transformations

Vector Spaces

A vector space is a set of vectors that satisfy certain algebraic properties.

The real numbers (any numbers on the number line) are an example of a vector space.

Vector Spaces

The dimension of a vector space is equal to the number of components we need to describe a vector in it.

The real numbers are a one-dimensional vector space.

The set of all vectors that look like \(\begin{bmatrix} x\\y \end{bmatrix}\) form a two-dimensional space.

Vector Spaces

If two vector spaces have the same dimension, we think of them as being equivalent. The vectors in them may look different, but they are algebraically identical, meaning they'll all follow the same rules and can be operated on together.

Vector Spaces

We can't add \(\begin{bmatrix} 1\\2 \end{bmatrix} + \begin{bmatrix} 3\\4\\5 \end{bmatrix}\) because the vectors come from two different spaces, but we can add $$ \begin{bmatrix} 1\\2 \end{bmatrix} + \begin{bmatrix} 3\\4 \end{bmatrix} = \begin{bmatrix} 1+3\\2+4 \end{bmatrix} = \begin{bmatrix} 4\\6 \end{bmatrix}$$ because both vectors are from the two-dimensional space.

Functions on Vector Spaces

The kind of functions you've seen before in high school are actually functions from a one-dimensional space to itself. They take in a real number, and output a real number.

The key is to think of the function as transforming the entire space at once, instead of one each number at a time.

Example:
\(f(x) = 3x\) multiplies every number we plug into it by 3. It stretches the whole space by a factor of 3.


Functions on Vector Spaces

We saw in the last class that we can also define a function on two dimensional spaces (the Cartesian plane).

Example:
\(f\left( \begin{bmatrix}x\\y\end{bmatrix} \right) = \begin{bmatrix}2x\\y\end{bmatrix}\) stretches the entire plane horizontally by a factor of 2. Any images in the plane are stretched too!


Linear Transformations

When a function like this leaves the origin (0,0) where it was, the function is called a linear transformation.

Any linear transformation can be represented by a matrix.

That is, we need $$ f\left( \begin{bmatrix}0\\0\end{bmatrix} \right) = \begin{bmatrix}0\\0\end{bmatrix} $$

Linear Transformations

When a function like this leaves the origin (0,0) where it was, the function is called a linear transformation.

Any linear transformation can be represented by a matrix.

Example:
\(f\left( \begin{bmatrix}x\\y\end{bmatrix} \right) = \begin{bmatrix}2x\\y\end{bmatrix}\) is a linear transformation, because $$ f\left( \begin{bmatrix}0\\0\end{bmatrix} \right) = \begin{bmatrix}2(0)\\0\end{bmatrix}= \begin{bmatrix}0\\0\end{bmatrix} $$


Linear Transformations

When a function like this leaves the origin (0,0) where it was, the function is called a linear transformation.

Any linear transformation can be represented by a matrix.

Example:
\(f\left( \begin{bmatrix}x\\y\end{bmatrix} \right) = \begin{bmatrix}x+2\\y\end{bmatrix}\) is NOT a linear transformation, because $$ f\left( \begin{bmatrix}0\\0\end{bmatrix} \right) = \begin{bmatrix}0+2\\0\end{bmatrix}= \begin{bmatrix}2\\0\end{bmatrix} $$


Linear Transformations

To find the matrix of a transformation, we just need to see what happens to the vectors \(\begin{bmatrix}1\\0\end{bmatrix}\) and \(\begin{bmatrix}0\\1\end{bmatrix}\).

The results give us the first and second column of our matrix, respectively.

Linear Transformations

Example: We'll find the matrix of \(f\left( \begin{bmatrix}x\\y\end{bmatrix} \right) = \begin{bmatrix}2x\\y\end{bmatrix}\)

First find where the vectors \([1,0]\) and \([0,1]\) are sent to: $$ {\scriptsize f\left( \begin{bmatrix}1\\0\end{bmatrix} \right) = \begin{bmatrix}2(1)\\0\end{bmatrix}= \begin{bmatrix}2\\0\end{bmatrix} \ \mbox{ and } \ \ f\left( \begin{bmatrix}0\\1\end{bmatrix} \right) = \begin{bmatrix}2(0)\\1\end{bmatrix}= \begin{bmatrix}0\\1\end{bmatrix} }$$ then build the matrix: $$ \begin{bmatrix}2&0\\0&1\end{bmatrix}$$


Linear Transformations

Example: What does this transformation do? $$ \begin{bmatrix}2&0\\0&1\end{bmatrix}$$
The x-coordinate of every point is moved twice as far away from the origin as it was. The y-coordinate doesn't change.


Linear Transformations

Example: The whole plane is stretched out, horizontally, by a factor of 2: $$ \begin{bmatrix}2&0\\0&1\end{bmatrix}$$


Linear Transformations

Example: The stretching affects everything in the plane, too: $$ \begin{bmatrix}2&0\\0&1\end{bmatrix}$$


Linear Transformations

Example: We'll find the matrix of \(f\left( \begin{bmatrix}x\\y\end{bmatrix} \right) = \begin{bmatrix}2x+y\\2y\end{bmatrix}\)

First find where the vectors \([1,0]\) and \([0,1]\) are sent to: $$ {\tiny f\left( \begin{bmatrix}1\\0\end{bmatrix} \right) = \begin{bmatrix}2(1) + 0 \\2(0) \end{bmatrix}= \begin{bmatrix}2\\0\end{bmatrix} \ \mbox{ and } \ \ f\left( \begin{bmatrix}0\\1\end{bmatrix} \right) = \begin{bmatrix}2(0) + 1\\2(1)\end{bmatrix}= \begin{bmatrix}1\\2\end{bmatrix} }$$ then build the matrix: $$ \begin{bmatrix}2&1\\0&2\end{bmatrix}$$


Linear Transformations

Example: This matrix does something a little more complicated. It stretches and 'shears'. $$ \begin{bmatrix}2&1\\0&2\end{bmatrix}$$


Linear Transformations

Once we know this trick, we can transform an image however we want to.
Example: We have an image, and want to reflect it (across a horizontal line) so it is upside down.


Linear Transformations

Once we know this trick, we can transform an image however we want to.
Example: Picture the image in the plane, along the horizontal axis. We want to flip the image over this axis.


Linear Transformations

Once we know this trick, we can transform an image however we want to.
Example: What happens to the points/vectors \(\color{blue}{(1,0)}\) and \(\color{red}{(0,1)}\) when we flip over the horizontal axis?
\(\color{blue}{(1,0)}\) doesn't move, but \(\color{red}{(0,1)}\) ends up at \((0,-1)\)


Linear Transformations

Once we know this trick, we can transform an image however we want to.
Example: What happens to the points/vectors \(\color{blue}{(1,0)}\) and \(\color{red}{(0,1)}\) when we flip over the horizontal axis?
\(\color{blue}{(1,0)}\) doesn't move, but \(\color{red}{(0,1)}\) ends up at \((0,-1)\)
So the function of our reflection does this: $$ {\scriptsize f\left( \begin{bmatrix}1\\0\end{bmatrix} \right) = \begin{bmatrix}1\\0\end{bmatrix} \ \mbox{ and } \ \ f\left( \begin{bmatrix}0\\1\end{bmatrix} \right) = \begin{bmatrix}0\\-1\end{bmatrix} }$$ and our matrix is $$ \begin{bmatrix}1&0 \\ 0&-1\end{bmatrix}$$


Linear Transformations

What about another transformation?
Example: Let's rotate the triangle by 90 degrees (quarter turn) counterclockwise:


Linear Transformations

What about another transformation?
Example: Again, see where the vectors \(\color{blue}{(1,0)}\) and \(\color{red}{(0,1)}\) go:


Linear Transformations

What about another transformation?
Example: Again, see where the vectors \(\color{blue}{(1,0)}\) and \(\color{red}{(0,1)}\) go.

This time, they both changed: $$ {\scriptsize f\left( \begin{bmatrix}1\\0\end{bmatrix} \right) = \begin{bmatrix}0\\1\end{bmatrix} \ \mbox{ and } \ \ f\left( \begin{bmatrix}0\\1\end{bmatrix} \right) = \begin{bmatrix}-1\\0\end{bmatrix} }$$ so our matrix is $$ \begin{bmatrix}0 & -1 \\ 1 & 0\end{bmatrix}$$


Stretching/Scaling/Shrinking

The matrix

$$ \begin{bmatrix}a&0\\0&1\end{bmatrix}$$
will stretch everything horizontally by a factor of \(a\).

Stretching/Scaling/Shrinking

The matrix

$$ \begin{bmatrix}1&0\\0&b\end{bmatrix}$$
will stretch everything vertically by a factor of \(b\).

Stretching/Scaling/Shrinking

The matrix

$$ \begin{bmatrix}a&0\\0&b\end{bmatrix}$$
will stretch everything horizontally by a factor of \(a\) and vertically by a factor of \(b\).

Rotation

The matrix

$$ \begin{bmatrix}\cos \theta&-\sin \theta\\\sin \theta&\cos \theta\end{bmatrix}$$
will rotate the plane (around the origin) by an angle of \(\theta\), counterclockwise.

Reflecting

The matrix

$$ \begin{bmatrix}-1&0\\0&1\end{bmatrix}$$
will reflect the plane over the y-axis.

Reflecting

The matrix

$$ \begin{bmatrix}1&0\\0&-1\end{bmatrix}$$
will reflect the plane over the x-axis.

Reflecting

The matrix

$$ \begin{bmatrix}-1&0\\0&-1\end{bmatrix}$$
will reflect the plane over the x-axis and y-axis... hey, that's a rotation!

(In fact, any two reflections, over any lines, will be some rotation).

Reflecting

The matrix

$$ \begin{bmatrix}-1&0\\0&-1\end{bmatrix}$$
will reflect the plane over the x-axis and y-axis... hey, that's a rotation!

(In fact, any two reflections, over any lines, will be some rotation).

Projecting

The matrix

$$ \begin{bmatrix}0&0\\0&1\end{bmatrix}$$
will project the plane onto the y-axis. It sets all x-coordinates to 0, and keeps y-coordinates where they were.

Projecting

The matrix

$$ \begin{bmatrix}1&0\\0&0\end{bmatrix}$$
will project the plane onto the x-axis. It sets all y-coordinates to 0, and keeps x-coordinates where they were.

Projecting

The matrix

$$ \begin{bmatrix}0.5&0.5\\0.5&0.5\end{bmatrix}$$
will project the plane onto the line $y=x$, the diagonal line through the origin at an angle of \(45^\circ\) to the x-axis.

Shearing

The matrix

$$ \begin{bmatrix}1&a\\0&1\end{bmatrix}$$
will shear horizontally by a factor of \(a\).

Shearing

The matrix

$$ \begin{bmatrix}1&0\\a&1\end{bmatrix}$$
will shear vertically by a factor of \(a\).

Detecting a Projection

There's a trick to figure out if a matrix is a projection or just something that changes shapes. If we have a matrix like this: $$ \begin{bmatrix} a&b\\c&d \end{bmatrix} $$ and $$ad - bc = 0$$ then the matrix is some projection onto a line.
Example: $$ \begin{bmatrix}1 & 2\\3 & 6\end{bmatrix} $$ is a projection, since $$ (1)(6) - (2)(3) = 0$$

Detecting a Projection

There's a trick to figure out if a matrix is a projection or just something that changes shapes. If we have a matrix like this: $$ \begin{bmatrix} a&b\\c&d \end{bmatrix} $$ and $$ad - bc = 0$$ then the matrix is some projection onto a line.
Example: $$ \begin{bmatrix}1 & 3\\3 & 6\end{bmatrix} $$ is NOT a projection, since $$ (1)(6) - (3)(3) = -3 \neq 0$$

Two Dimensional Transformation Applet

To experiment with more matrices, go to

The Linear Transformation Applet