Ran Wei/ Linear Algebra
中文
Linear Algebra · Vectors and linear systems

Module 3Matrices and linear maps

Read a matrix by its columns, compose transformations, and distinguish linear from affine maps.

80 minYou need Modules 1 and 2

In this module you will

  • Match the dimensions of a matrix with its inputs and outputs
  • Build a matrix from the images of the coordinate vectors
  • Compose maps and apply the transpose rule
1

A matrix as a rule for vectors

A linear map preserves addition and scalar multiplication. The two properties combine to give T(au+bv)=aT(u)+bT(v).T(a\mathbf u+b\mathbf v)=aT(\mathbf u)+bT(\mathbf v)\mathclose{\text{.}} In particular, it sends zero to zero. A matrix with mm rows and nn columns sends vectors in Rn\mathbb R^n to vectors in Rm.\mathbb R^m\mathclose{\text{.}} Its columns say where the coordinate vectors go.

Example 3.1Build the matrix of a shear✓ Checked

Let T(x,y)=(x+2y,y).T(x,y)=(x+2y,y)\mathclose{\text{.}} The first coordinate vector goes to (1,0)(1,0) and the second to (2,1).(2,1)\mathclose{\text{.}} The matrix therefore has columns (1,0)T(1,0)^\mathsf T and (2,1)T.(2,1)^\mathsf T\mathclose{\text{.}} At (0,3)(0,3) its output is (6,3),(6,3)\mathclose{\text{,}} three times the second column.

Try it

Apply a matrix to the square and to (1,1)T.(1,1)^\mathsf T\mathclose{\text{.}} Start with the identity, then try a shear and a matrix with dependent columns. Notice what happens to the square.

2

Composition and transpose

To apply BB first and AA second, form AB.AB\mathclose{\text{.}} Its jjth column is AA applied to column jj of B.B\mathclose{\text{.}} The inner dimensions must agree. If AA is m×nm\times n and BB is n×p,n\times p\mathclose{\text{,}} then ABAB is m×p.m\times p\mathclose{\text{.}}

The transpose swaps rows with columns. At the entry level, (AB)ij=∑kAikBkj.(AB)_{ij}=\sum_k A_{ik}B_{kj}\mathclose{\text{.}} Switching ii and jj gives (AB)T=BTAT.(AB)^\mathsf T=B^\mathsf TA^\mathsf T\mathclose{\text{.}} The order reverses.

Example 3.2A scale and a shear✓ Checked

Let S=(2001)S=\begin{pmatrix}2&0\\0&1\end{pmatrix} and H=(1101).H=\begin{pmatrix}1&1\\0&1\end{pmatrix}\mathclose{\text{.}} On (0,1),(0,1)\mathclose{\text{,}} shearing then scaling gives (2,1),(2,1)\mathclose{\text{,}} while scaling then shearing gives (1,1).(1,1)\mathclose{\text{.}} Both compositions exist and give different maps.

3

Affine maps

A map of the form Ax+bA\mathbf x+\mathbf b is affine. Its translation term moves every output by the same amount. It is linear exactly when b=0.\mathbf b=\mathbf 0\mathclose{\text{.}} If coordinates represent points on a map, translating the origin changes positions but keeps every displacement transformed by A.A\mathclose{\text{.}}

Compute itCompare the two products
Python
from sympy import Matrix

scale = Matrix([[2, 0], [0, 1]])
shear = Matrix([[1, 1], [0, 1]])
print((scale * shear).tolist())
print((shear * scale).tolist())
Output
[[2, 2], [0, 1]]
[[2, 1], [0, 1]]
4

Exercises

Exercise 3.1★Shapes

If AA is 4×24\times2 and BB is 2×3,2\times3\mathclose{\text{,}} give the shape of AB.AB\mathclose{\text{.}} Does BABA exist?

Show solution✓ Checked

ABAB maps R3\mathbb R^3 through R2\mathbb R^2 to R4,\mathbb R^4\mathclose{\text{,}} so the shape is 4×3.4\times3\mathclose{\text{.}} BABA has inner dimensions 33 and 4,4\mathclose{\text{,}} so it is undefined.

Exercise 3.2★★Reflection

Find the matrix for reflection across the line y=x.y=x\mathclose{\text{.}}

Show solution✓ Checked

The reflection swaps the coordinates, hence swaps the two coordinate vectors. Its matrix is (0110).\begin{pmatrix}0&1\\1&0\end{pmatrix}\mathclose{\text{.}} Applying it twice gives the identity.

Exercise 3.3★★★Recognise a translation

Show that F(x,y)=(x+1,2y)F(x,y)=(x+1,2y) is affine. What transformation does it apply to a displacement (h,k)?(h,k)\mathclose{\text{?}}

Show solution✓ Checked

Write F(x)=diag⁡(1,2)x+(1,0)T.F(\mathbf x)=\operatorname{diag}(1,2)\mathbf x+(1,0)^\mathsf T\mathclose{\text{.}} The difference F(x+h,y+k)−F(x,y)F(x+h,y+k)-F(x,y) is (h,2k).(h,2k)\mathclose{\text{.}} The translation cancels from the difference.

5

Check yourself

1
Which map is linear?
2
In ABv,AB\mathbf v\mathclose{\text{,}} which map is applied to the vector first?
3
What is the shape of the transpose of a 3×53\times5 matrix?
Finished this module?