A diagonal matrix is a square matrix whose entries outside the main diagonal are all zero. Its diagonal entries may be arbitrary, including zero. Diagonal matrices are fundamental in linear algebra because they represent transformations that act independently on coordinate directions, and because many matrix computations become elementary when a matrix is expressed in diagonal form.
Definition and notation
An matrix over a field is diagonal if
It is commonly written
For example,
is diagonal. The zero on its diagonal does not disqualify it; the defining restriction concerns only off-diagonal entries.
Important special cases include:
- The zero matrix, whose entries are all zero.
- The identity matrix .
- A scalar matrix , whose diagonal entries are all equal.
Every diagonal matrix is both upper triangular and lower triangular. Conversely, any square matrix that is both upper triangular and lower triangular is diagonal.
Some contexts also allow rectangular diagonal matrices: an matrix is called diagonal when its entry vanishes whenever . This convention is particularly useful in the singular value decomposition. Unless otherwise specified, “diagonal matrix” usually means a square matrix.
Interpretation as a linear transformation
Acting on a coordinate vector, a diagonal matrix gives
Each output coordinate depends only on the corresponding input coordinate: there is no mixing between coordinate directions.
Over the real numbers, multiplication by scales the -th coordinate. A negative value reverses its direction, while a zero value eliminates that component.
More generally, a linear map on a finite-dimensional vector space has a diagonal matrix relative to a basis precisely when
for every . Thus each basis vector is an eigenvector, with eigenvalue .
Diagonality is therefore basis-dependent. A transformation may have a diagonal matrix in one basis and a nondiagonal matrix in another.
Arithmetic and algebraic properties
Let
Addition and multiplication reduce to coordinatewise operations:
Consequently, diagonal matrices of the same size commute:
Together with scalar multiplication, these operations make the set of diagonal matrices a commutative algebra naturally identified with equipped with coordinatewise multiplication.
A diagonal matrix need not commute with an arbitrary matrix. For ,
Thus left multiplication by scales rows, whereas right multiplication scales columns. Moreover,
If all are distinct, every matrix commuting with must itself be diagonal. Repeated diagonal entries allow additional nonzero entries within the corresponding coordinate blocks.
Inverses and powers
A diagonal matrix is invertible exactly when every diagonal entry is nonzero. Its inverse is then
For every positive integer ,
and . Negative integer powers are defined when is invertible.
Determinant, trace, and rank
The principal numerical invariants are immediately available:
These are its determinant and trace. Its rank is the number of nonzero diagonal entries.
Its null space is spanned by the coordinate vectors corresponding to zero diagonal entries. Its image is spanned by those corresponding to nonzero diagonal entries.
Eigenvalues and diagonalization
The eigenvalues of are exactly its diagonal entries, counted with algebraic multiplicity. Its characteristic polynomial, using the convention , is
For an eigenvalue , the eigenspace consists of all vectors whose nonzero coordinates occur only at indices satisfying . Its dimension therefore equals the number of occurrences of on the diagonal.
Diagonal matrices versus diagonalizable matrices
A matrix is diagonalizable over if there is an invertible matrix such that
for a diagonal matrix . The columns of form a basis of eigenvectors of . This is a similarity transformation, and the process is called matrix diagonalization.
A diagonal matrix is already diagonal in the given basis; a diagonalizable matrix need not be. Not every matrix is diagonalizable. For example,
has only one linearly independent eigenvector and cannot be made diagonal by similarity.
Diagonalizability also depends on the underlying field. A real matrix may be diagonalizable over the complex numbers but not over the real numbers.
The spectral theorem provides important sufficient conditions:
- Every real symmetric matrix has an orthonormal basis of real eigenvectors and can be written , where is an orthogonal matrix.
- Every complex Hermitian matrix has a diagonalization , where is a unitary matrix and is real diagonal.
- More generally, every complex normal matrix is unitarily diagonalizable, although its eigenvalues need not be real.
Transpose, positivity, and matrix functions
Every diagonal matrix equals its transpose:
For complex entries, however, its conjugate transpose is
Thus a complex diagonal matrix is Hermitian exactly when all its diagonal entries are real. Every complex diagonal matrix is normal.
A real diagonal matrix is a positive-definite matrix exactly when all , since
It is positive semidefinite exactly when all .
For a polynomial ,
The same coordinatewise rule applies to functions defined by convergent power series where those series converge. For example,
This makes diagonal form especially useful for computing matrix powers, exponentials, and other matrix functions. When , polynomial evaluation gives
Computation and applications
A diagonal matrix can be stored using only its diagonal entries rather than entries. Matrix–vector multiplication then requires arithmetic operations. Diagonal matrices are consequently an important special case of sparse matrices.
For a linear system with every , the solution is simply
If , the corresponding equation is consistent only when ; in that case, is unrestricted.
In the Euclidean operator norm, a nonsingular real or complex diagonal matrix has condition number
Thus easy arithmetic does not guarantee good numerical conditioning: very small diagonal magnitudes relative to the largest can make a diagonal system sensitive to perturbations.
Other important uses include:
- Differential equations. Diagonalizing a constant coefficient matrix can separate a coupled linear differential system into independent scalar equations.
- Statistics. A diagonal covariance matrix indicates zero pairwise covariance between distinct components. This does not, in general, imply statistical independence.
- Matrix factorization. The singular value decomposition expresses a real or complex matrix using orthogonal or unitary factors and a possibly rectangular diagonal matrix of nonnegative singular values. Unlike similarity diagonalization, it applies to every matrix.
- Coordinate scaling. Diagonal matrices implement coordinatewise weighting and changes of scale, including rescaling variables in numerical algorithms.