Linear transformation
A rule moves every vector to a new vector. When can that rule be carried out by a single matrix, and how do you find the matrix?
Where you are 9 in Matrices as linear transformations
Why this exists
Leyli is a type designer. Her letters are drawn as points and strokes on a grid, and she wants an italic version of a whole alphabet: every letter slanted the same way. Moving each point by hand would be endless, so she wants one rule that moves every point of the plane at once. Her slant moves (x, y) to (x + y/4, y): the higher a point sits, the farther right it slides, a quarter unit for each unit of height, and the baseline stays put.
A rule like that is a function whose inputs and outputs are vectors. Most such functions are useless to a designer, because they bend straight strokes into curves. The ones that keep the drawing intact, straight strokes to straight strokes, parallel strokes to parallel strokes, the midpoint of a stroke to the midpoint of its image, are the ones that respect the two operations on vectors: adding and scaling. Those are the linear transformations. They are worth naming because, as this lesson proves, they are exactly the functions a matrix can carry out, so every question about them becomes a question about a matrix.
This lesson runs over two days. Day 1 is the definition and how to test a rule against it. Day 2 is the standard matrix: every linear transformation from \mathbb{R}^n to \mathbb{R}^m is multiplication by one matrix, and its columns are where the standard vectors go.
Definition
A function T: \mathbb{R}^n \to \mathbb{R}^m assigns to each vector \mathbf{x} in \mathbb{R}^n exactly one vector T(\mathbf{x}) in \mathbb{R}^m, called the image of \mathbf{x}. \mathbb{R}^n is the domain and \mathbb{R}^m the codomain. The two may be different spaces.
T is a linear transformation when, for all vectors \mathbf{u} and \mathbf{v} in \mathbb{R}^n and every scalar c,
In words: adding two inputs and then applying T gives the same result as applying T to each and adding the outputs, and the same holds for scaling. The first rule is additivity, the second homogeneity. Both must hold for every choice of vectors and scalars; a single failure makes T not linear.
For an m \times n matrix A, the matrix transformation of A is the function \mathbf{x} \mapsto A\mathbf{x} from \mathbb{R}^n to \mathbb{R}^m. When T(\mathbf{x}) = A\mathbf{x} for every \mathbf{x}, A is called the standard matrix of T.
Intuition
Picture a linear transformation of the plane by what it does to the grid. The origin stays fixed, because T(\mathbf{0}) = T(0\mathbf{0}) = 0\,T(\mathbf{0}) = \mathbf{0}. Grid lines go to straight lines that stay parallel and evenly spaced, because a line \mathbf{p} + t\mathbf{d} goes to T(\mathbf{p}) + t\,T(\mathbf{d}): another line, its direction T(\mathbf{d}) the same for every line that started parallel. (If T(\mathbf{d}) = \mathbf{0}, each such line collapses to a single point.) So a letter drawn on the grid comes out drawn the same way on the new grid.
Additivity says the parallelogram rule survives: the sum of two arrows, drawn as the diagonal of their parallelogram, goes to the diagonal of the image parallelogram. Homogeneity says an arrow twice as long goes to an arrow twice as long. What a linear transformation may change is lengths, angles and areas; Leyli’s slant tilts every vertical stroke and keeps every horizontal one.
Results
Linear transformations preserve combinations. If T is linear, then for any vectors \mathbf{u}_1, \dots, \mathbf{u}_k and scalars c_1, \dots, c_k,
In particular T(\mathbf{0}) = \mathbf{0} and T(-\mathbf{u}) = -T(\mathbf{u}).
Every matrix transformation is linear. For an m \times n matrix A, the map \mathbf{x} \mapsto A\mathbf{x} is a linear transformation from \mathbb{R}^n to \mathbb{R}^m.
Every linear transformation is a matrix transformation. If T: \mathbb{R}^n \to \mathbb{R}^m is linear, then T(\mathbf{x}) = A\mathbf{x} for every \mathbf{x} in \mathbb{R}^n, where A is the m \times n matrix whose columns are the images of the standard vectors:
This A is the only matrix that does it.
Reading linearity off a formula. A function given by a formula is linear exactly when each entry of the output is a sum of constant multiples of the input entries, with no constant term and no products, powers or other functions of the inputs. Such a formula is A\mathbf{x} with the coefficients as the rows of A.
Why it is true
Combinations. Additivity, applied k - 1 times, splits T of a sum of k vectors into the sum of the T values; homogeneity then pulls each scalar out. Taking every c_i = 0 gives T(\mathbf{0}) = \mathbf{0}, and c = -1 gives T(-\mathbf{u}) = -T(\mathbf{u}).
Matrix transformations. Multiplying a matrix by a vector proved A(\mathbf{u} + \mathbf{v}) = A\mathbf{u} + A\mathbf{v} and A(c\mathbf{u}) = c\,A\mathbf{u} from the column reading of the product. Those are the two rules of the definition, word for word.
Every linear T is a matrix transformation. Any \mathbf{x} = (x_1, \dots, x_n) in \mathbb{R}^n is the combination \mathbf{x} = x_1\mathbf{e}_1 + \dots + x_n\mathbf{e}_n of the standard vectors. Since T preserves combinations,
By the column reading of a product, the right side is A\mathbf{x} for the matrix A with columns T(\mathbf{e}_1), \dots, T(\mathbf{e}_n). Each column lies in \mathbb{R}^m and there are n of them, so A is m \times n.
Only one matrix. Suppose B is also m \times n with B\mathbf{x} = T(\mathbf{x}) for every \mathbf{x}. Then B\mathbf{e}_j = T(\mathbf{e}_j) = A\mathbf{e}_j, and B\mathbf{e}_j is column j of B, so A and B agree column by column.
Reading off a formula. If entry i of T(\mathbf{x}) is a_{i1}x_1 + \dots + a_{in}x_n, then T(\mathbf{x}) = A\mathbf{x} with A = [a_{ij}] by the row reading, so T is linear. Conversely, a linear T equals some A\mathbf{x}, and every entry of A\mathbf{x} has that form.
Worked examples
Day 1: Leyli’s slant is linear
Show that T(x, y) = (x + y/4,\ y) is a linear transformation of \mathbb{R}^2. Then check additivity on the corner \mathbf{u} = (3, 0) of a letter’s base and the top of its stem, \mathbf{v} = (0, 4).
SolutionTake any \mathbf{u} = (u_1, u_2) and \mathbf{v} = (v_1, v_2). Vectors add entry by entry, so \mathbf{u} + \mathbf{v} = (u_1 + v_1, u_2 + v_2) and
The middle step distributes \tfrac14 over u_2 + v_2 and then regroups the four terms (the commutative and associative properties of addition). For scaling, c\mathbf{u} = (cu_1, cu_2) and
by factoring out c (the distributive property). Both rules hold for all inputs, so T is linear.
The check on the letter: T(3, 0) = (3, 0) and T(0, 4) = (1, 4), with sum (4, 4). The sum of the inputs is (3, 4), and T(3, 4) = (3 + 1, 4) = (4, 4). The two agree, as additivity says they must. One numerical check never proves linearity; the general argument above does.
Day 1: A map from three dimensions to two
Show that T: \mathbb{R}^3 \to \mathbb{R}^2, T(x, y, z) = (x - z,\ 2y + z), is linear, and find T(1, -1, 2).
SolutionThe domain and codomain differ: three entries go in, two come out. Write \mathbf{u} = (u_1, u_2, u_3) and \mathbf{v} = (v_1, v_2, v_3). Then
which is T(\mathbf{u}) + T(\mathbf{v}), after regrouping each entry. And T(c\mathbf{u}) = (cu_1 - cu_3,\ 2cu_2 + cu_3), which is c\,(u_1 - u_3,\ 2u_2 + u_3) = c\,T(\mathbf{u}). So T is linear. Each output entry is a combination of x, y, z with no constant term, which is the pattern the Results section names.
At the given input, T(1, -1, 2) = (1 - 2,\ -2 + 2) = (-1, 0).
Day 1: Two rules that are not linear
Mahsa proposes two more rules for the plane: a nudge N(x, y) = (x + 1,\ y) and a bulge B(x, y) = (xy,\ y). Show that neither is linear.
SolutionTo show a rule is not linear, one specific failure is enough.
The nudge. Every linear transformation sends \mathbf{0} to \mathbf{0}, but N(0, 0) = (1, 0). So N is not linear. It is a translation, sliding every point one unit right (see Translations); no translation by a nonzero vector is linear. Additivity fails visibly too: N(\mathbf{0} + \mathbf{0}) = (1, 0) while N(\mathbf{0}) + N(\mathbf{0}) = (2, 0).
The bulge. Here B(0, 0) = (0, 0), so the zero test is passed, and that proves nothing. Try scaling: with \mathbf{u} = (1, 1) and c = 2,
These differ, so homogeneity fails and B is not linear. The product xy is what breaks it: scaling both inputs by c scales xy by c^2, not c.
Day 1: Where a stroke goes
Ronak works with a linear transformation T of the plane, and knows only that it sends \mathbf{p} = (2, 1) to (3, 0) and \mathbf{q} = (1, 3) to (1, 4). Find T(3\mathbf{p} - 2\mathbf{q}) and the image of the midpoint of the stroke from \mathbf{p} to \mathbf{q}, and describe the image of the whole stroke.
SolutionLinearity lets Ronak work with the images alone; he never needs a formula for T. By the combination rule,
The points of the stroke are (1 - t)\mathbf{p} + t\mathbf{q} for 0 \le t \le 1. Each goes to (1 - t)T(\mathbf{p}) + t\,T(\mathbf{q}), again by the combination rule, and those are the points of the stroke from (3, 0) to (1, 4). So a straight stroke goes to a straight stroke (or a single point, if its ends land together). The midpoint has t = \tfrac12:
Check: the midpoint of the stroke is (1.5, 2), and it lands at the midpoint of the image stroke, (2, 2).
Day 2: The matrix of the slant
Find the standard matrix of Leyli’s slant T(x, y) = (x + y/4,\ y) and use it to find where the corner (2.5, 4) of a letter goes.
SolutionT is linear (Example 1), so its standard matrix has columns T(\mathbf{e}_1) and T(\mathbf{e}_2):
So
The figure shows the two columns: \mathbf{e}_1 stays put and \mathbf{e}_2 leans a quarter unit right, so the unit square becomes a parallelogram with the same base and height.
Check against the formula:
which is T(x, y). For the corner,
Day 2: A matrix with more columns than rows
Find the standard matrix of T(x, y, z) = (x - z,\ 2y + z) from Example 2, and recompute T(1, -1, 2) with it.
SolutionThe domain is \mathbb{R}^3 and the codomain \mathbb{R}^2, so A has 3 columns, each in \mathbb{R}^2: it is 2 \times 3. The images of the standard vectors are
so
The rows of A are the coefficients of x, y, z in the two output entries, as the Results section predicts. Then
matching Example 2.
Day 2: Resizing, then slanting
For a condensed italic, Mahsa first resizes each letter, scaling widths by \tfrac45 and heights by \tfrac65, then applies Leyli’s slant. Find the standard matrix of the combined move, and compare it with doing the slant first.
SolutionThe resize is R(x, y) = (\tfrac45 x,\ \tfrac65 y), linear by the formula test. The combined move \mathbf{x} \mapsto T(R(\mathbf{x})) is linear too:
using additivity of R and then of T, and scaling passes through both in the same way. So it has a standard matrix, and its columns are where \mathbf{e}_1 and \mathbf{e}_2 end up:
since the slant adds \tfrac14 \cdot \tfrac65 = \tfrac{3}{10} to the first entry.
The matrix is \begin{bmatrix} \tfrac45 & \tfrac{3}{10} \\ 0 & \tfrac65 \end{bmatrix}. Slanting first instead sends \mathbf{e}_2 to (\tfrac14, 1) and then to (\tfrac45 \cdot \tfrac14, \tfrac65) = (\tfrac15, \tfrac65), with matrix \begin{bmatrix} \tfrac45 & \tfrac15 \\ 0 & \tfrac65 \end{bmatrix}. The order matters: resizing after slanting narrows the slant along with the letter. How such a combined matrix comes from the two separate matrices is the subject of Composing transformations as a matrix product.
Boundaries
- Translations are not linear. \mathbf{x} \mapsto \mathbf{x} + \mathbf{b} with \mathbf{b} \neq \mathbf{0} moves the origin, so it fails both rules, and so does \mathbf{x} \mapsto A\mathbf{x} + \mathbf{b}. A slide of a figure, as in Translations, is a perfectly good transformation of the plane, just not a linear one. The same goes for f(x) = mx + b with b \neq 0: its graph is a line, but it is not a linear transformation of \mathbb{R}.
- T(\mathbf{0}) = \mathbf{0} is necessary, not sufficient. It rules out a nudge but not a bulge (Example 3).
- Both rules are needed. \displaystyle f(x, y) = \sqrt[3]{x^3 + y^3} satisfies f(c\mathbf{u}) = c f(\mathbf{u}) for every scalar c, yet it is not additive (Exercise 12).
- The standard matrix is for maps from \mathbb{R}^n to \mathbb{R}^m. Linear maps also act on other spaces (polynomials, functions), where a matrix appears only after coordinates are chosen; see Coordinates in a basis and change of basis. Even in \mathbb{R}^n, a basis other than \mathbf{e}_1, \dots, \mathbf{e}_n can give a different matrix for the same map.
- Linear says nothing about undoing. A linear transformation may send many inputs to one output, as (x, y, z) \mapsto (x - z,\ 2y + z) does; when one can be undone is When a matrix or transformation can be undone.
Where this goes next
Geometry already met transformations of the plane, slides, turns and flips, one at a time and in sequence (Combining transformations and the general form, Composing transformations). Linear algebra keeps the ones that fix the origin and respect sums and scaling, and gains a matrix for each. Finding the matrix of a transformation uses the column rule A = [\,T(\mathbf{e}_1) \ \cdots \ T(\mathbf{e}_n)\,] to find the matrices of rotations, reflections and projections. Doing one linear transformation after another, as in Example 7, is a matrix product in Composing transformations as a matrix product. The vectors T sends to \mathbf{0} form its kernel, and all its outputs form its image. How much T stretches areas is the determinant, and the directions T only stretches lead to Eigenvalues and eigenvectors.
Exercises
Day 1: testing linearity
- Show directly from the definition that T(x, y) = (3x - y,\ x + 2y) is linear.
- Decide whether T(x, y) = (x - 4y,\ 0,\ 2x) is linear, and name its domain and codomain.
- Decide whether T(x, y) = (x + 2,\ 3y) is linear.
- Decide whether T(x, y) = (x^2,\ y) is linear.
- Decide whether T(x, y) = (|y|,\ x) is linear.
- Decide whether T(x, y, z) = (y,\ z,\ x) is linear.
Day 1: using linearity
- Leyli tries a steeper slant, S(x, y) = (x + y/3,\ y). Find the images of (0, 3), (2, 3) and (1.5, 1.5).
- A linear T of the plane has T(\mathbf{u}) = (1, 4) and T(\mathbf{v}) = (-2, 0). Find T(2\mathbf{u} + \mathbf{v}), T(\mathbf{u} - 3\mathbf{v}) and T(\mathbf{0}).
- A linear T sends \mathbf{p} to (2, 5) and \mathbf{q} to (6, -1). Find the image of the midpoint of the stroke from \mathbf{p} to \mathbf{q}, and of the point one quarter of the way from \mathbf{p} to \mathbf{q}.
- A linear T of the plane has T(3, 0) = (6, 3). Find T(1, 0) and T(-2, 0).
Day 1: reasoning
- Prove from the two rules that a linear T has T(\mathbf{0}) = \mathbf{0} and T(\mathbf{u} - \mathbf{v}) = T(\mathbf{u}) - T(\mathbf{v}).
- Show that \displaystyle f(x, y) = \sqrt[3]{x^3 + y^3} satisfies f(c\mathbf{u}) = c\,f(\mathbf{u}) for every scalar c and every \mathbf{u}, but is not linear.
- Give a counterexample to the claim “if T(\mathbf{0}) = \mathbf{0}, then T is linear,” different from the bulge of Example 3.
Day 2: standard matrices
- Find the standard matrix of T(x, y) = (2x - y,\ x + 3y,\ -y).
- Find the standard matrix of T(x, y, z, w) = (x + w,\ y - 2z).
- Find the standard matrix of the slant S of Exercise 7, and use it to find S(3, 6).
- Ronak widens letters without changing their height: W(x, y) = (\tfrac32 x,\ y). Find its standard matrix and W(2, 4).
- A linear T: \mathbb{R}^2 \to \mathbb{R}^3 has T(\mathbf{e}_1) = (1, 0, 2) and T(\mathbf{e}_2) = (-1, 3, 1). Find T(4, -2) and a formula for T(x, y).
- A linear T: \mathbb{R}^3 \to \mathbb{R} has T(\mathbf{e}_1) = 2, T(\mathbf{e}_2) = -1 and T(\mathbf{e}_3) = 5. Find its standard matrix and T(1, 1, 1).
Day 2: matrices found from images
- Ronak applies the slant S of Exercise 7 and then doubles every width, (x, y) \mapsto (2x, y). Find the standard matrix of the combined move.
- Find the standard matrix of the identity map of \mathbb{R}^3, \mathbf{x} \mapsto \mathbf{x}, and of the zero map from \mathbb{R}^2 to \mathbb{R}^3, \mathbf{x} \mapsto \mathbf{0}.
- A linear T of the plane has T(\mathbf{e}_1) = (2, 1) and T(\mathbf{e}_1 + \mathbf{e}_2) = (3, 4). Find its standard matrix.
Day 2: reasoning
- Let S and T be linear from \mathbb{R}^n to \mathbb{R}^m, with standard matrices A and B. Prove that the sum (S + T)(\mathbf{x}) = S(\mathbf{x}) + T(\mathbf{x}) is linear and that its standard matrix is A + B.
- Explain why no linear T of the plane sends (1, 2) to (1, 0) and (2, 4) to (3, 1).
- Show that a linear T of the plane sends two parallel lines either to two parallel lines (possibly the same line) or to two points.
Answers
- For \mathbf{u} = (u_1, u_2) and \mathbf{v} = (v_1, v_2), the first entry of T(\mathbf{u} + \mathbf{v}) is 3(u_1 + v_1) - (u_2 + v_2), which regroups to (3u_1 - u_2) + (3v_1 - v_2); the second is (u_1 + v_1) + 2(u_2 + v_2), which regroups to (u_1 + 2u_2) + (v_1 + 2v_2). So T(\mathbf{u} + \mathbf{v}) = T(\mathbf{u}) + T(\mathbf{v}). And T(c\mathbf{u}) = (3cu_1 - cu_2,\ cu_1 + 2cu_2) = c\,T(\mathbf{u}).
- Linear, from \mathbb{R}^2 to \mathbb{R}^3: each entry is a combination of x and y with no constant term (the entry 0 is 0x + 0y).
- Not linear: T(0, 0) = (2, 0) \neq \mathbf{0}.
- Not linear: T(2, 0) = (4, 0), but 2T(1, 0) = (2, 0).
- Not linear: with c = -1 and \mathbf{u} = (0, 1), T(0, -1) = (1, 0), but -T(0, 1) = (-1, 0).
- Linear, from \mathbb{R}^3 to \mathbb{R}^3: each entry is a single input entry, a combination with no constant term.
- (1, 3), (3, 3) and (2, 1.5): add a third of the height to the first entry.
- T(2\mathbf{u} + \mathbf{v}) = (2, 8) + (-2, 0) = (0, 8); T(\mathbf{u} - 3\mathbf{v}) = (1, 4) - (-6, 0) = (7, 4); T(\mathbf{0}) = (0, 0).
- Midpoint: \tfrac12(2, 5) + \tfrac12(6, -1) = (4, 2). Quarter point \tfrac34\mathbf{p} + \tfrac14\mathbf{q}: \tfrac34(2, 5) + \tfrac14(6, -1) = (3, 3.5).
- (1, 0) = \tfrac13(3, 0), so T(1, 0) = (2, 1); (-2, 0) = -\tfrac23(3, 0), so T(-2, 0) = (-4, -2).
- T(\mathbf{0}) = T(0\mathbf{0}) = 0\,T(\mathbf{0}) = \mathbf{0}. And T(\mathbf{u} - \mathbf{v}) = T(\mathbf{u} + (-1)\mathbf{v}) = T(\mathbf{u}) + (-1)T(\mathbf{v}), by additivity then homogeneity.
- \displaystyle f(cx, cy) = \sqrt[3]{c^3(x^3 + y^3)} = c\,\sqrt[3]{x^3 + y^3}, since the real cube root of c^3 is c for every real c, negative included. But f(1, 0) + f(0, 1) = 1 + 1 = 2, while \displaystyle f(1, 1) = \sqrt[3]{2} \approx 1.26, so additivity fails.
- T(x, y) = (x, y^2): T(\mathbf{0}) = \mathbf{0}, but T(0, 2) = (0, 4) while 2T(0, 1) = (0, 2). (Many other rules with a square or a product of the inputs and no constant term work too.)
- \begin{bmatrix} 2 & -1 \\ 1 & 3 \\ 0 & -1 \end{bmatrix}, columns T(\mathbf{e}_1) = (2, 1, 0) and T(\mathbf{e}_2) = (-1, 3, -1).
- \begin{bmatrix} 1 & 0 & 0 & 1 \\ 0 & 1 & -2 & 0 \end{bmatrix}, a 2 \times 4 matrix: the columns are T of the four standard vectors of \mathbb{R}^4.
- \begin{bmatrix} 1 & \tfrac13 \\ 0 & 1 \end{bmatrix}, and S(3, 6) = 3(1, 0) + 6(\tfrac13, 1) = (5, 6).
- \begin{bmatrix} \tfrac32 & 0 \\ 0 & 1 \end{bmatrix}, and W(2, 4) = (3, 4).
- T(4, -2) = 4(1, 0, 2) - 2(-1, 3, 1) = (6, -6, 6). In general T(x, y) = x(1, 0, 2) + y(-1, 3, 1), which is (x - y,\ 3y,\ 2x + y).
- The 1 \times 3 matrix \begin{bmatrix} 2 & -1 & 5 \end{bmatrix}, and T(1, 1, 1) = 2 - 1 + 5 = 6.
- \begin{bmatrix} 2 & \tfrac23 \\ 0 & 1 \end{bmatrix}: \mathbf{e}_1 \to (1, 0) \to (2, 0) and \mathbf{e}_2 \to (\tfrac13, 1) \to (\tfrac23, 1). As a formula, (x, y) \mapsto (2x + \tfrac23 y,\ y).
- The identity matrix \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}, since each \mathbf{e}_j goes to itself; and the 3 \times 2 zero matrix, since each \mathbf{e}_j goes to (0, 0, 0).
- By additivity, T(\mathbf{e}_2) = T(\mathbf{e}_1 + \mathbf{e}_2) - T(\mathbf{e}_1), which is (3, 4) - (2, 1) = (1, 3), so the matrix is \begin{bmatrix} 2 & 1 \\ 1 & 3 \end{bmatrix}.
- Additivity: (S + T)(\mathbf{u} + \mathbf{v}) = S(\mathbf{u}) + S(\mathbf{v}) + T(\mathbf{u}) + T(\mathbf{v}), by additivity of S and of T, and regrouping gives (S + T)(\mathbf{u}) + (S + T)(\mathbf{v}). Homogeneity: (S + T)(c\mathbf{u}) = c\,S(\mathbf{u}) + c\,T(\mathbf{u}) = c\,(S + T)(\mathbf{u}). So S + T is linear, and column j of its standard matrix is (S + T)(\mathbf{e}_j) = S(\mathbf{e}_j) + T(\mathbf{e}_j), which is column j of A plus column j of B. Every column of the matrix is the matching column of A + B.
- (2, 4) = 2(1, 2), so homogeneity forces T(2, 4) = 2T(1, 2) = (2, 0), not (3, 1).
- Two parallel lines are \mathbf{p} + t\mathbf{d} and \mathbf{q} + t\mathbf{d} with the same direction \mathbf{d} \neq \mathbf{0}. By linearity their images are T(\mathbf{p}) + t\,T(\mathbf{d}) and T(\mathbf{q}) + t\,T(\mathbf{d}). If T(\mathbf{d}) \neq \mathbf{0}, these are lines with the same direction T(\mathbf{d}), so parallel or equal. If T(\mathbf{d}) = \mathbf{0}, they are the single points T(\mathbf{p}) and T(\mathbf{q}).