Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 2: Linear Transformations and Matrices
Linear Algebra
01Week 1: Vectors and Linear Combinations
02Week 2: Linear Transformations and Matrices
03Week 3: Elimination and LU Factorization
04Week 4: Determinants
05Week 5: Vector Spaces, Independence, and Basis
06Week 6: The Four Fundamental Subspaces
07Week 7: Orthogonality and Projections
08Week 8: Least Squares and QR
09Week 9: Eigenvalues and Eigenvectors
10Week 10: Diagonalization and Markov Matrices
11Week 11: Differential Equations
12Week 12: Symmetric and Positive Definite Matrices
13Week 13: The SVD and Complex Matrices
14Week 14: The Fourier Matrix, FFT, and PCA
Week 02· Linear Algebra18 min read

Week 2: Linear Transformations and Matrices

✦Learning Outcomes
  • Define a linear transformation via additivity and homogeneity
  • Represent a linear transformation as matrix-vector multiplication
  • Interpret matrix multiplication as composition of transformations
  • Recognize rotation, scaling, and projection matrices geometrically
◆Prerequisites

Background knowledge assumed:

  • Vectors, linear combinations, and the dot product

Recommended: Review Week 1: Vectors and Linear Combinations before starting.

What Is a Linear Transformation#

A linear transformation (or linear map) is a function TTT from one vector space to another that respects the two vector-space operations: addition and scalar multiplication. Formally, TTT is linear when both of the following hold for all vectors u,vu, vu,v and every scalar ccc:

T(u+v)=T(u)+T(v)(additivity)T(u + v) = T(u) + T(v) \quad\text{(additivity)}T(u+v)=T(u)+T(v)(additivity) T(cu)=c T(u)(homogeneity)T(cu) = c\, T(u) \quad\text{(homogeneity)}T(cu)=cT(u)(homogeneity)

Together these say: “transform first, then add/scale” gives the same result as “add/scale first, then transform.” Equivalently, for any linear combination,

T(c1u+c2v)=c1T(u)+c2T(v).T(c_1 u + c_2 v) = c_1 T(u) + c_2 T(v).T(c1​u+c2​v)=c1​T(u)+c2​T(v).

Linear example: scaling. Define T ⁣:R2→R2T \colon \mathbb{R}^2 \to \mathbb{R}^2T:R2→R2 by T(x)=3xT(x) = 3xT(x)=3x. Then

T(u+v)=3(u+v)=3u+3v=T(u)+T(v),T(u + v) = 3(u + v) = 3u + 3v = T(u) + T(v),T(u+v)=3(u+v)=3u+3v=T(u)+T(v),

and T(cu)=3(cu)=c(3u)=c T(u)T(cu) = 3(cu) = c(3u) = c\, T(u)T(cu)=3(cu)=c(3u)=cT(u). Scaling by a fixed factor is linear. Reflection through the origin (T(x)=−xT(x) = -xT(x)=−x), rotation about the origin, and projection onto a line through the origin are also linear — we will meet them as matrices below.

Non-linear counterexample: adding a constant. Define S(x)=x+bS(x) = x + bS(x)=x+b for a fixed nonzero shift bbb (translation). Then

S(u+v)=u+v+b,S(u)+S(v)=(u+b)+(v+b)=u+v+2b.S(u + v) = u + v + b, \qquad S(u) + S(v) = (u + b) + (v + b) = u + v + 2b.S(u+v)=u+v+b,S(u)+S(v)=(u+b)+(v+b)=u+v+2b.

These agree only when b=0b = 0b=0. Translation moves the origin; linear maps must send 000 to 000, because T(0)=T(0⋅u)=0⋅T(u)=0T(0) = T(0 \cdot u) = 0 \cdot T(u) = 0T(0)=T(0⋅u)=0⋅T(u)=0. Any map that moves the origin fails linearity.

Why this matters. Linearity is the contract that lets us represent a whole map by a finite table of numbers — a matrix — and compose maps by multiplying those tables. Everything from solving Ax=bAx = bAx=b to changing bases and projecting data assumes this structure.


Matrices as Transformations#

An m×nm \times nm×n matrix AAA is a rectangular array of real numbers with mmm rows and nnn columns. Write its columns as vectors a1,a2,…,an∈Rma_1, a_2, \ldots, a_n \in \mathbb{R}^ma1​,a2​,…,an​∈Rm. For a vector x=(x1⋮xn)∈Rnx = \begin{pmatrix} x_1 \\ \vdots \\ x_n \end{pmatrix} \in \mathbb{R}^nx=​x1​⋮xn​​​∈Rn, the matrix–vector product is the linear combination of those columns weighted by the entries of xxx:

Ax=x1a1+x2a2+⋯+xnan.Ax = x_1 a_1 + x_2 a_2 + \dots + x_n a_n.Ax=x1​a1​+x2​a2​+⋯+xn​an​.

The result lives in Rm\mathbb{R}^mRm. In components, the iii-th entry of AxAxAx is the dot product of the iii-th row of AAA with xxx.

Worked example. Let

A=(1234),x=(5−1).A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \quad x = \begin{pmatrix} 5 \\ -1 \end{pmatrix}.A=(13​24​),x=(5−1​).

The columns are a1=(13)a_1 = \begin{pmatrix} 1 \\ 3 \end{pmatrix}a1​=(13​) and a2=(24)a_2 = \begin{pmatrix} 2 \\ 4 \end{pmatrix}a2​=(24​), so

Ax=5(13)+(−1)(24)=(515)+(−2−4)=(311).Ax = 5\begin{pmatrix} 1 \\ 3 \end{pmatrix} + (-1)\begin{pmatrix} 2 \\ 4 \end{pmatrix} = \begin{pmatrix} 5 \\ 15 \end{pmatrix} + \begin{pmatrix} -2 \\ -4 \end{pmatrix} = \begin{pmatrix} 3 \\ 11 \end{pmatrix}.Ax=5(13​)+(−1)(24​)=(515​)+(−2−4​)=(311​).

Linearity of x↦Axx \mapsto Axx↦Ax. By the column definition,

A(u+v)=(u1+v1)a1+⋯=Au+Av,A(cu)=c(Au).A(u + v) = (u_1 + v_1)a_1 + \cdots = Au + Av, \qquad A(cu) = c(Au).A(u+v)=(u1​+v1​)a1​+⋯=Au+Av,A(cu)=c(Au).

So every matrix defines a linear transformation TA(x)=AxT_A(x) = AxTA​(x)=Ax from Rn\mathbb{R}^nRn to Rm\mathbb{R}^mRm.

Every linear map has a matrix. Conversely, if T ⁣:Rn→RmT \colon \mathbb{R}^n \to \mathbb{R}^mT:Rn→Rm is linear, let e1,…,ene_1, \ldots, e_ne1​,…,en​ be the standard basis of Rn\mathbb{R}^nRn and form the matrix AAA whose jjj-th column is T(ej)T(e_j)T(ej​). Then for any x=x1e1+⋯+xnenx = x_1 e_1 + \cdots + x_n e_nx=x1​e1​+⋯+xn​en​,

T(x)=x1T(e1)+⋯+xnT(en)=Ax.T(x) = x_1 T(e_1) + \cdots + x_n T(e_n) = Ax.T(x)=x1​T(e1​)+⋯+xn​T(en​)=Ax.

So linear transformations Rn→Rm\mathbb{R}^n \to \mathbb{R}^mRn→Rm and m×nm \times nm×n matrices are two views of the same object: the map, and the table that stores where the basis goes.


Matrix Multiplication as Composition#

If BBB is n×pn \times pn×p and AAA is m×nm \times nm×n, the product ABABAB is the m×pm \times pm×p matrix defined so that

(AB)x=A(Bx)(AB)x = A(Bx)(AB)x=A(Bx)

for every x∈Rpx \in \mathbb{R}^px∈Rp. In words: applying ABABAB means apply BBB first, then apply AAA. Equivalently, ABABAB is the matrix of the composition A∘BA \circ BA∘B: the right-hand factor acts first, then the left-hand factor.

How to compute ABABAB. The jjj-th column of ABABAB is AAA times the jjj-th column of BBB. Equivalently, entry (i,j)(i,j)(i,j) of ABABAB is the dot product of row iii of AAA with column jjj of BBB. The product is defined only when the inner dimensions match (nnn above).

Numeric example. Compose two 2×22 \times 22×2 maps. Let

B=(1101)(shear),A=(2003)(scale).B = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} \quad\text{(shear)}, \qquad A = \begin{pmatrix} 2 & 0 \\ 0 & 3 \end{pmatrix} \quad\text{(scale)}.B=(10​11​)(shear),A=(20​03​)(scale).

Then

AB=(2003)(1101)=(2⋅1+0⋅02⋅1+0⋅10⋅1+3⋅00⋅1+3⋅1)=(2203).AB = \begin{pmatrix} 2 & 0 \\ 0 & 3 \end{pmatrix} \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} = \begin{pmatrix} 2\cdot 1 + 0\cdot 0 & 2\cdot 1 + 0\cdot 1 \\ 0\cdot 1 + 3\cdot 0 & 0\cdot 1 + 3\cdot 1 \end{pmatrix} = \begin{pmatrix} 2 & 2 \\ 0 & 3 \end{pmatrix}.AB=(20​03​)(10​11​)=(2⋅1+0⋅00⋅1+3⋅0​2⋅1+0⋅10⋅1+3⋅1​)=(20​23​).

Check on x=(11)x = \begin{pmatrix} 1 \\ 1 \end{pmatrix}x=(11​):

Bx=(21),A(Bx)=(43),(AB)x=(2203)(11)=(43).Bx = \begin{pmatrix} 2 \\ 1 \end{pmatrix}, \quad A(Bx) = \begin{pmatrix} 4 \\ 3 \end{pmatrix}, \quad (AB)x = \begin{pmatrix} 2 & 2 \\ 0 & 3 \end{pmatrix} \begin{pmatrix} 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 4 \\ 3 \end{pmatrix}.Bx=(21​),A(Bx)=(43​),(AB)x=(20​23​)(11​)=(43​).

Order matters. In general AB≠BAAB \neq BAAB=BA. Here

BA=(1101)(2003)=(2303)≠AB.BA = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 2 & 0 \\ 0 & 3 \end{pmatrix} = \begin{pmatrix} 2 & 3 \\ 0 & 3 \end{pmatrix} \neq AB.BA=(10​11​)(20​03​)=(20​33​)=AB.

Shear then scale is not the same as scale then shear. Composition of linear maps is associative — (AB)C=A(BC)(AB)C = A(BC)(AB)C=A(BC) — but not commutative.


Geometric Examples#

Three families of 2×22 \times 22×2 matrices appear constantly in geometry, graphics, and robotics. Each is linear, so each is completely determined by where it sends the standard basis vectors e1=(10)e_1 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}e1​=(10​) and e2=(01)e_2 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}e2​=(01​).

Rotation by angle θ\thetaθ (counterclockwise about the origin).

Rθ=(cos⁡θ−sin⁡θsin⁡θcos⁡θ).R_\theta = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix}.Rθ​=(cosθsinθ​−sinθcosθ​).

The first column is where e1e_1e1​ goes: (cos⁡θ,sin⁡θ)(\cos\theta, \sin\theta)(cosθ,sinθ). The second is where e2e_2e2​ goes: (−sin⁡θ,cos⁡θ)(-\sin\theta, \cos\theta)(−sinθ,cosθ). For θ=90∘=π/2\theta = 90^\circ = \pi/2θ=90∘=π/2, cos⁡90∘=0\cos 90^\circ = 0cos90∘=0 and sin⁡90∘=1\sin 90^\circ = 1sin90∘=1, so

R90∘=(0−110).R_{90^\circ} = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}.R90∘​=(01​−10​).

This sends (x,y)(x, y)(x,y) to (−y,x)(-y, x)(−y,x): the unit square’s corner (1,0)(1,0)(1,0) maps to (0,1)(0,1)(0,1), and (0,1)(0,1)(0,1) maps to (−1,0)(-1,0)(−1,0). Lengths and angles are preserved; only orientation in the plane changes.

Scaling (stretch or shrink along the axes).

(a00b)\begin{pmatrix} a & 0 \\ 0 & b \end{pmatrix}(a0​0b​)

sends (x,y)(x, y)(x,y) to (ax,by)(ax, by)(ax,by). If a=ba = ba=b, the map is a uniform scale (similarity). If a≠ba \neq ba=b, a circle becomes an ellipse elongated along the axis with larger absolute factor. For example, (2001)\begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix}(20​01​) doubles horizontal distances and leaves vertical ones unchanged. Negative aaa or bbb also reflects through the corresponding axis.

Projection onto the xxx-axis.

(1000)\begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}(10​00​)

sends (x,y)(x, y)(x,y) to (x,0)(x, 0)(x,0). Every point collapses vertically onto the horizontal axis. A unit square with vertices at (0,0)(0,0)(0,0), (1,0)(1,0)(1,0), (1,1)(1,1)(1,1), (0,1)(0,1)(0,1) becomes the segment from (0,0)(0,0)(0,0) to (1,0)(1,0)(1,0) (the top edge lands on the bottom). Projection is linear but not invertible: many inputs share the same output, and applying it twice is the same as applying it once (it is a projection operator: P2=PP^2 = PP2=P).

Acting on a simple shape. Take the unit square’s vertices as columns of a 2×42 \times 42×4 matrix of points (or a closed path with five points including the return to the start). Multiplying on the left by RθR_\thetaRθ​, by a diagonal scale matrix, or by the xxx-axis projection transforms every vertex the same way. The browser lab below rotates a square by 90∘90^\circ90∘ and plots original versus image — the same recipe works for scaling and projection.

These geometric maps are the building blocks of Week 3’s elementary matrices (row operations as left-multiplication) and of the four-subspace picture in Week 6 (kernel and range of AAA).

Exercise · Multiple choice

Which 2×2 matrix rotates every vector in the plane by 90° counterclockwise?

[[0,-1],[1,0]]
[[1,0],[0,1]]
[[0,1],[1,0]]
[[-1,0],[0,-1]]

Knowledge check#

Question 1 of 3

If T(u+v) = T(u) + T(v) and T(cu) = cT(u) for all vectors u, v and scalars c, T is called a ___ transformation.


Browser lab#

Apply a 90° rotation matrix to a square and plot the result.

python · runs in browser
import numpy as np
import matplotlib.pyplot as plt

theta = np.pi / 2
R = np.array([[np.cos(theta), -np.sin(theta)],
              [np.sin(theta),  np.cos(theta)]])

square = np.array([[0, 1, 1, 0, 0],
                    [0, 0, 1, 1, 0]])

rotated = R @ square

fig, ax = plt.subplots(figsize=(5, 5))
ax.plot(square[0], square[1], "o-", color="tab:blue", label="original")
ax.plot(rotated[0], rotated[1], "o-", color="tab:orange", label="rotated 90°")
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)
ax.set_aspect("equal")
ax.axhline(0, color="gray", linewidth=0.5)
ax.axvline(0, color="gray", linewidth=0.5)
ax.legend()
ax.set_title("A square before and after applying R")
plt.show()

print("R =\n", R)
← Previous
Week 1: Vectors and Linear Combinations
Next →
Week 3: Elimination and LU Factorization
On this page
  • What Is a Linear Transformation
  • Matrices as Transformations
  • Matrix Multiplication as Composition
  • Geometric Examples
  • Knowledge check
  • Browser lab