Matrices: Functions and Geometry - drnickmines/MinesLinearAlgebra GitHub Wiki

We've learned the basics of matrices and operations, especially matrix multiplication. Here, we will see a different way to interpret matrix multiplication. This leads to a set of matrices we can use for geometric representations of matrix multiplication.

The topics in this lesson are particularly useful in fields where we represent images, like computer graphics and 3D printing. In these fields, matrix multiplication is used to move, stretch, rotate, and visualize objects.

Linear Transformations (Functions)

A function is an object that assigns an output for any given input. Here are two quick examples:

  • $\large f(x)=3x$. This is a linear function that takes a real number as an input and spits out a real number as an output. We say $\large f: \mathbb{R}\rightarrow\mathbb{R}$.
  • $\large f(\vec{x}) = \left<x_1+x_2,2x_1,3x_2\right>$, with $\large f:\mathbb{R}^2\rightarrow\mathbb{R}^3$.

If we think about it, we can consider $\large A\vec{x}$ as a function too:

$$\large f(\vec{x})=A\vec{x}$$

Definition: We call the function $\large A\vec{x}$ a linear transformation, and we typically write it as $\large T(\vec{x})$. If $\large A$ is $\large m\times n$, then $\large T:\mathbb{R}^n\rightarrow\mathbb{R}^m$.

As an example, let's define $\large A$ and $\large \vec{u}$ as follows:

$$\large A=\begin{bmatrix} 1 & -3 \\ 3 & 5\\ -1 & 7\\ \end{bmatrix}, \vec{u}=\begin{bmatrix} 2\\ -1\\ \end{bmatrix} $$

Then we can compute $\large T(\vec{u})$:

$$\large T(\vec{u}) = A\vec{u}=\begin{bmatrix} 1 & -3 \\ 3 & 5\\ -1 & 7\\ \end{bmatrix}\begin{bmatrix} 2\\ -1\\ \end{bmatrix}=\begin{bmatrix} 5 \\ 1 \\ -9\\ \end{bmatrix} $$

Note

Thinking of matrix multiplication as a function lets us think of $\large A$ as something that acts on vectors. We can consider the question: what does $\large A$ do to vectors?

Properties of Linear Transformations

The following are true for any linear transformation:

  • $\large T(\vec{0})=\vec{0}$
  • $\large T(a\vec{u}+b\vec{v})=aT(\vec{u})+bT(\vec{v})$ (this is the defining property of a linear transformation)
  • Any linear transformation from $\large \mathbb{R}^n$ to $\large \mathbb{R}^m$ can be written as $\large T(\vec{x})=A\vec{x}$.

Linear Transformations and Geometry

As mentioned, in fields such as computer graphics, we use linear transformations to manipulate shapes and images. We'll learn a general principle for visualizing the effect of a matrix on a vector, and then we'll see two specific common transformations.

Visualizing Matrices

Principle: A linear transformation $\large A$ is completely defined by what it does to the unit basis vectors. The first column of $\large A$ is where $\large A$ sends $\large \hat{\imath}$, and the second column tells us exactly where $\large \hat{\jmath}$ lands.

Suppose we have the following $\large A$:

$$\large \begin{bmatrix} 2 & 1\\ 3 & 2 \\ \end{bmatrix} $$

This matrix is the linear transformation that takes $\large \hat{\imath}$ to $\large \left<2,3\right>$ and $\large \hat{\jmath}$ to $\large \left<1,2\right>$. Here's the image of those transformations:

basis transform

Common Transformations

There are a few linear transformations of note that we can visualize geometrically.

  • A shear transformation:

$$\large A=\begin{bmatrix} 1 & 2 \\ 0 & 1\\ \end{bmatrix}, \quad\quad \large T(\vec{x})=A\vec{x} $$

By the guiding principle above, we see that $\large A$ will not change $\large\hat{\imath}$, but it will take $\large \hat{\jmath}$ to $\large \left<2,1\right>$.

What does this mean for vectors that are not the standard unit basis vectors? If we take the points $\large (0,0),(1,0), (0,1), (1,1)$ and use them as inputs into $\large T$, we get $\large (0,0), (1,0), (2,1), (3,1)$. In the image below, we can see the effect of multiplying by $\large A$. The red dots are the inputs, and the blue dots are the outputs:

genSol

Remember that we can think of $\large A\vec{x}$ as a linear combination of the columns of $\large A$ (see Matrix Basics). With this view, the shear transformation above looks like:

$$\large T(\vec{u})=\begin{bmatrix} 1 & 2 \\ 0 & 1\\ \end{bmatrix}\begin{bmatrix} u_1 \\ u_2 \\ \end{bmatrix}= \begin{bmatrix} 1 \\ 0 \\ \end{bmatrix}u_1+\begin{bmatrix} 2 \\ 1 \\ \end{bmatrix}u_2=\begin{bmatrix} u_1+2u_2 \\ u_2 \\ \end{bmatrix} $$

If the coordinates $\large u_1$ and $\large u_2$ are positive, we see that the matrix has the effect of increasing the $\large x$ coordinate with no effect on the $\large y$ coordinate.

  • A rotation transformation:

$$\large A=\begin{bmatrix} 0 & -1 \\ 1 & 0\\ \end{bmatrix}, \quad\quad \large T(\vec{x})=A\vec{x} $$

What does this matrix do to vectors? Again, we return to the guiding principle. This $\large A$ takes $\large \hat{\imath}$ to $\large \hat{\jmath}$, and it takes $\large \hat{\jmath}$ to $\large-\hat{\imath}$.

The image shows a set of three points (in red) and their transformed images in blue:

rotation

We see that $\large A$ rotates points 90 degrees counterclockwise.

A more general rotation matrix is:

$$\large \begin{bmatrix} \cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta)\\ \end{bmatrix} $$

This matrix rotates vectors $\large \theta$ degrees counterclockwise.

Multiple Transformations

Consider the product:

$$\large \begin{bmatrix} \cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta)\\ \end{bmatrix}\begin{bmatrix} 1 & 3 \\ 0 & 1\\ \end{bmatrix}\begin{bmatrix} 1 \\ 1 \\ \end{bmatrix} $$

This is one transformation followed by another. It will first shear the vector and then will rotate it. In the language of linear transformations, this corresponds to a composition of functions. If we use $\large \theta = \frac{\pi}{3}$, we get the following (the initial vector in red, the sheared vector in blue, and the sheared and then rotated vector in green):

composition

Section Outcomes

I can:

  • Represent matrix multiplication as a linear transformation.
  • Use the properties of linear transformations.
  • Recognize and use shear and rotation matrices to transform vectors.
⚠️ **GitHub.com Fallback** ⚠️