Matrix Transpose Calculator

Swap rows and columns of any matrix. Learn transpose properties, symmetric matrices, orthogonal matrices, and how the transpose powers gradient computation in machine learning.

Transpose Definition and Notation

The transpose of a matrix A, written AT (also denoted A′ or At), is obtained by swapping rows and columns. Formally:

AT[i][j] = A[j][i]

If A is an m × n matrix, then AT is n × m. The first row of A becomes the first column of AT, the second row becomes the second column, and so on. For example, if A = [[1, 2, 3], [4, 5, 6]] (a 2×3 matrix), then AT = [[1, 4], [2, 5], [3, 6]] (a 3×2 matrix).

The transpose of a column vector is a row vector, and vice versa. This is particularly important in linear algebra notation: the dot product of two column vectors u and v can be written as uTv, producing a 1×1 matrix (a scalar). The outer product is uvT, producing an n×n matrix from two n×1 vectors.

Key Properties of the Transpose

The transpose satisfies several algebraic identities that are used constantly in proofs and derivations:

Double transpose: (AT)T = A. Transposing twice returns the original matrix.

Sum rule: (A + B)T = AT + BT. Transposing distributes over addition.

Scalar rule: (cA)T = cAT. Scalars pass through the transpose.

Product rule: (AB)T = BTAT. The order reverses. This extends to any number of factors: (ABC)T = CTBTAT.

Determinant: det(AT) = det(A). Transposing does not change the determinant.

Inverse: (AT)-1 = (A-1)T. The transpose and inverse operations commute.

Symmetric and Orthogonal Matrices

A symmetric matrix is one that equals its own transpose: A = AT. This means a[i][j] = a[j][i] for every pair of indices — the matrix is mirrored across its main diagonal. Symmetric matrices must be square. The covariance matrix in statistics, computed as (1/n)XTX (where X is the centered data matrix), is always symmetric. Symmetric matrices have the special property that all their eigenvalues are real (never complex), and they can always be diagonalized by an orthogonal matrix (the spectral theorem).

An orthogonal matrix Q satisfies QTQ = QQT = I, meaning QT = Q-1. The columns of Q are orthonormal: they have unit length and are mutually perpendicular. Orthogonal matrices represent rotations (when det = +1) and reflections (when det = -1). They preserve lengths, angles, and distances, making them essential in computer graphics, signal processing, and numerical linear algebra. The Gram-Schmidt process, Householder reflections, and Givens rotations all produce orthogonal matrices.

Transpose in Machine Learning

The transpose is ubiquitous in machine learning computations. In a neural network layer computing y = Wx + b, the gradient of the loss with respect to the input x involves WT: ∂L/∂x = WT · ∂L/∂y. This is why backpropagation through a linear layer multiplies the incoming gradient by the transposed weight matrix.

The normal equation for linear regression is w = (XTX)-1XTy, where XTX is a square matrix (the Gram matrix) even when X is not square. In attention mechanisms, the similarity between queries Q and keys K is computed as QKT, a matrix product that pairs every query with every key. The SVD (Singular Value Decomposition) factors any m×n matrix as A = UΣVT, where U and V are orthogonal matrices. This decomposition powers latent semantic analysis, recommendation systems, and image compression.

Frequently Asked Questions

What does transposing a matrix do?

Transposing a matrix swaps its rows and columns. The element at row i, column j moves to row j, column i. If the original matrix has dimensions m × n, the transpose has dimensions n × m. For example, a 3×2 matrix becomes a 2×3 matrix. The first row of the original becomes the first column of the transpose.

What is a symmetric matrix?

A symmetric matrix equals its own transpose: A = AT. This means a[i][j] = a[j][i] for all entries, so the matrix is mirrored across its main diagonal. Symmetric matrices are always square, have real eigenvalues, and can be diagonalized by an orthogonal matrix. The covariance matrix in statistics is always symmetric.

What is the transpose of a product (AB)T?

The transpose of a product reverses the order: (AB)T = BTAT. This reversal rule extends to any number of factors: (ABC)T = CTBTAT. This property is essential in deriving gradient formulas for neural networks during backpropagation.

What is an orthogonal matrix?

An orthogonal matrix Q satisfies QTQ = I, meaning its transpose equals its inverse: QT = Q-1. The columns of an orthogonal matrix are orthonormal (unit length and mutually perpendicular). Orthogonal matrices preserve lengths and angles, so they represent rotations and reflections. Their determinant is always +1 (rotation) or -1 (reflection).

How is the transpose used in machine learning?

The transpose appears throughout machine learning. In gradient computation, the gradient of a loss with respect to weights involves transposed Jacobian matrices. The normal equation for linear regression uses XT: w = (XTX)-1XTy. Covariance matrices are computed as (1/n)XTX. Attention mechanisms in transformers compute QKT to measure similarity between queries and keys.

Related Tools

Built by Michael Lip. Try the ML3X Matrix Calculator for interactive step-by-step solutions.