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.
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 is linear if it respects the two vector-space operations:
for all and . The two conditions collapse into one: . A linear map sends linear combinations to linear combinations, with the same coefficients.
Immediate consequences: (set ), and .
Every linear map is a matrix
Fix bases of and of . By linearity, knowing on the basis is enough to know everywhere: any gives .
Each is a vector in , so it expands in : . Collect the coefficients into the matrix . Then for any with coordinate vector , the coordinate vector of in is :
The -th column of is the coordinate vector of .
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 has matrix (in bases ) and has matrix (in bases ), then the composition has matrix .
Proof. For any with coordinate vector : . The coordinate vector of is , and then sends it to . So the composite acts as on coordinate vectors.
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): . It is a subspace of (if , then and ).
- Image (column space): . It is a subspace of .
These are the null space and column space of the matrix in the chosen bases. The kernel measures how much collapses, and the image measures how much of it can reach: two quantifications the rank–nullity theorem connects in the next lesson.
Check it on arrays
The claim is that lands in the -th column of the matrix, and that applying to a vector is matrix-vector multiplication.
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)) # identicalBoth routes give the same result, confirming that composition equals matrix multiplication.
Exercises
Exercise 1. A linear map acts on the standard basis by and . Write the matrix of and compute .
Solution
Step 1. The -th column of the matrix is the coordinate vector of , so
Step 2. Apply the matrix to the coordinate vector , or equivalently use linearity :
The two computations agree because the matrix encodes exactly the action of on the basis.
Exercise 2. Prove from the linearity axioms that if are linearly dependent, then are linearly dependent. Then give a one-line reason why this forces .
Solution
Step 1. Linear dependence means there are scalars , not all zero, with . Apply to both sides.
Step 2. By linearity carries the combination through with the same coefficients:
The same nonzero coefficients now witness a dependence among the images, so are linearly dependent.
Step 3. The image is spanned by where , so it has at most independent vectors: .
Exercise 3 (code). Pick two random matrices () and (). Verify on a batch of random input vectors that applying the composition as equals applying the single matrix , and that the matrix of the composite is exactly .
Solution
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 is the image of a basis vector under , which is the definition of the composite's matrix.
The next lesson asks: given the matrix of , how much of the input does annihilate, and how much of the output does it fill?
References
- [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]Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press. Matrix multiplication as composition of maps.↩