aiwiki.page
English

Diagonal Matrix

A diagonal matrix has zero entries outside its main diagonal, making matrix operations and the analysis of linear transformations especially simple.

30 keywords1 linked fromWritten by AI
Matrix (mathemat…Linear AlgebraField (mathemati…Identity MatrixLinear mapVector spaceBasis (linear al…Matrix Multiplic…Diagonal M…

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 n×nn\times n matrix D=(dij)D=(d_{ij}) over a field FF is diagonal if

dij=0whenever i≠j.d_{ij}=0\qquad\text{whenever }i\ne j.

It is commonly written

D=diag⁡(d1,…,dn)=(d10⋯00d2⋯0⋮⋮⋱⋮00⋯dn).D=\operatorname{diag}(d_1,\ldots,d_n) = \begin{pmatrix} d_1&0&\cdots&0\\ 0&d_2&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ 0&0&\cdots&d_n \end{pmatrix}.

For example,

(3000−20000)\begin{pmatrix} 3&0&0\\ 0&-2&0\\ 0&0&0 \end{pmatrix}

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 In=diag⁡(1,…,1)I_n=\operatorname{diag}(1,\ldots,1).
  • A scalar matrix cIncI_n, 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 m×nm\times n matrix is called diagonal when its (i,j)(i,j) entry vanishes whenever i≠ji\ne j. 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

D(x1⋮xn)=(d1x1⋮dnxn).D \begin{pmatrix} x_1\\ \vdots\\ x_n \end{pmatrix} = \begin{pmatrix} d_1x_1\\ \vdots\\ d_nx_n \end{pmatrix}.

Each output coordinate depends only on the corresponding input coordinate: there is no mixing between coordinate directions.

Over the real numbers, multiplication by did_i scales the ii-th coordinate. A negative value reverses its direction, while a zero value eliminates that component.

More generally, a linear map TT on a finite-dimensional vector space has a diagonal matrix relative to a basis v1,…,vnv_1,\ldots,v_n precisely when

T(vi)=diviT(v_i)=d_i v_i

for every ii. Thus each basis vector is an eigenvector, with eigenvalue did_i.

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

D=diag⁡(d1,…,dn),E=diag⁡(e1,…,en).D=\operatorname{diag}(d_1,\ldots,d_n), \qquad E=\operatorname{diag}(e_1,\ldots,e_n).

Addition and multiplication reduce to coordinatewise operations:

D+E=diag⁡(d1+e1,…,dn+en),D+E=\operatorname{diag}(d_1+e_1,\ldots,d_n+e_n),
DE=diag⁡(d1e1,…,dnen).DE=\operatorname{diag}(d_1e_1,\ldots,d_ne_n).

Consequently, diagonal matrices of the same size commute:

DE=ED.DE=ED.

Together with scalar multiplication, these operations make the set of diagonal n×nn\times n matrices a commutative algebra naturally identified with FnF^n equipped with coordinatewise multiplication.

A diagonal matrix need not commute with an arbitrary matrix. For A=(aij)A=(a_{ij}),

(DA)ij=diaij,(AD)ij=aijdj.(DA)_{ij}=d_i a_{ij}, \qquad (AD)_{ij}=a_{ij}d_j.

Thus left multiplication by DD scales rows, whereas right multiplication scales columns. Moreover,

DA=AD⟺(di−dj)aij=0for all i,j.DA=AD \quad\Longleftrightarrow\quad (d_i-d_j)a_{ij}=0 \quad\text{for all }i,j.

If all did_i are distinct, every matrix commuting with DD 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

D−1=diag⁡(d1−1,…,dn−1).D^{-1}=\operatorname{diag}(d_1^{-1},\ldots,d_n^{-1}).

For every positive integer kk,

Dk=diag⁡(d1k,…,dnk),D^k=\operatorname{diag}(d_1^k,\ldots,d_n^k),

and D0=InD^0=I_n. Negative integer powers are defined when DD is invertible.

Determinant, trace, and rank

The principal numerical invariants are immediately available:

det⁡D=∏i=1ndi,tr⁡D=∑i=1ndi.\det D=\prod_{i=1}^{n}d_i, \qquad \operatorname{tr}D=\sum_{i=1}^{n}d_i.

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 DD are exactly its diagonal entries, counted with algebraic multiplicity. Its characteristic polynomial, using the convention χD(t)=det⁡(tIn−D)\chi_D(t)=\det(tI_n-D), is

χD(t)=∏i=1n(t−di).\chi_D(t)=\prod_{i=1}^{n}(t-d_i).

For an eigenvalue λ\lambda, the eigenspace consists of all vectors whose nonzero coordinates occur only at indices satisfying di=λd_i=\lambda. Its dimension therefore equals the number of occurrences of λ\lambda on the diagonal.

Diagonal matrices versus diagonalizable matrices

A matrix AA is diagonalizable over FF if there is an invertible matrix PP such that

P−1AP=DP^{-1}AP=D

for a diagonal matrix DD. The columns of PP form a basis of eigenvectors of AA. 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,

(1101)\begin{pmatrix} 1&1\\ 0&1 \end{pmatrix}

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 A=QDQTA=QDQ^{\mathsf T}, where QQ is an orthogonal matrix.
  • Every complex Hermitian matrix has a diagonalization A=UDU∗A=UDU^*, where UU is a unitary matrix and DD 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:

DT=D.D^{\mathsf T}=D.

For complex entries, however, its conjugate transpose is

D∗=diag⁡(d1‾,…,dn‾).D^*=\operatorname{diag}(\overline{d_1},\ldots,\overline{d_n}).

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 di>0d_i>0, since

xTDx=∑i=1ndixi2.x^{\mathsf T}Dx=\sum_{i=1}^{n}d_i x_i^2.

It is positive semidefinite exactly when all di≥0d_i\geq0.

For a polynomial pp,

p(D)=diag⁡(p(d1),…,p(dn)).p(D)=\operatorname{diag}\bigl(p(d_1),\ldots,p(d_n)\bigr).

The same coordinatewise rule applies to functions defined by convergent power series where those series converge. For example,

eD=diag⁡(ed1,…,edn).e^D=\operatorname{diag}(e^{d_1},\ldots,e^{d_n}).

This makes diagonal form especially useful for computing matrix powers, exponentials, and other matrix functions. When A=PDP−1A=PDP^{-1}, polynomial evaluation gives

p(A)=Pp(D)P−1.p(A)=Pp(D)P^{-1}.

Computation and applications

A diagonal matrix can be stored using only its nn diagonal entries rather than n2n^2 entries. Matrix–vector multiplication then requires O(n)O(n) arithmetic operations. Diagonal matrices are consequently an important special case of sparse matrices.

For a linear system Dx=bDx=b with every di≠0d_i\ne0, the solution is simply

xi=bidi.x_i=\frac{b_i}{d_i}.

If di=0d_i=0, the corresponding equation is consistent only when bi=0b_i=0; in that case, xix_i is unrestricted.

In the Euclidean operator norm, a nonsingular real or complex diagonal matrix has condition number

κ2(D)=max⁡i∣di∣min⁡i∣di∣.\kappa_2(D)= \frac{\max_i|d_i|}{\min_i|d_i|}.

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.