What Is a Diagonal Matrix? Definition and Properties

A diagonal matrix is a square matrix where every entry outside the main diagonal is zero. Only the entries running from the top-left corner to the bottom-right corner can be nonzero. For a 3×3 example, imagine a grid of nine numbers where the six off-diagonal slots are all zero and only the three slots at positions (1,1), (2,2), and (3,3) hold values. This simple structure makes diagonal matrices extraordinarily easy to work with, which is why they show up constantly in linear algebra, data science, and engineering.

The Formal Definition

A diagonal matrix is an n × n square matrix D where the entry at row i and column j equals zero whenever i ≠ j. The entries along the main diagonal (where the row number equals the column number) can be any value, including zero. You’ll often see a diagonal matrix written in shorthand as D = diag(d₁, d₂, …, dₙ), listing only the diagonal entries because everything else is understood to be zero.

Because the definition requires equal numbers of rows and columns, a 2×3 or 4×5 matrix cannot be diagonal. The matrix must be square.

Why Diagonal Matrices Are Easy to Compute

Most matrix operations that normally involve tedious calculations become almost trivial with diagonal matrices. That simplicity is their main appeal.

Addition and scalar multiplication. Adding two diagonal matrices just means adding the corresponding diagonal entries: diag(s₁, s₂, …, sₙ) + diag(t₁, t₂, …, tₙ) = diag(s₁+t₁, s₂+t₂, …, sₙ+tₙ). Multiplying by a constant r scales each diagonal entry by r.

Multiplying two diagonal matrices. You multiply the matching diagonal entries: diag(s₁, s₂, …, sₙ) × diag(t₁, t₂, …, tₙ) = diag(s₁t₁, s₂t₂, …, sₙtₙ). Notably, diagonal matrices always commute, meaning A × B = B × A. That’s a property most matrices don’t share.

Multiplying a diagonal matrix by a regular matrix. When a diagonal matrix D multiplies a regular matrix A from the left (D × A), it scales each row of A by the corresponding diagonal entry. When D multiplies from the right (A × D), it scales each column instead. This makes diagonal matrices natural tools for rescaling data along specific dimensions.

Determinant, Trace, and Inverse

The determinant of a diagonal matrix is the product of its diagonal entries. For diag(3, 5, 2), the determinant is simply 3 × 5 × 2 = 30. No cofactor expansion or row reduction needed.

The trace (the sum of the diagonal entries) is equally straightforward: for that same matrix, the trace is 3 + 5 + 2 = 10. Since only diagonal entries exist, the trace formula works the same way it does for any square matrix, just with fewer terms to worry about.

A diagonal matrix is invertible if and only if every diagonal entry is nonzero. When it is invertible, the inverse is another diagonal matrix formed by taking the reciprocal of each entry: diag(d₁, d₂, …, dₙ)⁻¹ = diag(1/d₁, 1/d₂, …, 1/dₙ). If any single diagonal entry is zero, the matrix has no inverse.

Eigenvalues Read Directly Off the Diagonal

For most matrices, finding eigenvalues requires solving a polynomial equation. For a diagonal matrix, the eigenvalues are just the diagonal entries themselves. If D = diag(4, −1, 7), the eigenvalues are 4, −1, and 7. The corresponding eigenvectors are the standard basis vectors, meaning the vectors with a 1 in one position and 0s everywhere else.

This property is one reason diagonalization (the process of rewriting a matrix in diagonal form) is so valuable. If a matrix A can be expressed as A = CDC⁻¹ where D is diagonal, then all the hard eigenvalue work is captured in D, and the columns of C give you the eigenvectors.

Raising a Diagonal Matrix to a Power

To compute Dⁿ for a diagonal matrix, you raise each diagonal entry to the nth power individually: diag(d₁, d₂, …, dₖ)ⁿ = diag(d₁ⁿ, d₂ⁿ, …, dₖⁿ). Computing the 100th power of a diagonal matrix is no harder than computing the second.

This extends to any matrix that can be diagonalized. If A = CDC⁻¹, then Aⁿ = CDⁿC⁻¹. You only need to raise the simple diagonal entries to the nth power, then multiply by C and its inverse. This shortcut is essential for modeling systems that evolve over many time steps, such as population models, Markov chains, and difference equations in engineering.

Special Types of Diagonal Matrices

Two important matrices are special cases of diagonal matrices:

  • Scalar matrices are diagonal matrices where every diagonal entry has the same value k. Multiplying by a scalar matrix is equivalent to multiplying by the constant k, so these matrices act like a single number spread across multiple dimensions.
  • The identity matrix is a scalar matrix where every diagonal entry is 1. It’s the matrix equivalent of the number 1: multiplying any matrix by the identity matrix leaves it unchanged. Every identity matrix is a scalar matrix, and every scalar matrix is a diagonal matrix, but the reverse isn’t true.

Where Diagonal Matrices Show Up in Practice

Diagonal matrices are central to diagonalization, which is one of the most widely used techniques in applied mathematics. In data science, principal component analysis (PCA) works by decomposing a covariance matrix so that the variance along each component appears as a diagonal entry. In signal processing, many transformations become simple element-wise operations once you move into a basis where the relevant matrix is diagonal.

Even when a matrix isn’t diagonal, analysts often try to express it in diagonal form because the computational savings are enormous. Multiplying two general n × n matrices requires on the order of n³ operations. Multiplying two diagonal matrices requires only n multiplications. For large systems with thousands of dimensions, that difference determines whether a computation finishes in seconds or hours.