explainer
Matrix transpose and inverse: when do they agree?
Transpose rectangular matrices, calculate a 2×2 inverse, and test when a transpose reverses a transformation. Explore rotations, reflections, and singular maps.
What you will learn
- Transpose a rectangular matrix by swapping row and column indices.
- Verify an inverse through multiplication by the original matrix.
- Explain why orthogonal matrices have inverse equal to transpose.
- Reverse the order when transposing or inverting a matrix product.
Before you start
A transpose rearranges a matrix's entries. An inverse undoes its action on every input. They agree for rotations and reflections, but a simple shear shows why that agreement needs a condition.
We will use real matrices and column vectors throughout. Start with matrix multiplication if applying a matrix to a vector is new.
Swap rows and columns
The transpose of A, written Aᵀ, moves entry (i, j) to position (j, i):
(Aᵀ)ⱼᵢ = Aᵢⱼ
m × n → n × m
For A with rows (1, 2, 3) and (4, 5, 6), the transpose has rows (1, 4), (2, 5), and (3, 6). The first row becomes the first column. Every value stays the same.
This works for rectangular matrices. Transposing twice returns the original: (Aᵀ)ᵀ = A. A square matrix satisfying Aᵀ = A is symmetric.
Array software also tracks dimensions. In NumPy, transposing a one-dimensional array leaves its shape unchanged. An explicit row or column array needs two dimensions. NumPy's transpose documentation explains these cases.
Define what it means to undo a matrix
For a square matrix A, its inverse A⁻¹ satisfies both products:
A⁻¹A = AA⁻¹ = I
The identity matrix I leaves every input unchanged. If y = Av, applying A⁻¹ gives A⁻¹y = v. SciPy's linear algebra guide introduces the inverse through the identity product.
Here, “inverse” means the ordinary two-sided inverse. A rectangular matrix cannot have one. One-sided inverses and pseudoinverses address other questions; a transpose alone does not establish either property.
The −1 in A⁻¹ does not mean taking the reciprocal of each entry. Matrix multiplication, including its sums across rows and columns, determines the inverse.
Invert a shear by hand
Use A with rows (1, 1) and (0, 1). It sends (x, y) to (x + y, y). To reverse it, subtract the second output coordinate from the first.
For a general 2×2 matrix, let Δ = ad − bc:
A = [a, b; c, d]
A⁻¹ = (1/Δ)[d, −b; −c, a], when Δ ≠ 0
Semicolons separate rows in this compact notation. Our shear has Δ = 1, so:
| Matrix | First row | Second row |
|---|---|---|
| A | 1, 1 | 0, 1 |
| Aᵀ | 1, 0 | 1, 1 |
| A⁻¹ | 1, −1 | 0, 1 |
Start with v = (2, 1). Applying A gives (3, 1). The inverse returns (3 − 1, 1) = (2, 1), while the transpose gives (3, 3 + 1) = (3, 4).
Check A⁻¹A: its rows are (1, 0) and (0, 1), so it is I. Checking AA⁻¹ gives the same identity.
Compare two attempts to recover the input
The default example reproduces the shear calculation. The plot compares the input with the results of applying Aᵀ or A⁻¹ after A.
Try Quarter-turn (90°) and Reflection across x. Both recovery results meet the original input. The readout checks the matrices themselves, so it describes all inputs.
Then choose the zero input under the shear. Every linear map sends zero to zero, so matching that one result proves very little. Return to (2, 1) to expose the difference.
The rectangular preset focuses on transposition. Its input has three coordinates, so the two-coordinate input control becomes inactive.
Recognize when transpose equals inverse
A real square matrix Q is orthogonal when QᵀQ = I. Its columns have unit Euclidean length and zero dot products with one another. These conditions give Q⁻¹ = Qᵀ. The QR factorization lab at Florida State University states this relationship and its length-preserving consequence.
The quarter-turn matrix sends (x, y) to (−y, x). Its transpose sends the result back. The reflection matrix sends (x, y) to (x, −y) and reverses itself. Both are orthogonal. A reflection reverses orientation, so it is not a rotation.
Symmetry is a different condition. The matrix 2I is symmetric, but its inverse is 0.5I. The quarter-turn is orthogonal without being symmetric.
In robotics, a rotation R can map displacement coordinates between orthonormal frames, with Rᵀ providing the reverse mapping. If points also include translation t, use p_world = Rp_robot + t. Recover them with p_robot = Rᵀ(p_world − t). The translation needs its own reversal. The coordinate frames lesson shows that reversal on a fixed landmark; homogeneous transformations combine both operations in one matrix.
Reverse the order of a composition
For invertible square A and B, AB applies B first, then A. Undo A first, then B:
(AB)⁻¹ = B⁻¹A⁻¹
(AB)(B⁻¹A⁻¹) = A(BB⁻¹)A⁻¹ = I
Transposing also reverses product order: (AB)ᵀ = BᵀAᵀ. This identity applies whenever AB is defined, including compatible rectangular matrices. For A shaped m×n and B shaped n×p, both sides have shape p×m.
For one invertible matrix, (Aᵀ)⁻¹ = (A⁻¹)ᵀ: transpose and inversion can happen in either order. Gilbert Strang's MIT lecture derives these identities.
Identify the information an inverse needs
The Singular: discard y preset sends (x, y) to (x, 0). Inputs (2, 1) and (2, 9) both produce (2, 0). No function of that output alone can know which input to return.
This matrix is singular, meaning it has no inverse. Its transpose still exists and equals the original matrix. Transposing again cannot restore the lost coordinate.
For a square matrix, a nonzero determinant is equivalent to invertibility in exact arithmetic. Rank and null space describe the lost information: here the nonzero direction (0, 1) maps to zero.
Solve equations without forming an inverse
The equation Ax = b has solution x = A⁻¹b when A is invertible. To compute x, normally use a linear-system solver, such as solve(A, b). Explicitly building the inverse creates work that this task does not require and can worsen numerical error. SciPy recommends solving the system directly.
An inverse can exist mathematically while floating-point calculations lose accuracy. A condition number helps assess the relative sensitivity of a solve. NumPy's inverse documentation explains why an inversion can return inaccurate results without raising an error.
A small determinant alone does not diagnose this problem. The two-by-two matrix 10⁻⁶I₂ has determinant 10⁻¹² but 2-norm condition number 1: it scales every direction equally. The diagonal matrix with entries 10⁶ and 10⁻⁶ has determinant 1 but condition number 10¹².
For rectangular systems, the least squares lesson explains the residual a solver minimizes. Use appropriate solvers and conditioning checks for measured data. The fixed examples here make the identities visible; they do not replace numerical analysis.
Check the identities in Python
This standard-library example uses exact fractions for the 2×2 inverse formula. It reproduces the shear calculation without rounding. It assumes rectangular input arrays and uses the inverse helper only on 2×2 matrices.
from fractions import Fraction
def transpose(a):
return [list(column) for column in zip(*a)]
def inverse2(a):
(p, q), (r, s) = [[Fraction(x) for x in row] for row in a]
determinant = p * s - q * r
if determinant == 0:
return None
return [[s / determinant, -q / determinant],
[-r / determinant, p / determinant]]
def apply(a, v):
return [sum(x * y for x, y in zip(row, v)) for row in a]
def vector_text(v):
return "(" + ", ".join(str(x) for x in v) + ")"
a = [[1, 1], [0, 1]]
v = [2, 1]
after = apply(a, v)
print("A transpose:", transpose(a))
print("After A:", vector_text(after))
print("After transpose:", vector_text(apply(transpose(a), after)))
print("After inverse:", vector_text(apply(inverse2(a), after)))
print("Singular inverse:", inverse2([[1, 0], [0, 0]]))
print("Rectangular transpose:", transpose([[1, 2, 3], [4, 5, 6]]))
assert transpose(transpose(a)) == a
Expected output:
A transpose: [[1, 0], [1, 1]]
After A: (3, 1)
After transpose: (3, 4)
After inverse: (2, 1)
Singular inverse: None
Rectangular transpose: [[1, 4], [2, 5], [3, 6]]
Try it yourself
Exercise 1. A has rows (1, 2, 3) and (0, 1, 4). Find Aᵀ and its shape. Does A have an ordinary two-sided inverse?
Show solution: move each row into a column
Aᵀ has rows (1, 0), (2, 1), and (3, 4). Its shape is 3×2. Transposing it again recovers the original 2×3 matrix.
A is rectangular, so it has no ordinary two-sided inverse. This does not prevent transposition.
Exercise 2. Compare Q = diag(1, −1) with S = diag(2, 0.5). For each, find its transpose and inverse. Which is orthogonal? Does symmetry settle that question?
Show solution: check the identity product
Both are diagonal and symmetric, so Qᵀ = Q and Sᵀ = S. Q⁻¹ = Q, and QᵀQ = I. Q is orthogonal.
S⁻¹ = diag(0.5, 2), while SᵀS = diag(4, 0.25). S is not orthogonal. Symmetry establishes equality with the transpose, not with the inverse.
Sources and further study
- NumPy: transpose, for dimension and axis behavior.
- SciPy: Linear Algebra, for inverses and direct linear-system solves.
- MIT, Gilbert Strang: Lecture 4 transcript, for product and transpose identities.
- Florida State University: QR Factorizations, for orthogonal matrices and preserved Euclidean length.
- NumPy: linalg.inv, for inversion errors and numerical conditioning.