Scaling and Reflection

Open any photo editor and you'll find three buttons that quietly do linear algebra. "Stretch" pulls an image wider without touching its height. "Squish" flattens it. "Flip horizontal" mirrors it, left for right, as if you'd held the picture up to a mirror. All three are the same kind of transformation — the plainest, most readable matrices there are — and all three are built from one method you already know: track where the basis vectors land.

Recall that a matrix is fully decided by where it sends \hat{\imath} = (1,0) and \hat{\jmath} = (0,1) — those two images become the matrix's columns. Scaling and reflection are the special case where each basis vector just slides up or down its own axis: \hat{\imath} never picks up a y-component, and \hat{\jmath} never picks up an x-component. That's exactly what makes the matrix diagonal.

This is worth pausing on, because it's rare: most transformation matrices you'll meet later — rotations, shears, projections — mix x and y together in every entry, and reading off "what does this do to a shape?" takes real work. A diagonal matrix is the one case where you can just glance at the two numbers on the diagonal and know exactly what happens to the whole plane: the first number is what happens sideways, the second is what happens vertically, and nothing else is going on.

Building the matrix: track the basis vectors

Suppose you want to scale the x-direction by a factor s_x and the y-direction by s_y. Ask the one question that always builds a matrix: where does \hat{\imath} go, and where does \hat{\jmath} go?

Write those two columns side by side and you have the scaling matrix:

\begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix}.

Every other entry is zero simply because neither basis vector ever strays off its own axis. With s_x = s_y the whole plane zooms in or out evenly; with them different, it squashes one way and stretches the other.

A reflection is the same idea taken to an extreme: instead of shrinking an axis towards zero, you carry on past it into negative territory. Send \hat{\imath} to (-1, 0) — a scale factor of exactly -1 — and leave \hat{\jmath} fixed at (0,1). The columns give

\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix},

the matrix that mirrors every point across the y-axis. Mirror across the x-axis instead by flipping \hat{\jmath} to (0,-1) and leaving \hat{\imath} alone: \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}.

Notice the pattern: to mirror across an axis, leave the basis vector on that axis alone and negate the one pointing away from it. Mirroring across the x-axis leaves \hat{\imath} (which already sits on that axis) untouched — only \hat{\jmath}, pointing away from it, gets flipped. Once you can see a mirror line this way, the same basis-vector bookkeeping builds the matrix for reflecting across almost any line through the origin, not only the two axes.

Worked example 1: stretch wide, squash flat

Build the matrix that doubles width and halves height. Doubling x means s_x = 2; halving y means s_y = \tfrac{1}{2}. Track the basis vectors: \hat{\imath} \to (2,0) and \hat{\jmath} \to (0, \tfrac12), giving

M = \begin{bmatrix} 2 & 0 \\ 0 & \tfrac12 \end{bmatrix}.

Apply it to the point (3, 4) the usual way, entry by entry down each row:

M \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \cdot 3 + 0 \cdot 4 \\ 0 \cdot 3 + \tfrac12 \cdot 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 2 \end{bmatrix}.

The point widens from x=3 to x=6 and flattens from y=4 down to y=2 — exactly "wider and flatter," in numbers. Notice the shape's area is unchanged overall: doubling one direction while halving the other multiplies area by 2 \times \tfrac12 = 1, a neat coincidence of this particular pair of factors, not a general rule.

Worked example 2: mirror across the x-axis

Build the matrix that reflects across the x-axis and use it on a triangle with corners A(1,2), B(3,1), C(2,4). From the basis-vector method above, that matrix is R = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}. Apply it to each corner:

R\begin{bmatrix}1\\2\end{bmatrix} = \begin{bmatrix}1\\-2\end{bmatrix}, \quad R\begin{bmatrix}3\\1\end{bmatrix} = \begin{bmatrix}3\\-1\end{bmatrix}, \quad R\begin{bmatrix}2\\4\end{bmatrix} = \begin{bmatrix}2\\-4\end{bmatrix}.

Every x-coordinate survived untouched; every y-coordinate simply changed sign. That's the signature of an x-axis reflection: it verifies itself — if a claimed reflection matrix ever moved the x-coordinates, it wasn't reflecting across the x-axis at all.

Worked example 3: mirror across the line y = x

Not every mirror line is an axis. To reflect across the diagonal line y = x, ask where the basis vectors land: a point on the x-axis like \hat{\imath}=(1,0) mirrors onto the y-axis at (0,1), and \hat{\jmath}=(0,1) mirrors onto (1,0). The columns swap places entirely:

S = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}.

Try it on (2, 5): S\begin{bmatrix}2\\5\end{bmatrix} = \begin{bmatrix}5\\2\end{bmatrix} — the coordinates simply trade places, which is exactly what "reflect across y=x" ought to mean. This matrix is its own transpose — flipping it across its own diagonal does nothing, because swapping rows and columns is the same operation as swapping x and y. Apply S twice and every point lands back where it started, which makes sense: mirror a mirror-image and you undo the mirror.

Stretch and flip, live

Set the two scale factors below and watch \hat{\imath} and \hat{\jmath} ride along the axes as the whole grid stretches with them. Push either slider below zero and that axis reflects, turning the grid inside out across the line — the diagonal matrix doesn't know the difference between "shrink to nothing and keep going" and "flip"; they're the same slider, the same formula, just a different sign.

Try to predict the label in the corner before you move a slider: with s_x = 2, s_y = -1, area should read |2 \times -1| = 2 and the grid should look flipped, since the product of the two factors is negative. Slide until you match it, then try to break your own prediction with a pair of factors like s_x = -1.5, s_y = -1 — two negatives together flip twice, which is the same as not flipping at all, so the grid should look unreflected even though both numbers are negative.

These two mix-ups catch almost everyone the first time round:

Because it is the same, in every app, on every device. When photo software flips an image left-to-right, it takes every pixel's coordinates and multiplies them by \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} — the exact matrix from this page. There's no special "mirror" algorithm hiding underneath; it's ordinary matrix multiplication applied millions of times, once per pixel, fast enough to feel instant.

Funhouse mirrors work the physical version of the other half of this page. A curved mirror that makes you tall and thin is stretching your reflection unevenly — squashing width, say, while barely touching height — the same uneven-scaling distortion from the "Watch out!" box above, just happening with light and glass instead of coordinates and a matrix.

The telltale signs

Scaling and reflection are the matrices you can read at a glance: everything lives on the diagonal, and every off-diagonal entry is zero. Their effect on area is just s_x \cdot s_y (each axis contributes its own factor independently), and a single negative factor secretly flips the plane's "handedness" — clockwise becomes counter-clockwise, like a right-hand glove turning into a left-hand one. Two ideas the determinant will soon make precise: it's exactly this signed area-scaling factor, for any matrix, not only the diagonal ones.

Put the three families of this page side by side and the pattern is unmistakable:

Every one of them, though, was built the very same way: decide where \hat{\imath} and \hat{\jmath} land, and write their landing spots down the columns. That one habit is the master key to every matrix you'll meet from here on, however tangled its entries look.

See it explained