AI Knowledge Tree

Linear maps and matrices

Show every linear map between finite-dimensional spaces is a matrix once bases are fixed, and that composition is matrix multiplication.

⏱ 30 minPrerequisites:Span, independence, basis, dimension

Numbers are not the only things we multiply by scalars and add together; maps between vector spaces can behave the same way. When they do, a single rectangular array of numbers captures everything about them.

What a linear map is

A map T:V→WT: V \to W is linear if it respects the two vector-space operations:

T(u+v)=T(u)+T(v),T(αv)=α T(v),T(u + v) = T(u) + T(v), \qquad T(\alpha v) = \alpha\, T(v),

for all u,v∈Vu, v \in V and α∈R\alpha \in \mathbb{R}. The two conditions collapse into one: T(αu+βv)=αT(u)+βT(v)T(\alpha u + \beta v) = \alpha T(u) + \beta T(v). A linear map sends linear combinations to linear combinations, with the same coefficients.

Immediate consequences: T(0)=0T(0) = 0 (set α=0\alpha = 0), and T(−v)=−T(v)T(-v) = -T(v).

Every linear map is a matrix

Fix bases B={e1,…,en}\mathcal{B} = \{e_1, \dots, e_n\} of VV and C={f1,…,fm}\mathcal{C} = \{f_1, \dots, f_m\} of WW. By linearity, knowing TT on the basis is enough to know TT everywhere: any v=∑jxjejv = \sum_j x_j e_j gives T(v)=∑jxjT(ej)T(v) = \sum_j x_j T(e_j).

Each T(ej)T(e_j) is a vector in WW, so it expands in C\mathcal{C}: T(ej)=∑iaijfiT(e_j) = \sum_i a_{ij} f_i. Collect the coefficients into the m×nm \times n matrix A=[aij]A = [a_{ij}]. Then for any vv with coordinate vector x∈Rnx \in \mathbb{R}^n, the coordinate vector of T(v)T(v) in C\mathcal{C} is AxAx:

[T(v)]C=A [v]B.[T(v)]_{\mathcal{C}} = A\,[v]_{\mathcal{B}}.

The jj-th column of AA is the coordinate vector of T(ej)T(e_j).

This is the complete story: a linear map is a matrix, and the matrix depends on the choice of bases[1]. Switch bases and the matrix changes, but it represents the same map.

Composition is matrix multiplication

If T:U→VT: U \to V has matrix AA (in bases B,C\mathcal{B}, \mathcal{C}) and S:V→WS: V \to W has matrix BB (in bases C,D\mathcal{C}, \mathcal{D}), then the composition S∘T:U→WS \circ T: U \to W has matrix BABA.

Proof. For any uu with coordinate vector xx: (S∘T)(u)=S(T(u))(S \circ T)(u) = S(T(u)). The coordinate vector of T(u)T(u) is AxAx, and then SS sends it to B(Ax)=(BA)xB(Ax) = (BA)x. So the composite acts as BABA on coordinate vectors. ■\qquad\blacksquare

Matrix multiplication is not a formula chosen for convenience; it is the only rule for associating a matrix to a composition of linear maps[2].

The kernel and image

Two subspaces are attached to every linear map:

  • Kernel (null space): ker⁡T={v∈V:T(v)=0}\ker T = \{v \in V : T(v) = 0\}. It is a subspace of VV (if T(u)=T(v)=0T(u) = T(v) = 0, then T(u+v)=0T(u+v) = 0 and T(αu)=0T(\alpha u) = 0).
  • Image (column space): im⁡T={T(v):v∈V}\operatorname{im} T = \{T(v) : v \in V\}. It is a subspace of WW.

These are the null space and column space of the matrix AA in the chosen bases. The kernel measures how much TT collapses, and the image measures how much of WW it can reach: two quantifications the rank–nullity theorem connects in the next lesson.

A matrix is a linear map: it sends the square grid to a uniformly sheared grid, moving every point by the same rule.
A matrix is a linear map: it sends the square grid to a uniformly sheared grid, moving every point by the same rule.

Check it on arrays

The claim is that T(ej)T(e_j) lands in the jj-th column of the matrix, and that applying TT to a vector is matrix-vector multiplication.

python · numpy
import numpy as np

# Define T: R^3 -> R^2 by its action on the standard basis:
#   T(e1) = [1, 2], T(e2) = [0, -1], T(e3) = [3, 1]
A = np.array([[1.0, 0.0, 3.0],
              [2.0,-1.0, 1.0]])

# v = 2*e1 - e2 + 4*e3
v = np.array([2.0, -1.0, 4.0])
Tv = A @ v
print("T(v):", Tv)   # [1*2+0*(-1)+3*4, 2*2+(-1)*(-1)+1*4] = [14, 9]
print("manual:", 2*A[:,0] - A[:,1] + 4*A[:,2])  # same

# Composition: define S: R^2 -> R^2
B = np.array([[0.0, 1.0],
              [-1.0, 2.0]])

# (S o T)(v) = B @ (A @ v) = (B @ A) @ v
print("B@A@v:", B @ A @ v)
print("B@(A@v):", B @ (A @ v))  # identical

Both routes give the same result, confirming that composition equals matrix multiplication.

Exercises

Exercise 1. A linear map T:R2→R2T: \mathbb{R}^2 \to \mathbb{R}^2 acts on the standard basis by T(e1)=(1,2)T(e_1) = (1, 2) and T(e2)=(3,−1)T(e_2) = (3, -1). Write the matrix of TT and compute T(4,5)T(4, 5).

Solution

Step 1. The jj-th column of the matrix is the coordinate vector of T(ej)T(e_j), so

A=(132−1).A = \begin{pmatrix} 1 & 3 \\ 2 & -1 \end{pmatrix}.

Step 2. Apply the matrix to the coordinate vector (4,5)(4, 5), or equivalently use linearity T(4e1+5e2)=4 T(e1)+5 T(e2)T(4e_1 + 5e_2) = 4\,T(e_1) + 5\,T(e_2):

A(45)=(1⋅4+3⋅52⋅4+(−1)⋅5)=(193).A\begin{pmatrix} 4 \\ 5 \end{pmatrix} = \begin{pmatrix} 1\cdot 4 + 3\cdot 5 \\ 2\cdot 4 + (-1)\cdot 5 \end{pmatrix} = \begin{pmatrix} 19 \\ 3 \end{pmatrix}.

The two computations agree because the matrix encodes exactly the action of TT on the basis.

Exercise 2. Prove from the linearity axioms that if v1,…,vkv_1, \dots, v_k are linearly dependent, then T(v1),…,T(vk)T(v_1), \dots, T(v_k) are linearly dependent. Then give a one-line reason why this forces rank⁡(T)≤dim⁡V\operatorname{rank}(T) \le \dim V.

Solution

Step 1. Linear dependence means there are scalars c1,…,ckc_1, \dots, c_k, not all zero, with ∑icivi=0\sum_i c_i v_i = 0. Apply TT to both sides.

Step 2. By linearity TT carries the combination through with the same coefficients:

T ⁣(∑icivi)=∑ici T(vi)=T(0)=0.T\!\left(\sum_i c_i v_i\right) = \sum_i c_i\,T(v_i) = T(0) = 0.

The same nonzero coefficients cic_i now witness a dependence among the images, so T(v1),…,T(vk)T(v_1), \dots, T(v_k) are linearly dependent.

Step 3. The image is spanned by T(e1),…,T(en)T(e_1), \dots, T(e_n) where n=dim⁡Vn = \dim V, so it has at most nn independent vectors: rank⁡(T)=dim⁡(im⁡T)≤dim⁡V\operatorname{rank}(T) = \dim(\operatorname{im} T) \le \dim V.

Exercise 3 (code). Pick two random matrices AA (4×34 \times 3) and BB (2×42 \times 4). Verify on a batch of random input vectors that applying the composition S∘TS \circ T as B(Ax)B(Ax) equals applying the single matrix BABA, and that the matrix of the composite is exactly BABA.

Solution
python · numpy
import numpy as np

rng = np.random.default_rng(1)
A = rng.normal(size=(4, 3))   # T: R^3 -> R^4
B = rng.normal(size=(2, 4))   # S: R^4 -> R^2

X = rng.normal(size=(3, 100))         # 100 input vectors as columns
two_step = B @ (A @ X)                 # apply T then S
one_step = (B @ A) @ X                 # apply the composite matrix
assert np.allclose(two_step, one_step)

# The composite's matrix is BA: its j-th column is (S o T)(e_j).
BA = B @ A
for j in range(3):
    e_j = np.zeros(3); e_j[j] = 1.0
    assert np.allclose(B @ (A @ e_j), BA[:, j])
print("composite matrix shape:", BA.shape)

Every input gives the same output under both routes, and each column of BABA is the image of a basis vector under S∘TS \circ T, which is the definition of the composite's matrix.

The next lesson asks: given the matrix of TT, how much of the input does TT annihilate, and how much of the output does it fill?


References

  1. [1]Axler, S. (2015). Linear Algebra Done Right (3rd ed.), ch. 3. Springer. Linear maps and their matrices relative to chosen bases (doi:10.1007/978-3-319-11080-6).↩
  2. [2]Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press. Matrix multiplication as composition of maps.↩