II.8 · Linear Algebra
A matrix is a rule for moving every vector—and the whole coordinate grid.
Drag the two image columns. The same exact rule moves an arbitrary vector, reshapes a unit square, preserves or reverses orientation, and sometimes collapses the plane.
Drag the matrix columns; reshape the coordinate paper
This is linear and fixes the origin. Its columns are the two basis images; det A is 1, so orientation is preserved.
- matrix A
- 2×2 [1, 1; 0, 1]
- first column / image of e₁
- (1, 0)
- second column / image of e₂
- (1, 1)
- input vector
- (2, 1)
- output vector
- (3, 1)
- image of the origin
- (0, 0)
- orientation and area scale
- 1
Exact expressions use =. Rounded computations use ≈. Every view uses this same state.
This is linear and fixes the origin. Its columns are the two basis images; det A is 1, so orientation is preserved.
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
from −4 to 4, up to 2 decimal places
Begin with the Shear preset. Move while leaving the columns fixed: the output follows the deformed grid. Then move itself. Predict which family of grid lines changes before you drag. Finally choose Affine shift and inspect where the origin goes.
Intuition: specify two directions, determine the whole plane
Every vector in the plane is a weighted combination of the standard basis vectors,
A linear transformation respects those same weights. Once we choose the two images and , every other output is forced. The stage draws those images as draggable columns and transforms the complete grid with them.
Definition
A transformation is linear when
Writing the two image vectors as columns gives a matrix
The transformation is then . A linear map always fixes the origin because .
Mechanics: read the transformed grid
Vertical grid lines consist of points with one fixed weight while varies. Their images remain parallel to the second matrix column. Horizontal grid lines remain parallel to the first column. A shear slants one family; unequal scaling changes spacing; a rotation turns both families; a reflection changes handedness.
When the columns become dependent, two grid directions collapse onto one direction. Distinct inputs can then share the same output. The stage keeps this exact singular case visible instead of nudging the columns apart.
Derivation: the columns control every vector
Apply linearity to the basis expansion:
This is why dragging a column moves the grid and the arbitrary output through one state. The picture is not a separate geometric approximation of the formula.
Linear versus affine
An affine transformation has the form
It keeps the parallel-line deformation supplied by , then translates every output by the same . If , the origin moves and the full map is not linear. The stage marks that moved origin explicitly; it does not hide translation inside an extra matrix coordinate.
Worked examples
For
the columns are and . Therefore . The unit square becomes a slanted parallelogram, but its two directions remain independent.
Inspect the worked calculation
Read the columns as Ae₁ and Ae₂.
- matrix A
- 2×2 [1, 1; 0, 1]
- first column / image of e₁
- (1, 0)
- second column / image of e₂
- (1, 1)
- input vector
- (2, 1)
- output vector
- (3, 1)
- image of the origin
- (0, 0)
- orientation and area scale
- 1
The quarter-turn preset sends upward and left. The reflection preset reverses one basis direction. The singular preset uses proportional columns, so the transformed square has zero area and the full grid collapses to one direction.
Executable reference code
The pedagogical Python file represents a small matrix by rows and computes exact rational outputs. The NumPy version uses the matrix multiplication operator and checks both the transformed basis and arbitrary vectors.
from fractions import Fraction as F
def transform(a, x):
if not a or len(a[0]) != len(x):
raise ValueError("matrix columns must match the input length")
return tuple(sum((entry * value for entry, value in zip(row, x)), F(0)) for row in a)
def affine(a, x, translation):
linear = transform(a, x)
if len(linear) != len(translation):
raise ValueError("translation must match the output length")
return tuple(value + shift for value, shift in zip(linear, translation))
A = ((F(1), F(1)), (F(0), F(1)))
assert transform(A, (F(0), F(0))) == (0, 0)
assert transform(A, (F(2), F(1))) == (3, 1)
assert affine(A, (F(0), F(0)), (F(2), F(-1))) == (2, -1)import numpy as np
A = np.array([[1.0, 1.0], [0.0, 1.0]])
x = np.array([2.0, 1.0])
b = np.array([2.0, -1.0])
np.testing.assert_allclose(A @ x, [3.0, 1.0])
np.testing.assert_allclose(A @ np.zeros(2), np.zeros(2))
np.testing.assert_allclose(A @ np.zeros(2) + b, b)Explore
Make the first column twice as long without changing the second. Turn both columns by a quarter-turn. Reverse exactly one column. Make the columns equal, then opposite. For each state, predict the grid, output, origin, and orientation before reading the inspector. Add a translation only after you can explain the linear deformation.
Common mistakes
A matrix is not merely a table of coefficients: here its columns are geometric images. Rows do not show where the basis vectors land. A translation is not linear just because it appears next to a matrix. A singular map is still a valid linear map; it simply loses directions. Finally, a transformed grid need not keep right angles or unit spacing.
Numerical considerations
Entered decimals become exact rational values, so exact collapse means exact dependence rather than a hidden epsilon decision. Display coordinates are floating-point visual proxies derived from that state. In measured data, nearly dependent columns can behave sensitively even when they are exactly independent; that conditioning question is distinct from exact singularity.
Engineering and ML connections
Graphics pipelines use matrices for rotation, reflection, scale, and shear, then add translations for placement. A linear layer in a neural network similarly maps input directions to output directions; its bias makes the layer affine. Thinking in columns reveals what each input feature contributes before later chapters study larger systems and rank.
Exercises
Summary and checkpoints
A linear map is determined by the images of a basis, uses the same weights for every vector, and fixes the origin. Check that you can read rotations, reflections, shears, scalings, and collapses from two columns, and distinguish from . Next we make the matrix–vector arithmetic explicit.