In 1.1 Vectors, Linear Combinations & Span a vector was a single arrow, and the state of a simulation was one big vector. Every simulation also does something to its state on every step: a rigid body’s orientation gets rotated, a camera projects 3D points onto the screen, and a fluid solver’s diffusion step averages neighbors. Most of these operations are linear transformations, and every linear transformation is a matrix. Your first course probably treated a matrix as a rectangle of numbers to row-reduce. This lesson is about what that rectangle does: a matrix is a function that moves every vector in space at once, and its columns tell you exactly how. Once you can see a matrix as a motion, systems of differential equations like turn into pictures of flows instead of symbol-pushing.
Transcript
- In your first linear algebra course, a matrix was a grid of numbers you row-reduced. Today we see what a matrix really is: a machine that moves space.
- Think of a transformation as a function. You feed in a vector, and it hands you back another vector. The word transformation invites you to picture that as motion.
- And a matrix does this to every vector at the same time. So instead of one arrow, watch the whole grid move.
- Linear transformations are special. Grid lines stay straight, they stay parallel and evenly spaced, and the origin does not move.
- Something like this, which bends the grid lines into curves, is not linear, and it is not something a matrix can do.
- Straight, evenly spaced grid lines are the picture of a rule called linearity. Transforming a v plus b w gives the same thing as a times the transformed v plus b times the transformed w.
- That rule has a stunning consequence. Watch just two vectors: i hat and j hat, the unit steps along the axes.
- Apply a transformation. i hat lands on two, one. j hat lands on negative one, one.
- Write those two landing spots side by side as columns, and you have the matrix. That is all a matrix is: the first column is where i hat lands, the second is where j hat lands.
- Now where does any other vector go? Take v equals one, two. Before the move, v is one i hat plus two j hats.
- Because the grid lines stay parallel and evenly spaced, after the move v is still one transformed i hat plus two transformed j hats. It lands on zero, three.
- That is the column picture of a matrix times a vector: use the entries of the vector as weights on the columns of the matrix.
- The rule you memorized, row times column, gives the same answer. Each output entry is the dot product of a row with the vector. Two pictures, one computation.
- Now we can read any matrix by its columns. Rotate by ninety degrees: i hat goes up to zero, one, and j hat swings over to negative one, zero.
- A shear keeps i hat fixed and pushes j hat sideways to one, one. Squares lean over into parallelograms, like a deck of cards pushed from the top.
- A diagonal matrix just scales. Here x is doubled and y is halved.
- This one flips space over the x axis: j hat lands on negative one times j hat. Notice the orientation has reversed.
- And a projection squashes the whole plane onto a line. j hat lands on zero. Information is destroyed, and no matrix can undo it. We will dig into that next lesson.
- What happens if you apply two transformations in a row? First rotate by ninety degrees, then shear.
- The result is one single linear transformation. Read off where i hat and j hat ended up, and you get its matrix, which is the product S times R.
- Notice the order. The rotation acts first, but it is written on the right, next to the vector. Read matrix products from right to left, like function composition.
- Now swap the order: shear first, then rotate. The dashed arrows show where the basis vectors went last time.
- Different landing spots, different matrix. R times S is not S times R. Matrix multiplication does not commute, because doing things in a different order gives a different motion.
- Everything carries over to three dimensions. A three by three matrix has three columns: where i hat, j hat and k hat land.
- This one is a shear in space: it slides the top of a box sideways while the floor stays put.
- Here is why a fluid simulator cares. Zoom in on a tiny blob of fluid in a shear flow, where the top moves faster than the bottom.
- Nearby velocities differ by a matrix times the separation. That matrix, the velocity gradient, stretches, shears and rotates the blob. The circle becomes a tilted ellipse.
- Later, in fluid kinematics, we will split this matrix into a symmetric part that strains the blob and an antisymmetric part that spins it. Same matrix, read geometrically.
- So: a matrix is a function that moves every vector at once. Its columns are where the basis vectors land, and multiplying matrices means doing one motion after another.
- Next time we run the machine backwards: given an output b, which inputs land on it? That is what solving A x equals b really means.
Functions that move vectors
A transformation from to is just a function: it takes an input vector and returns an output vector . In calculus you graphed functions from numbers to numbers. A function from to has no useful graph (it would need four dimensions), so instead we picture it as motion: every point of the plane slides to its new location, and we watch the whole grid deform.
Most such functions bend the grid into curves. The ones linear algebra studies are much tamer.
In words: transforming a linear combination gives the same linear combination of the transformed vectors. Linear maps don’t care whether you combine first and then transform, or transform first and then combine.
The grid picture and the algebraic rule describe the same thing:
- The origin stays fixed. Take in the scaling rule: .
- Lines stay lines. The line through in direction is the set of points . Linearity sends it to , which is again a line (or a single point, if ).
- Parallel, evenly spaced grid lines stay parallel and evenly spaced. The grid lines are the points . Their images are : all parallel to , and shifted by equal steps of .
So a quick visual test: if the origin moves, or any grid line bends, the transformation is not linear.
Things that are not linear
- Translation with moves the origin, so it isn’t linear. (Graphics programmers get around this with “homogeneous” matrices, a trick worth knowing for your flight simulator.)
- Anything with products or powers of components, like . Doubling the input quadruples the first output instead of doubling it.
- Absolute values, clamps, , and so on. These bend grid lines.
Columns are where î and ĵ land
Here is the big payoff of linearity. Every vector in the plane is a combination of the basis vectors, . Apply a linear and use the rule:
Once you know where the two vectors and land, you know where every vector lands. A linear transformation of the plane is completely described by four numbers: the two coordinates of and the two of . We record them as the columns of a matrix:
This works in any dimension. A linear map from to is an matrix: columns (one per input basis vector), each with entries (a vector in the output space).
Worked example: from a picture to a matrix
A linear transformation sends to and to . Find its matrix and the image of .
The columns are the landing spots, so
Since , linearity gives
This is exactly the example in the video. Before the move, is “one step along , two steps along ”. After the move it is still one step along the new and two steps along the new . The coordinates of a point relative to the moving grid never change. Only the grid moves.
The matrix–vector product, two ways
The worked example is the definition of the matrix–vector product. For a general matrix:
Read that equation from both ends and you get two pictures of the same computation.
The column picture. is a linear combination of the columns of , with the entries of as the weights:
where is the -th column. This is the geometric picture: walk steps along where went, then steps along where went, and so on. It also connects straight back to span: the set of all outputs is the span of the columns. That set is called the column space, and it gets a full treatment in 1.3 Linear Systems, Kernel & Column Space.
The row picture. The -th entry of is the dot product of row with :
This is the “row times column” rule you memorized. It’s the efficient way to compute one entry at a time, and it’s how you’d think about a linear system: each row is one equation.
Both pictures always give the same numbers, because they add up the same products , just grouped differently. The column picture groups by (by column), and the row picture groups by (by row).
Worked example: both pictures
Compute for and .
Columns:
Rows: and . Same answer, as it must be.
Playing with the transformer
The sim below shows the whole plane moving under a matrix. The faint grid is the original plane, and the violet grid is where it goes. The arrows are (first column) and (second column).
Try these:
- Drag the tip of and watch the sliders and change. The first column of the matrix is the tip of , literally. Do the same with .
- Drag the faint input vector . The green arrow is built tip to tail from copies of the first column and copies of the second. That construction is the column picture.
- Preset → Rotation, then slide . The square stays a square and the circle stays a circle. Rotations preserve lengths and angles.
- Preset → Projection. The plane collapses onto a line, the square’s area goes to , and many inputs land on the same output. Keep this picture in mind for the next lesson.
- Mode → Compose, with A = Shear and B = Rotation by 90°. The two panels apply the same two motions in opposite orders and end up in different places.
A gallery of transformations
With “columns = landing spots”, building a matrix for a geometric operation becomes a matter of asking where and should go.
Rotation by (counterclockwise). Rotating by lands it at on the unit circle. starts ahead, so it lands at . Therefore
Shear. Keep fixed and push sideways to :
Each horizontal layer slides by an amount proportional to its height, like a deck of cards pushed from the top. Squares become parallelograms with the same base and height, so area is unchanged.
Scaling. A diagonal matrix stretches each axis independently:
The unit circle becomes an ellipse with semi-axes and . Diagonal matrices are the easiest matrices there are, and much of this module (eigenvectors, diagonalization) is about finding a viewpoint from which a matrix looks diagonal.
Reflection. Flipping across the -axis sends to , and flipping across the line swaps and :
Across the line at angle to the -axis, the reflection is . A reflection reverses orientation: after it, turning from to goes clockwise instead of counterclockwise.
Projection. Squash every vector onto a line through the origin, along the perpendicular direction. Onto the -axis this sends to :
Onto the line through a unit vector , the shadow of is (from the dot product in lesson 1.1). Its columns are the shadows of and , namely and :
Worked example: projection onto the diagonal
Find the matrix that projects onto the line , and check that projecting twice is the same as projecting once.
The unit vector along the line is , so :
Check: , which is on the line and directly “below” along the perpendicular. Now . A point already on the line doesn’t move, so projecting twice changes nothing: .
Notice also that . The whole perpendicular line gets crushed to the origin. A projection destroys information: from the output alone you can’t recover the input, so no matrix can undo . That set of crushed inputs (the kernel) and the question of when a matrix can be undone (the inverse) are the heart of 1.3 Linear Systems, Kernel & Column Space.
Write down the matrix for each transformation by finding where and land.
- Reflection across the line .
- Rotation by counterclockwise.
- Projection onto the line through .
- Horizontal shear that moves the point to .
Show worked solution
- Reflection across swaps the axes: and , so the matrix is .
- , so . Check: lands at , on the diagonal.
- The unit vector is . Then , and , so . Check: , so points on the line stay put. And , so the perpendicular direction is crushed.
- A horizontal shear is , which sends to . Setting gives , so the matrix is .
A linear transformation satisfies and . Find its matrix. (Hint: write and as combinations of and first.)
Show worked solution
Since and , linearity gives
These are the columns:
Check: ✓ and ✓.
The lesson: the values of a linear map on any basis pin it down completely, not just on . Changing which basis you describe a map in is the subject of 1.6 Change of Basis & Diagonalization.
Matrix multiplication is composition
What happens if you apply one transformation and then another? Suppose acts first and second. A vector goes to , then to . The combined map is still linear (a combination survives each step), so it has its own matrix. We define the product to be that matrix:
To find its columns, ask where and end up. sends to its first column , and then sends that to . Likewise for every column:
Column of is times column of . If you compute each with the row picture, entry of comes out as (row of ) · (column of ). That’s the familiar multiplication rule, and now you know why it’s the rule: it’s the only rule that makes true.
The sizes have to match: if is (from to ) and is (from to ), then is . The output of must fit into the input of . Composition also explains for free why matrix multiplication is associative, : both sides mean “do , then , then ”.
Worked example: rotate, then shear
Let and . Find the matrix for “rotate, then shear”.
Rotate first means is on the right, so we want . Track the basis vectors:
Check with the row-times-column rule: entry is , entry is , entry is , and entry is . ✓
Order matters: AB ≠ BA
Now swap the order: shear first, then rotate. That’s :
Matrix multiplication is not commutative. Geometrically there’s nothing strange about this. Shearing pushes things horizontally, and whether something is horizontal depends on whether you rotated it yet. Put on your socks and then your shoes, or your shoes and then your socks: same two operations, different outcome. Try it in the sim’s compose mode.
Some pairs do commute: any matrix with the identity (which does nothing), any two scalings , and any two rotations of the plane, , since turning by then is a turn by either way. But commuting is the exception, not the rule. In 3D, even rotations stop commuting, which is a headache you’ll meet in 12.3 Rigid-Body Dynamics & Rotations.
- Multiply out entry by entry.
- Using the geometric fact that rotating by and then by is a rotation by , deduce the angle-addition formulas for and .
- What is ? Interpret it.
Show worked solution
- Row times column:
- Geometrically this product must equal . Comparing first columns gives
The second column gives the same two identities again. You never need to memorize these formulas: they’re just “rotations compose”.
- . Rotating by undoes rotating by , so is the inverse of . Since and , is with its off-diagonal signs flipped, which is its transpose: .
Let be the reflection across the line at angle .
- Verify that and are the reflections across the -axis and across .
- Compute and identify it.
- Show that in general . Why does it make sense that two orientation-reversing maps compose to an orientation-preserving one?
Show worked solution
- (flip across the -axis). has , so (swap, i.e. flip across ).
- . Tracking : the first flip leaves it alone and the swap sends it to , a quarter turn.
- Write , , and similarly for . Then
By the angle-difference formulas, and , and the top-right entry is the negative of the bottom-left one. So the product is . Each reflection reverses orientation (clockwise ↔ counterclockwise). Reversing twice restores it, so the result must be a rotation. With and we recover part 2.
Three dimensions, briefly
Everything carries over to unchanged. A matrix has three columns: where , and land.
rotates around the -axis: lands on itself (third column ), and the -plane turns exactly like the 2D rotation. is a shear in space. It leaves the floor (, ) alone and sends to , so a box’s top slides 2 units in for every unit of height. Matrix–vector products and composition work exactly as before: , and column of is .
In a flight simulator, the aircraft’s orientation is a rotation matrix whose columns are the aircraft’s nose, right-wing and belly directions written in world coordinates, which is the “columns are where the basis lands” idea in practice. You’ll build one in 12.4 6-DOF Aircraft Equations of Motion.
Matrices in code
In NumPy, A @ x is the matrix–vector product and A @ B the matrix product. This cell transforms the grid and an airplane outline so you can experiment with any matrix:
Notice the trick in M @ plane.T: stacking many points as the columns of one matrix transforms all of them in a single product. That’s because column of is times column of , which is the composition rule again. It’s how GPUs transform millions of vertices per frame.
Now implement the ideas yourself, without @.
The velocity gradient: a matrix inside every fluid parcel
Here is where matrices meet fluids. Pick a point in a flow with velocity field , and look at a nearby point . For a tiny separation, the velocity difference is approximately linear in :
This is the multivariable version of the tangent-line approximation . The derivative of a vector field is a matrix, called the velocity gradient tensor , and you’ll derive it properly in 2.2 Linearization, the Chain Rule & the Jacobian. Relative to its center, then, a small blob of fluid moves according to , a linear system of ODEs. The matrix is the local motion of the fluid.
Take simple shear flow, : fluid at height moves right with speed , like the air near a wing surface. Then
Following the blob for a time , each of its points moves by . That’s a shear matrix! A round blob becomes a tilted ellipse, which is what the end of the video and the sim’s “Fluid blob” preset show.
Key Takeaways
- A linear transformation fixes the origin and keeps grid lines straight, parallel and evenly spaced. Algebraically, .
- The columns of a matrix are where the basis vectors land. Knowing and determines everywhere.
- is a combination of the columns of weighted by the entries of (the column picture), and equivalently each entry is a row · vector dot product (the row picture).
- Rotation, shear, scaling, reflection and projection matrices can all be written down by asking where and go. Projections crush a direction and can’t be undone.
- Matrix multiplication is composition: , so acts first. Column of is times column of .
- Order matters: in general (rotate-then-shear differs from shear-then-rotate), although rotations of the plane commute with each other.
- Everything extends to and matrices: one column per input basis vector.
- The velocity gradient is the matrix that locally stretches, shears and rotates a fluid parcel, and every Euler step of a linear system is a multiplication by .