Linear transformations: where two basis arrows go is the matrix

When you first learn matrix multiplication, it looks like a rule for multiplying numbers in a certain order. In fact a matrix is a note about how to change the plane, and the note only says where two arrows go. Drag the tips of those two arrows and see how the whole plane follows.

Short answer. A linear transformation is a function from arrows (vectors) to arrows that keeps sums and scaling: T(u + v) = T(u) + T(v) and T(k·u) = k·T(u). Then knowing where the basis arrows e₁ and e₂ go tells you where every arrow goes, and standing those two up as columns gives the matrix: T(x) = [T(e₁) T(e₂)]·x. In pictures, it is a change of the plane that keeps the origin in place and keeps grid lines straight and evenly spaced.

The matrix of T. The first column is T(e₁), the second column is T(e₂)

Drag the tips of the green and blue arrows, or type numbers into the four boxes (−4 to 4). The faint lines are where the original grid goes under T, and the green cell is where one original square (made by e₁ and e₂) goes. [a b; c d] means the matrix with top row a b and bottom row c d. When the plane is squashed onto a line, the solid purple line is the range and the dashed orange line is the kernel. If the two tips land on the same spot, dragging grabs the green one, so use the number boxes.

Try this. ① The starting matrix [2 −1; 1 1] has T(e₁) = (2, 1) and T(e₂) = (−1, 1). The grid leans and stretches but stays straight and evenly spaced. The range is the whole plane and the kernel is only 0, so 2 + 0 = 2. ② Press "Project onto y = x". All four boxes become 0.5 and the plane is squashed onto one purple line. The dashed orange line in direction (1, −1) is the kernel, and 1 + 1 = 2. ③ Go back to "Starting matrix" and drag the blue tip to (−2, −1) (or type b = −2, d = −1). Now T(e₂) = −T(e₁), so both arrows lie on one line. The range is the line in direction (1, 0.5) and the kernel is the line in direction (1, 1), because T(1, 1) = T(e₁) + T(e₂) = (2, 1) + (−2, −1) = (0, 0). ④ Rotate, stretch and shear never squash area to 0, so their kernel is only 0.

Definitions

The page below explains with maps from the plane to the plane, but the definitions are the same between any vector spaces. V and W are vector spaces and T : V → W is a function. V is the domain and W is the codomain.

linear transformation
T is a linear transformation if the two conditions below hold for all u, v ∈ V and c ∈ ℝ. It is also called a linear map.

T(𝐮+𝐯)=T(𝐮)+T(𝐯),T(c𝐮)=cT(𝐮)

standard matrix
For a linear transformation T : ℝⁿ → ℝᵐ, the m×n matrix A whose columns are where the standard basis vectors e₁, …, eₙ go, in order. For every x ∈ ℝⁿ, T(x) = Ax. This is "the matrix of T" on this page.

A=[T(𝐞1)⋯T(𝐞n)],T(𝐱)=A𝐱

kernel
The set of all members of V that the linear transformation T sends to the zero vector. It is a subspace of V.

kerT={𝐱∈V∣T(𝐱)=0}

range
The set of all values of T. Some books call it the image. It is a subspace of W. If T(x) = Ax, it is the column space of A.

imT={T(𝐱)∣𝐱∈V}

injective
T is injective (one-to-one) if it sends different members to different members. For a linear transformation T, this is the same as ker T = {0}.

T(𝐮)=T(𝐯)⟹𝐮=𝐯

surjective
T is surjective if every member of the codomain W is a value of T, that is, if the range is all of the codomain.

imT=W

isomorphism
A linear transformation that is both injective and surjective (bijective), that is, a linear transformation for which both equations below hold. If there is an isomorphism from V to W, then V and W are isomorphic, written V ≅ W.

kerT={0},imT=W

1. What a linear transformation is: a function that keeps sums and scaling

Say a function T takes an arrow x and gives back an arrow T(x) (arrows are on the vectors page). You can also think of it as a rule that moves every point of the plane somewhere. It is a linear transformation when it follows these two rules.

In one line: T(a·u + b·v) = a·T(u) + b·T(v). In pictures: the origin stays put (T(0) = T(0·u) = 0·T(u) = 0). Grid lines stay straight, parallel, and evenly spaced. If the plane gets squashed flat, several lines can land on top of each other. The faint grid in the lab always behaves like this.

Examples that are not linear

A shift T(x) = x + (1, 0) is not a linear transformation, because it moves the origin to (1, 0). Sums break too: T(e₁ + e₂) = T(1, 1) = (2, 1), but T(e₁) + T(e₂) = (2, 0) + (1, 1) = (3, 1). The (1, 0) got added twice. A rotation or stretch plus a shift has its own name, an affine transformation. In graphics, people add one extra 1 to the end of each coordinate (homogeneous coordinates) so that a shift also becomes a matrix, one size bigger.

Bending is not linear either. T(x, y) = (x², y) gives T(2e₁) = (4, 0), but 2·T(e₁) = (2, 0), so it does not keep scaling.

2. How the formula is built: where the basis goes is the matrix

Using the lab's starting matrix, follow where x = (2, 3) goes. e₁ = (1, 0) and e₂ = (0, 1) are the plane's basic arrows (the standard basis). Suppose all we know about T is T(e₁) = (2, 1) and T(e₂) = (−1, 1).

Written only as formulas, the steps above are these.

𝐱=x1𝐞1+x2𝐞2

T(𝐱)=T(x1𝐞1+x2𝐞2)

T(x1𝐞1+x2𝐞2)=x1T(𝐞1)+x2T(𝐞2)

x1T(𝐞1)+x2T(𝐞2)=[T(𝐞1)T(𝐞2)][x1x2]

T[23]=2[21]+3[−11]=[2−111][23]=[15]

In formulas, (2, 3) is written standing up as a column. It is the same arrow.

  1. Split x: x = x₁e₁ + x₂e₂. (2, 3) is e₁ taken 2 times followed by e₂ taken 3 times.
  2. Apply T: T(x) = T(x₁e₁ + x₂e₂). Apply the same T to both sides. In the picture the staircase moves with the grid but stays a staircase.
  3. Use the two rules: = x₁T(e₁) + x₂T(e₂). Keeping sums splits the bracket in two, and keeping scaling pulls the 2 and the 3 out of T. 2(2, 1) + 3(−1, 1) = (4, 2) + (−3, 3) = (1, 5).
  4. Pack into a matrix: = [T(e₁) T(e₂)]·x. "Take the columns x₁ times and x₂ times and add them" is exactly what multiplying a matrix by a vector does. [2 −1; 1 1]·(2, 3) = (2×2 + (−1)×3, 1×2 + 1×3) = (1, 5).

So the matrix of T has T(e₁) and T(e₂) as its columns, in order. If the input arrows have n entries, there are n basis arrows and so n columns. If the outputs have m entries, each column has m entries, so the matrix is m×n. The other way round, for any matrix A, x ↦ Ax follows both rules (A(u + v) = Au + Av, A(ku) = k·Au), so it is a linear transformation. Once a basis is fixed, linear transformations and matrices pair up one to one. How to multiply a matrix by a vector is on the matrix basics page.

3. Work it by hand: projecting onto the line y = x

A projection drops a line from the tip of an arrow straight down onto a line (at a right angle) and sends the arrow to the foot of that drop. It is the shadow you get when light shines straight onto the line. You do not need the matrix in advance. Just find the shadows of the two basis arrows.

  1. T(e₁). Points on the line look like (t, t). The arrow from (1, 0) to (t, t) is (t − 1, t), and it must be at a right angle to the line's direction (1, 1), so (t − 1)×1 + t×1 = 0, which gives t = 0.5. T(e₁) = (0.5, 0.5).
  2. T(e₂). The same way, t + (t − 1) = 0, t = 0.5. T(e₂) = (0.5, 0.5).
  3. The matrix. Stand them up as columns: [0.5 0.5; 0.5 0.5]. This is the lab's "Project onto y = x" button.
  4. Put in x = (3, 1). (0.5×3 + 0.5×1, 0.5×3 + 0.5×1) = (2, 2).
  5. Kernel and range. The output is 0 when 0.5x + 0.5y = 0, that is y = −x. The kernel is the line in direction (1, −1). Every output looks like (s, s), so the range is the line y = x.
  6. Check. (3, 1) = (2, 2) + (1, −1). The projection keeps the range part (2, 2) and erases the kernel part (1, −1). Projecting (2, 2) again leaves it at (2, 2).

The same work written as formulas:

𝐞1=(1,0):(t−1)·1+t·1=0⟹t=0.5,T(𝐞1)=(0.5,0.5)

𝐞2=(0,1):t·1+(t−1)·1=0⟹t=0.5,T(𝐞2)=(0.5,0.5)

A=[T(𝐞1)T(𝐞2)]=[0.50.50.50.5]

A[31]=[0.5·3+0.5·10.5·3+0.5·1]=[22]

kerT={(x,y)∣0.5x+0.5y=0}=span{(1,−1)},imT=span{(1,1)}

(3,1)=(2,2)+(1,−1),T(2,2)=(2,2),T(1,−1)=(0,0)

4. Common transformations and their matrices

For each one you can write the matrix right away: stand T(e₁) and T(e₂) up as columns.

TransformationT(e₁)T(e₂)MatrixKernelArea factorUndo
Rotate by θ, counterclockwise(cos θ, sin θ)(−sin θ, cos θ)[cos θ −sin θ; sin θ cos θ], for 90° [0 −1; 1 0]only 01yes (rotate by −θ)
Stretch across ×2(2, 0)(0, 1)[2 0; 0 1]only 02yes (across ×0.5)
Shear(1, 0)(1, 1)[1 1; 0 1]only 01yes ([1 −1; 0 1])
Project onto y = x(0.5, 0.5)(0.5, 0.5)[0.5 0.5; 0.5 0.5]line in direction (1, −1)0no

The area factor is the determinant, and the matrix that undoes a transformation is the inverse matrix.

5. Kernel, range, and the rank-nullity theorem

The kernel is every arrow that T sends to 0: ker T = { x : T(x) = 0 }. It always contains 0. In the lab it is the dashed orange line.

The range is every place T(x) can reach: im T = { T(x) }. Since T(x) = x₁T(e₁) + x₂T(e₂), it is everything you can make by adding up multiples of the matrix's columns, the column space. In the lab it is the solid purple line.

The rank-nullity theorem: dim(kernel) + dim(range) = dim(domain). The domain is the space the inputs come from. It says the input directions split into "directions that get squashed away" and "directions that survive". The dimension of the range is the rank of the matrix.

Transformationdim(kernel)dim(range)Sum = dim(domain)
Rotating the plane022
Projecting the plane onto y = x112
Sending the whole plane to 0202
3D to the plane, (x, y, z) ↦ (x, y)1 (the z axis)23

When the kernel is only 0, two different inputs never land on the same output. If T(u) = T(v), then T(u − v) = 0, so u − v is in the kernel, and if the kernel is only 0 then u = v. For a transformation from the plane to the plane, the range is then the whole plane too, so it can be undone. That is exactly when the determinant is not 0 and the inverse matrix exists. One more link: a nonzero arrow in the kernel is an arrow that T multiplies by 0, which makes it an eigenvector with eigenvalue 0.

6. Maps: injective, surjective, isomorphism

A map (or mapping) is another name for a function: a rule that assigns to each element of one set exactly one element of another, written T : V → W. V is the domain and W is the codomain. In linear algebra, functions between vector spaces are usually called maps, and the ones that keep sums and scaling are linear maps. So "linear map" and "linear transformation" mean the same thing, though some books keep "transformation" for the case where the domain and codomain are the same space (V → V).

Maps are sorted by two questions: do outputs collide, and is everything reached?

NameMeaningHow to tell for a linear map
Injective (one-to-one)Different inputs go to different placesThe kernel is only 0
Surjective (onto)Every point of the codomain is reachedThe range is the whole codomain
BijectiveBoth injective and surjective. An inverse map existsThe kernel is only 0 and the range is the whole codomain

The link between injective and the kernel is the argument at the end of section 5. Surjective says the range (what is reached) equals the codomain (the stated target). The map decides the range, but we choose the codomain, so the two can differ.

MapInjectiveSurjectiveWhy
Rotating the planeyesyesThe kernel is only 0 and the range is the whole plane
Projecting the plane onto y = x (codomain: the plane)nonoThe (1, −1) direction goes to 0, and nothing off the line is reached
3D to the plane, (x, y, z) ↦ (x, y)noyesThe z axis goes to 0, but the plane is filled
The plane to 3D, (x, y) ↦ (x, y, 0)yesnoNothing collides, but points with z ≠ 0 are not reached

With matrices, the sizes alone settle some cases. An m × n matrix is a map from n dimensions to m dimensions. By rank-nullity, dim(kernel) = n − rank, so injective means "rank = n" and surjective means "rank = m". The rank cannot exceed the smaller of m and n, so a wide matrix (n > m) is never injective and a tall matrix (n < m) is never surjective. For a square matrix (n = m) the two hold or fail together, and they hold exactly when the inverse matrix exists.

A bijective linear map is an isomorphism, and two spaces joined by one are isomorphic: the elements have different names, but adding and scaling work the same way. In finite dimensions, two spaces are isomorphic exactly when they have the same dimension. For example, the polynomials a + bx + cx² of degree at most 2 are isomorphic to 3D coordinate space through the map to (a, b, c).

The map I(x) = x that leaves everything in place is the identity map, and its matrix is the identity matrix. The shortcut in a residual connection is this map.

7. A new basis changes the matrix: similar matrices

So far "the matrix of T" meant the matrix when coordinates are written in the standard basis e₁, e₂. Write coordinates in another basis and the same transformation gets different numbers.

Stand the new basis ℬ = {b₁, …, bₙ} up as the columns of a matrix P. Multiplying new coordinates [x]ℬ by P gives standard coordinates, and multiplying by P⁻¹ goes back (the change-of-basis matrix. That page calls this matrix B. Here it is P, because B is needed for the similar matrix).

𝐱=P[𝐱]ℬ,P=[𝐛1⋯𝐛n]

If the standard matrix of T is A, getting from new coordinates to new coordinates takes three steps: convert to standard coordinates (P), transform (A), and convert back (P⁻¹).

[T(𝐱)]ℬ=P−1T(𝐱)=P−1A𝐱=P−1AP[𝐱]ℬ

So the matrix of T in the new basis is P⁻¹AP. Two square matrices A and B are called similar matrices when some invertible matrix P satisfies the equation below. Similar matrices are the same linear transformation written in different bases.

B=P−1AP

Example: the projection in a basis that fits it

Take the projection onto the line y = x from section 3 again. For the new basis, pick the direction of the line, b₁ = (1, 1), and the direction at a right angle to it, b₂ = (1, −1).

A=[0.50.50.50.5],P=[111−1],P−1=12[111−1]

P−1AP=12[111−1][0.50.50.50.5][111−1]=12[111−1][1010]=[1000]

In the new basis the matrix is diagonal. What the projection does, "keep the b₁ direction (times 1) and send the b₂ direction to 0 (times 0)", is now readable straight from the numbers. In the standard matrix A all four entries were 0.5, which hid it.

What similar matrices share

They describe the same transformation, so anything that does not depend on the basis is the same for both.

ValueMeaningA and P⁻¹AP in the example
DeterminantHow much areas are scaled0 and 0
TraceSum of the diagonal entries0.5 + 0.5 = 1 and 1 + 0 = 1
RankDimension of the range1 and 1
EigenvaluesHow much vectors that keep their direction are scaled1 and 0 for both

The determinants agree because the determinant of a product is the product of the determinants.

det(P−1AP)=det(P−1)detAdetP=1detPdetAdetP=detA

Choose the basis from the eigenvectors and P⁻¹AP becomes diagonal. The example above is that case, and doing this is called diagonalization. Some books define P the other way round and write B = PAP⁻¹. That only swaps P and P⁻¹, so the meaning is the same.

8. Properties to know

PropertyIn plain wordsIn the lab
The origin stays at the originT(0) = 0. This is why a shift is not linearHowever you drag, the arrows start at the origin
Straight lines stay straightA line goes to a line or a single point, and even spacing stays evenThe faint grid
Where the basis goes decides everythingTwo linear transformations that send the basis to the same places are the same transformation. Those places, stood up as columns, are the matrixDragging just two tips moves the whole plane
Composition is matrix multiplicationIf T has matrix A and S has matrix B, doing T and then S is S(T(x)) = (BA)x. The one done first sits on the right (matrix multiplication)
Rank-nullity theoremdim(kernel) + dim(range) = dim(domain)The "1 + 1 = 2" in the readout

Where it is used

Common questions

Are a linear transformation and a matrix the same thing?

Once you pick a basis, each linear transformation gets exactly one matrix. The matrix is the transformation written down as numbers. If you change the basis, the same transformation gets different numbers. The transformation did not change, only the ruler you wrote it with.

y = 2x + 1 is a straight line, so why is it not a linear transformation?

Because "linear" here means something stricter than "the graph is a straight line". A linear transformation must send 0 to 0, but y = 2x + 1 sends 0 to 1. Sums break too. Putting in 1 and 2 gives 3 and 5, but putting in 1 + 2 = 3 gives 7, not 3 + 5 = 8. A function like this is a linear transformation plus a shift, and it is called an affine function.

Why can a projection not be undone?

Because its kernel holds arrows other than 0. Projecting onto the line y = x sends both (3, 1) and (2, 2) to (2, 2). Their difference (1, −1) lies in the kernel, so it was erased. Looking only at the output (2, 2), you cannot tell which input it came from. A transformation from the plane to the plane can be undone only when its kernel is just 0, and that is exactly when the determinant is not 0 and the inverse matrix exists.

Words

Word used hereTextbook name
A function that keeps sums and scalinglinear transformation, linear map
Scalingscalar multiplication
Basic arrows e₁, e₂standard basis
The matrix with T(e₁), T(e₂) as columnsmatrix of a linear transformation, standard matrix
Arrows squashed to 0kernel, null space
Everything that can be reachedrange, image, column space
Input space, output spacedomain, codomain
A rule that assigns one element to each elementmap, mapping, function
Different inputs go to different placesinjective, one-to-one
Every point of the codomain is reachedsurjective, onto
Both injective and surjectivebijective
A bijective linear mapisomorphism
The map that leaves everything in placeidentity map
dim(kernel) + dim(range) = dim(domain)rank-nullity theorem. dim(kernel) is the nullity, dim(range) is the rank
Shadow dropped at a right angle onto a lineorthogonal projection
A linear transformation plus a shiftaffine transformation
Adding a 1 to coordinates so shifts become matriceshomogeneous coordinates
Doing one transformation after anothercomposition
Two matrices for the same transformation in different basessimilar matrices. B = P⁻¹AP
The matrix P with the new basis as columnschange-of-basis matrix, transition matrix. Some books give this name to P⁻¹

Sources

← RankEigenvalues and eigenvectors →