Mathwords logoMathwords

Diagonal Matrix

Diagonal Matrix

A square matrix which has zeros everywhere other than the main diagonal. Entries on the main diagonal may be any number, including 0.

 

3x3 diagonal matrix with values 5, -2, √3 on the main diagonal and zeros in all off-diagonal positions.

 

 

See also

Matrix

Key Formula

D=(d1000d2000dn)D = \begin{pmatrix} d_1 & 0 & \cdots & 0 \\ 0 & d_2 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & d_n \end{pmatrix}
Where:
  • DD = The diagonal matrix of size n × n
  • d1,d2,,dnd_1, d_2, \ldots, d_n = The entries on the main diagonal; each may be any real (or complex) number, including 0
  • nn = The number of rows and columns (the matrix must be square)

Worked Example

Problem: Let D = diag(3, −1, 5). Compute D² (the matrix multiplied by itself).
Step 1: Write out the diagonal matrix D explicitly.
D=(300010005)D = \begin{pmatrix} 3 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & 5 \end{pmatrix}
Step 2: Use the key property of diagonal matrices: when you multiply two diagonal matrices, you simply multiply corresponding diagonal entries.
D2=(33000(1)(1)00055)D^2 = \begin{pmatrix} 3 \cdot 3 & 0 & 0 \\ 0 & (-1)\cdot(-1) & 0 \\ 0 & 0 & 5 \cdot 5 \end{pmatrix}
Step 3: Evaluate each diagonal entry.
D2=(9000100025)D^2 = \begin{pmatrix} 9 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 25 \end{pmatrix}
Answer: D² = diag(9, 1, 25). Each diagonal entry is simply squared.

Another Example

This example shows how to find the determinant and inverse of a diagonal matrix, illustrating that both operations reduce to simple arithmetic on the diagonal entries—unlike the general case, which requires cofactor expansion or row reduction.

Problem: Find the determinant and inverse of the diagonal matrix A = diag(2, 4, −3).
Step 1: Write the matrix A.
A=(200040003)A = \begin{pmatrix} 2 & 0 & 0 \\ 0 & 4 & 0 \\ 0 & 0 & -3 \end{pmatrix}
Step 2: The determinant of a diagonal matrix is the product of its diagonal entries.
det(A)=24(3)=24\det(A) = 2 \cdot 4 \cdot (-3) = -24
Step 3: Since the determinant is nonzero, A is invertible. The inverse of a diagonal matrix is formed by taking the reciprocal of each diagonal entry.
A1=(120001400013)A^{-1} = \begin{pmatrix} \frac{1}{2} & 0 & 0 \\ 0 & \frac{1}{4} & 0 \\ 0 & 0 & -\frac{1}{3} \end{pmatrix}
Step 4: Verify: multiply A by A⁻¹ to confirm the result is the identity matrix.
AA1=(100010001)=I3A \cdot A^{-1} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} = I_3
Answer: det(A) = −24 and A⁻¹ = diag(1/2, 1/4, −1/3).

Frequently Asked Questions

Is the identity matrix a diagonal matrix?
Yes. The identity matrix has 1s on the main diagonal and 0s everywhere else, which satisfies the definition of a diagonal matrix exactly. It is a special case where every diagonal entry equals 1.
Can a diagonal matrix have zeros on the diagonal?
Yes. The definition only requires that all off-diagonal entries are zero. Diagonal entries can be any number, including zero. For example, diag(5, 0, 2) is a valid diagonal matrix. However, if any diagonal entry is zero, the matrix is not invertible.
What is the difference between a diagonal matrix and a symmetric matrix?
Every diagonal matrix is symmetric (it equals its own transpose), but the reverse is not true. A symmetric matrix can have nonzero entries off the main diagonal, as long as the matrix equals its transpose. For example, the matrix [[1, 3], [3, 2]] is symmetric but not diagonal.

Diagonal Matrix vs. Identity Matrix

Diagonal MatrixIdentity Matrix
DefinitionSquare matrix with zeros everywhere except the main diagonalSquare matrix with 1s on the main diagonal and zeros elsewhere
Diagonal entriesAny numbers (including 0)All equal to 1
DeterminantProduct of diagonal entries (can be any value)Always 1
InverseExists only if no diagonal entry is 0; inverse is diag(1/d₁, …, 1/dₙ)Always exists; the identity is its own inverse
RoleGeneral class of easily computable matricesMultiplicative identity for matrix multiplication (AI = IA = A)

Why It Matters

Diagonal matrices appear constantly in linear algebra because they make matrix operations trivial: multiplication, exponentiation, finding determinants, and computing inverses all reduce to simple arithmetic on individual entries. In applications such as principal component analysis and solving systems of differential equations, diagonalizing a matrix (rewriting it as a product involving a diagonal matrix) is a core technique. If you continue to eigenvalues and eigenvectors, you will find that the eigenvalues of a diagonal matrix are exactly its diagonal entries.

Common Mistakes

Mistake: Confusing a diagonal matrix with an upper or lower triangular matrix.
Correction: A triangular matrix can have nonzero entries above (or below) the main diagonal. A diagonal matrix is both upper and lower triangular simultaneously—it has zeros in every off-diagonal position.
Mistake: Assuming a diagonal matrix must have all nonzero diagonal entries.
Correction: Zeros are allowed on the diagonal. The matrix diag(4, 0, 7) is still diagonal. The only requirement is that all off-diagonal entries are zero. A zero on the diagonal simply means the matrix is singular (not invertible).

Related Terms