Everything so far has sat still, and the subject only becomes useful when something moves the vectors around.
The previous lessons built the objects: vectors, added and scaled, spanning subspaces that have a dimension and a basis. Nothing in them acts. This lesson introduces maps from one space to another, restricts them to the ones that respect the two operations, and finds that the restriction is so severe that such a map can be written down completely with a handful of numbers.
The definition, and what it rules out
A map from to is linear when it satisfies two conditions for all vectors and all scalars :
In words: it does not matter whether you add before or after applying , and it does not matter whether you scale before or after. The two together say preserves linear combinations, , which is the form actually used in proofs.
An immediate consequence is : take in the second condition. A linear map cannot move the origin, and that alone rules out a large class of familiar operations.
Translation is the important casualty. The map , sliding the plane one unit right, is not linear, because . This is not a technicality to be regretted: translations are excluded on purpose, because including them would destroy the theory, and the practical fix is the affine trick mentioned at the end of this lesson.
Squaring fails too. For , compare with . Scaling the input doubled the output in one place and quadrupled it in another, so the second condition fails. And a map can satisfy one condition while failing the other, so both must be checked.
What survives is a smaller class than intuition suggests, and it contains exactly the operations that stretch, rotate, reflect, shear, project and collapse, applied uniformly to the whole space. Geometrically, a linear map on the plane sends straight lines to straight lines, keeps the origin fixed, and sends a grid of parallel evenly spaced lines to another grid of parallel evenly spaced lines, though the grid may be tilted, stretched or flattened.
Example. Is linear?
Take and . Then , and expanding and regrouping gives . Scaling works the same way, since every term carries exactly one factor of an input component. So it is linear, and the general rule is visible: a map whose output components are sums of the input components multiplied by constants, with no constant term, is linear.
Now you. Is linear?
Answer
No. and , so the sum of the outputs is , while . Addition is not preserved. The second component multiplies two input components together, which is exactly what linearity forbids.
A map is fixed by what it does to a basis
Here is the theorem that makes the subject computational. Write any vector in the plane in the standard basis, where and . Applying a linear and using both conditions,
The right hand side involves only at the two basis vectors. So if you know where sends and where it sends , you know where it sends everything, with no further information required. In the same argument uses basis vectors, and in any subspace it uses a basis of that subspace.
This is a strong statement. A general function from the plane to the plane requires specifying two numbers for each of infinitely many points. A linear one requires four numbers in total.
Suppose and . Then , and every other value of is available the same way.
The matrix of a transformation
Record those images as the columns of an array, and the array is the matrix of . Following the convention fixed in the first lesson, a matrix is written as the list of its columns, so the map above has matrix
whose first column is and whose second is . This is the single most useful sentence in the subject: the columns of a matrix are the images of the basis vectors. Read a matrix that way and its geometry is visible without any computation.
The product is then defined to be exactly what the theorem says is:
a linear combination of the columns with the components of as the weights. Taking and : .
The same number can be computed the other way round, taking one output component at a time: the th component of is the th row of dotted with . Here the first row is , giving , and the second row is , giving . The row method is how the arithmetic is usually organised, and the column method is what it means. Both give the same answer, because both are the same sum of products with the terms gathered differently.
An by matrix has columns, each of length , and represents a map from to : it eats vectors with components and produces vectors with . Note the order, which trips everyone at first: the number of columns is the dimension of the input space.
With this, the very first lesson's system becomes , and the whole subject is one notation. Solving a system asks which input sends to a given output.
Example. A linear map doubles every vector and then rotates it a quarter turn anticlockwise. What is its matrix?
Follow the basis vectors. doubles to , and a quarter turn anticlockwise sends it to . doubles to , and turning sends it to . So the matrix is . Test it on : the formula gives , and by hand, doubling gives and a quarter turn sends to .
Now you. A linear map reflects in the horizontal axis and then multiplies every length by three. What is its matrix?
Answer
is unmoved by the reflection and becomes . reflects to and becomes . The matrix is . Applied to it gives , which is the reflection tripled.
A catalogue of plane transformations
Every entry below is obtained the same way, by asking where and go. None of them needs to be memorised.
Scaling. Stretching by horizontally and vertically sends to and to , giving . With this is a uniform scaling, and with it is the identity matrix , which leaves every vector alone.
Rotation. Turn the plane anticlockwise by . The vector lands on the unit circle at angle , which is . The vector starts a quarter turn ahead of and stays a quarter turn ahead, landing at angle , which is . So
For this is , matching the quarter turn used above. That entire derivation is two sentences of trigonometry, which is why the rotation matrix is worth deriving rather than remembering.
Shear. Fix the horizontal axis and slide everything else sideways in proportion to its height: stays at and moves to . The matrix is . With the point goes to : the height is unchanged and the horizontal displacement equals the height. This is what italic type does to letters.
Projection. Flatten the plane onto the horizontal axis: stays and goes to , giving . Information is destroyed here, since every point with the same has the same image, and that irreversibility is the subject of two lessons from now.
Reflection. Reflecting in the line swaps the axes, so and , giving . For a general line through the origin at angle , reflecting sends to angle and to angle , giving . Setting recovers the swap, since and .
Example. Rotate by and confirm the length is unchanged.
The matrix is . Applying it, . The length is , unchanged, as a rotation demands. The exact answer is .
Now you. Rotate by .
Answer
Only the second column contributes: . The length is , unchanged. The exact answer is .
Why the restriction pays
Linearity is what makes a transformation knowable from finitely many measurements, and the consequences run further than convenience.
Because preserves combinations, it maps subspaces to subspaces: the image of a line through the origin is a line through the origin or the single point , and the image of a plane is a plane, a line or a point. Nothing bends, and nothing that was flat becomes curved.
Because is determined on a basis, two maps agreeing on a basis are the same map everywhere, which is the standard way of proving that two matrices are equal. And because the matrix is just a list of images, building a transformation to specification is a matter of writing down where you want the basis to go, which is how every rotation in a graphics engine and every filter in signal processing is constructed.
The catalogue also shows what to watch for. Rotations and reflections preserve length; scalings and shears do not; projections destroy information. Those distinctions get numbers attached to them in the next three lessons.
Honest limits
Translation is not linear, and yet moving objects around is most of what computer graphics does. The standard fix is to embed the plane in three dimensions as the slice , where a translation of the plane becomes a shear of the larger space, which is linear. Points then carry an extra coordinate, called homogeneous coordinates, and this is why graphics hardware works with four by four matrices for three-dimensional scenes: three dimensions of geometry plus one for the trick. Maps of the form are called affine, and they are the ones that preserve straight lines without fixing the origin.
Second, the matrix of a map depends on the basis used to write it down. Everything above used the standard basis silently. The same transformation gets a different matrix in a different basis, and choosing a basis that makes the matrix simple is the whole strategy of the last third of this course.
Third, real data is rarely linear, and calling a model linear is a claim that can be wrong. Doubling the dose does not always double the effect. The usual defence is that a smooth relationship is approximately linear over a small enough range, which is exactly what a derivative asserts, and the approximation fails outside that range without any warning from the algebra.
One transformation is now four numbers. Two transformations applied in turn are also a transformation, so it too has four numbers, and asking how to compute them from the original eight is what defines matrix multiplication in the next lesson.