The Transpose
Imagine a spreadsheet with one row per student and one column per subject — each cell holds a
test score. Now imagine you need the opposite layout: one row per subject, one column per
student, so a teacher marking Maths can scan straight down a single row. You don't have to
retype a single number. You just flip the table over its diagonal, and rows become
columns automatically. That flip is called the transpose.
We mark the transpose of a matrix A with a small
\mathsf{T}:
A = \begin{bmatrix} 2 & -1 & 0 \\ 3 & 5 & 4 \end{bmatrix} \;\longrightarrow\; A^{\mathsf{T}} = \begin{bmatrix} 2 & 3 \\ -1 & 5 \\ 0 & 4 \end{bmatrix}.
Entry by entry, the rule is simply (A^{\mathsf{T}})_{ij} = A_{ji} —
swap the row and column index. Whatever sat in row i, column
j of A now sits in row
j, column i of A^{\mathsf{T}}.
A 2\times 3 matrix transposes into a 3\times 2
one; the shape turns on its side. It looks like a purely cosmetic rearrangement — but it's also the
secret ingredient that lets us write the dot product
of two vectors as ordinary matrix multiplication, as you'll see below.
Watch the flip
Step through the entries. Each highlighted number in A lands in the
mirror-image position of A^{\mathsf{T}} — row and column swapped. Notice
that the two diagonal entries, 2 and 5,
never leave their spot; only the off-diagonal entries trade places across the fold line.
Worked example: transposing by hand
Let's build a transpose from scratch, one entry at a time, with a fresh matrix:
C = \begin{bmatrix} 7 & 1 & -2 \\ 0 & 4 & 9 \end{bmatrix}.
C is 2\times 3 — two rows, three columns.
To build C^{\mathsf{T}}, take row 1 of C,
(7,\,1,\,-2), and lay it down as column 1 of
C^{\mathsf{T}}. Then take row 2, (0,\,4,\,9),
and lay it down as column 2:
C^{\mathsf{T}} = \begin{bmatrix} 7 & 0 \\ 1 & 4 \\ -2 & 9 \end{bmatrix}.
Check the shape: C was 2\times 3 (2 rows, 3
columns) and C^{\mathsf{T}} is 3\times 2 (3
rows, 2 columns) — the two dimensions have swapped places. That's not a coincidence: an
m\times n matrix always transposes into an
n\times m one.
Worked example: pivoting a real table
Suppose a weather app records the temperature (in °C) at three cities over five days — rows are
days, columns are cities:
T = \begin{array}{c|ccc} & \text{London} & \text{Paris} & \text{Berlin} \\ \hline \text{Mon} & 14 & 17 & 12 \\ \text{Tue} & 15 & 18 & 13 \\ \text{Wed} & 13 & 16 & 11 \\ \text{Thu} & 16 & 19 & 14 \\ \text{Fri} & 15 & 17 & 12 \end{array}
Reading straight across a row of T answers "what was the weather like
on Tuesday, everywhere?" Now transpose it. Cities become the rows, days become the
columns:
T^{\mathsf{T}} = \begin{array}{c|ccccc} & \text{Mon} & \text{Tue} & \text{Wed} & \text{Thu} & \text{Fri} \\ \hline \text{London} & 14 & 15 & 13 & 16 & 15 \\ \text{Paris} & 17 & 18 & 16 & 19 & 17 \\ \text{Berlin} & 12 & 13 & 11 & 14 & 12 \end{array}
Now reading straight across a row answers a completely different question: "how did
Paris change over the week?" No number moved to the wrong city or the wrong day — the
transpose just changed which direction you read in. This exact operation has a name in every
spreadsheet program: it's called a pivot.
The double flip returns you home
What happens if you transpose a matrix, then transpose the result again? Try it on a small
example:
D = \begin{bmatrix} 3 & -5 \\ 8 & 2 \end{bmatrix} \;\longrightarrow\; D^{\mathsf{T}} = \begin{bmatrix} 3 & 8 \\ -5 & 2 \end{bmatrix} \;\longrightarrow\; (D^{\mathsf{T}})^{\mathsf{T}} = \begin{bmatrix} 3 & -5 \\ 8 & 2 \end{bmatrix} = D.
Flipping a page over swaps its front and back — flip it a second time and you're back to reading
the front, exactly as it started. The transpose behaves the same way: it's its own perfect undo.
For any matrix A:
- (A^{\mathsf{T}})^{\mathsf{T}} = A — transposing twice recovers
the original matrix exactly.
- If A is m\times n, then
A^{\mathsf{T}} is n\times m, and
(A^{\mathsf{T}})^{\mathsf{T}} is back to
m\times n.
Worked example: the dot product in disguise
Here's the payoff promised earlier. Take two column vectors:
\vec{u} = \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}, \qquad \vec{v} = \begin{bmatrix} 4 \\ -1 \\ 2 \end{bmatrix}.
Their ordinary dot product multiplies matching entries and adds:
\vec{u}\cdot\vec{v} = 1(4) + 2(-1) + 3(2) = 4 - 2 + 6 = 8. Now transpose
\vec{u} — a 3\times 1 column becomes a
1\times 3 row, \vec{u}^{\mathsf{T}} = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}
— and multiply it by \vec{v} as a matrix product:
\vec{u}^{\mathsf{T}}\vec{v} = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}\begin{bmatrix} 4 \\ -1 \\ 2 \end{bmatrix} = 1(4) + 2(-1) + 3(2) = 8.
Exactly the same number. A 1\times 3 row times a
3\times 1 column is the only shape combination that multiplies down to
a bare 1\times 1 number — which is exactly what a dot product is
supposed to produce. The transpose is what makes that shape line up.
When the flip changes nothing: symmetric matrices
Most of the time A^{\mathsf{T}} looks nothing like
A — the shape itself might even change. But every so often, flipping a
matrix across its diagonal lands every entry back exactly where it started. Such a matrix is called
symmetric:
A = A^{\mathsf{T}}.
Here's a symmetric matrix with a very natural meaning — road distances (in km) between three
cities:
D = \begin{array}{c|ccc} & A & B & C \\ \hline A & 0 & 120 & 340 \\ B & 120 & 0 & 260 \\ C & 340 & 260 & 0 \end{array}
Entry D_{AB} = 120 is the distance from city A to city B. Entry
D_{BA} = 120 too — the distance from B back to A is exactly the same
road, walked the other way. Because D_{ij} = D_{ji} for every pair,
D = D^{\mathsf{T}}: transposing this matrix does absolutely nothing to
it. The zeros running down the diagonal make sense too — the distance from any city to itself is
zero, and diagonal entries never move under a transpose anyway.
Symmetric matrices aren't a curiosity — they're everywhere a quantity is measured
between pairs of things rather than belonging to one thing alone, which is also exactly
why the dot product hides a transpose inside it: writing two column vectors
\vec{u} and \vec{v}, their dot product is
\vec{u}\cdot\vec{v} = \vec{u}^{\mathsf{T}}\vec{v} — a
1\times n row multiplied by an n\times 1
column, which is precisely the shape matrix multiplication needs to produce a single number.
Two mistakes catch almost everyone the first time they meet the transpose:
-
The dimensions don't survive unless the matrix is square. An
m\times n matrix becomes n\times m —
not another m\times n matrix. Only when
m = n (a square matrix) does the shape stay the same after
transposing — the entries can still move even then, just within the same square outline.
-
The diagonal entries never move. The rule (A^{\mathsf{T}})_{ij}=A_{ji}
only relocates an entry when i \ne j. When i = j
(a diagonal entry) it just swaps with itself — that is, it stays exactly where it is. Only the
off-diagonal pairs actually trade places.
Once you know to look, symmetric matrices show up constantly. A
correlation matrix in statistics records how strongly every pair of variables
moves together — the correlation between height and weight is the same number as between weight
and height, so the matrix is automatically symmetric. An
adjacency matrix of an ordinary (non-directional) friendship network works the
same way: if the matrix entry says "Amir is friends with Beatriz," the mirrored entry says
"Beatriz is friends with Amir" — and since friendship goes both ways, the two entries always agree.
And that "pivot" move from the temperature table above isn't just a maths-class trick — it's the
literal name of the button in Excel and Google Sheets that turns a "rows of records" table into a
"summary by category" table. Every time you click Pivot Table, you're asking the
spreadsheet to transpose (and often also summarise) your data for you.
The idea even has a slightly grand history: the word "matrix" itself, and much of the notation we
still use for it — including treating rows and columns as interchangeable operations like the
transpose — was hammered out by the English mathematician Arthur Cayley in the
1850s, while he was working as a full-time lawyer and doing mathematics as a hobby in the evenings.
A tool he sketched for fun now runs underneath almost every spreadsheet, image filter and
machine-learning model on Earth.
See it explained