# Diagonal Matrix - Definition, Properties, Inverse, Examples

TL;DR

A diagonal matrix is a square matrix with zeros off the main diagonal. Learn its properties, determinant, inverse, special cases, and worked examples.

## What Is a Diagonal Matrix?

A **diagonal matrix** is a square matrix whose entries are all zero except possibly on the **main diagonal**, the line of positions running from the top-left corner to the bottom-right. In symbols, \( a_{ij} = 0 \) whenever \( i \neq j \). The diagonal entries themselves can be any value, including zero.

A 3x3 example:

\[ D = \begin{bmatrix} 4 & 0 & 0 \\\ 0 & 7 & 0 \\\ 0 & 0 & 2 \end{bmatrix} \]

Everything off the diagonal is zero; the diagonal holds 4, 7, and 2.

**Variable glossary.** \( a_{ij} \) is the entry in row \( i \), column \( j \). The _main diagonal_ is the set of entries where \( i = j \) (positions \( a_{11}, a_{22}, a_{33}, \ldots \)). "Off-diagonal" means any position where \( i \neq j \).

The matrix must be square first: the order has to be \( n \times n \) for a main diagonal to be defined at all.

## What Are the Properties of a Diagonal Matrix?

Diagonal matrices behave so cleanly because the zeros do most of the work. The properties worth memorizing:

- **A diagonal matrix is symmetric.** Reflecting across the diagonal changes nothing, since the off-diagonal entries are all zero, so \( D = D^T \).

- **It is both upper- and lower-triangular.** There are no nonzero entries above _or_ below the diagonal, which is the cleanest link to the [triangular matrix](/content/math/algebra/triangular-matrix/index.html).

- **Diagonal matrices commute.** For two diagonal matrices, \( D_1 D_2 = D_2 D_1 \), which is rare, since most matrices do not commute.

- **Products and sums stay diagonal.** Add or multiply two diagonal matrices of the same order and the result is still diagonal; you just add or multiply the diagonal entries position by position.

- **Powers are trivial.** \( D^k \) raises each diagonal entry to the power \( k \) and leaves the zeros alone.

That last property is why diagonal matrices are the goal of _diagonalization_: turning an ugly matrix into a diagonal one so its powers become easy.

## How Do You Find the Determinant and Inverse of a Diagonal Matrix?

Both reduce to one-line operations on the diagonal.

**Determinant.** The [determinant](/content/math/algebra/determinant-of-matrix/index.html) of a diagonal matrix is simply the product of its diagonal entries. For \( D \):

\[ |D| = 4 \times 7 \times 2 = 56 \]

No cofactor expansion is needed, since the zeros kill every other term.

**Inverse.** A diagonal matrix is [invertible](/content/math/algebra/invertible-matrix/index.html) exactly when no diagonal entry is zero. The inverse is found by replacing each diagonal entry with its reciprocal:

\[ D^{-1} = \begin{bmatrix} \tfrac{1}{4} & 0 & 0 \\\ 0 & \tfrac{1}{7} & 0 \\\ 0 & 0 & \tfrac{1}{2} \end{bmatrix} \]

If even one diagonal entry is zero, the determinant is zero, and no inverse exists.

## What Is Diagonalization of a Matrix?

**Diagonalization** is the process of rewriting a square matrix \( A \) as \( A = PDP^{-1} \), where \( D \) is a diagonal matrix and \( P \) is an [invertible matrix](/content/math/algebra/invertible-matrix/index.html) whose columns are the eigenvectors of \( A \). The diagonal entries of \( D \) are the eigenvalues of \( A \). Not every matrix can be diagonalized, but when one can, the payoff is large.

The reason this matters connects straight back to the properties above: powers of a diagonal matrix are trivial. Once \( A = PDP^{-1} \), raising \( A \) to a power telescopes,

\[ A^k = PD^kP^{-1} \]

The machinery rests on [eigenvalues](/content/math/algebra/eigenvalues/index.html), which decide whether a matrix is diagonalizable in the first place.

## Special Cases: Scalar, Identity, and Null Matrices

Three named matrices are all diagonal matrices wearing a more specific label.

- **Scalar matrix:** a diagonal matrix where every diagonal entry is the _same_ value \( \lambda \). It acts like multiplying by the single number \( \lambda \).

- **Identity matrix:** the special scalar matrix where that value is 1. The [identity matrix](/content/math/algebra/identity-matrix/index.html) is the diagonal matrix with 1s down the diagonal.

- **Null (zero) matrix:** a diagonal matrix where every diagonal entry happens to be zero.

The chain is one-directional: every identity is scalar, every scalar is diagonal, but a diagonal matrix is usually neither. This is exactly the relationship readers ask about most: "is an identity matrix a diagonal matrix?" Yes, and so is a scalar matrix.

## Examples of a Diagonal Matrix

### Example 1

**Is** \[ \begin{bmatrix} 5 & 0 \\\ 0 & 9 \end{bmatrix} \] **a diagonal matrix?**  
Check every off-diagonal entry. Position (1,2)=0 and position (2,1)=0.

All off-diagonal entries are zero, and the matrix is square.

**Final answer:** Yes, it is a 2×2 diagonal matrix.

### Example 2

**Find the determinant of** \[ \begin{bmatrix} 3 & 0 & 0 \\\ 0 & 6 & 0 \\\ 0 & 0 & 0 \end{bmatrix} \].

This is the wrong-path-first example.

_Wrong attempt._ A student sees a diagonal matrix and writes "diagonal matrices are always invertible, so the determinant is nonzero," then guesses a value.

_Why it is wrong._ The shortcut "diagonal means invertible" is false. Invertibility needs _every_ diagonal entry to be nonzero. Here the third entry is 0.

_Correct._ Multiply the diagonal entries:

\[ |D| = 3 \times 6 \times 0 \]

**Final answer:** \( |D| = 0 \). The matrix is singular and has no inverse, because a zero sits on the diagonal.

### Example 3

**Find the inverse of** \[ \begin{bmatrix} 2 & 0 \\\ 0 & 8 \end{bmatrix} \].

Reciprocate each diagonal entry:

\[ D^{-1} = \begin{bmatrix} \tfrac{1}{2} & 0 \\\ 0 & \tfrac{1}{8} \end{bmatrix} \]

**Final answer:** \[ D^{-1} = \begin{bmatrix} \tfrac{1}{2} & 0 \\\ 0 & \tfrac{1}{8} \end{bmatrix} \].

### Example 4

**Compute** \( D^3 \) **for** \[ D = \begin{bmatrix} 2 & 0 \\\ 0 & 3 \end{bmatrix} \].

Cube each diagonal entry, leave the zeros:

\[ D^3 = \begin{bmatrix} 8 & 0 \\\ 0 & 27 \end{bmatrix} \]

**Final answer:** \[ D^3 = \begin{bmatrix} 8 & 0 \\\ 0 & 27 \end{bmatrix} \]. Compare the effort to cubing a full matrix — this is the diagonal payoff.

### Example 5

**Multiply** \[ \begin{bmatrix} 4 & 0 \\\ 0 & 5 \end{bmatrix} \] **by** \[ \begin{bmatrix} 2 & 0 \\\ 0 & 3 \end{bmatrix} \].

Multiply the diagonal entries position by position:

\[ \begin{bmatrix} 8 & 0 \\\ 0 & 15 \end{bmatrix} \]

**Final answer:** \[ \begin{bmatrix} 8 & 0 \\\ 0 & 15 \end{bmatrix} \], still diagonal, and the order would not change if you reversed the two matrices.

### Example 6

**A diagonal matrix has order 3×3 with diagonal entries 1, 1, 1. Name it.**  
Every diagonal entry equals 1, off-diagonal entries are zero, and it is square.

**Final answer:** This is the 3×3 identity matrix, \( I_3 \), the most famous diagonal matrix of all.

## Why Diagonal Matrices Matter: "Simplicity that scales"

Diagonal matrices exist as the simplest non-trivial matrices, and the entire effort of diagonalization is aimed at turning hard problems into this easy shape. When a system decouples — when each variable evolves on its own without dragging the others along — the matrix describing it is diagonal, and the math becomes one independent equation per variable.

The destination shows up across applied fields:

- **Population and growth models.** When several groups grow at fixed rates independently, the transition matrix is diagonal, and projecting many years ahead is just raising each rate to a power.

- **Computer graphics scaling.** Stretching an object by different factors along the x, y, and z axes is a single diagonal matrix; the diagonal entries are the stretch factors.

- **Principal component analysis.** A core data-science technique works by rotating data until its covariance matrix becomes diagonal, so the dimensions stop interfering with each other. The connection runs through the covariance matrix and eigenvalues.

A diagonal matrix is what every messier matrix wishes it were. That is why "diagonalize it" is one of the most common instructions in linear algebra.

## Diagonal Matrix - Common Confusions Cleared Up

### Mistake 1: Thinking every diagonal matrix is invertible

**The correct way:** Reciprocate only when every diagonal entry is nonzero. A single zero on the diagonal makes the determinant zero and kills the inverse.

### Mistake 2: Confusing the diagonal matrix with the scalar or identity matrix

**The correct way:** Diagonal allows _different_ values on the diagonal; scalar needs them _all equal_; identity needs them all equal to _1_.

### Mistake 3: Including off-diagonal nonzeros and still calling it diagonal

**The correct way:** _Every_ off-diagonal entry must be zero. That stray nonzero entry makes the matrix upper-triangular, not diagonal.

## Diagonal Matrix - In Five Bullets

- A diagonal matrix is square with every off-diagonal entry zero; values sit only on the main diagonal.
- It is symmetric, both upper- and lower-triangular, and diagonal matrices commute with each other.
- Its determinant is the product of the diagonal entries; its inverse reciprocates them, but only when none of them is zero.
- Scalar, identity, and null matrices are all special diagonal matrices.
- Powers, products, and inverses all reduce to one-line operations, which is why diagonalization is a central goal in linear algebra.

## Practice Questions on Diagonal Matrices

Solve these, then check your work below.

1. Is \[ \begin{bmatrix} 6 & 0 & 0 \\\ 0 & 0 & 0 \\\ 0 & 0 & 4 \end{bmatrix} \] a diagonal matrix? Is it invertible?

2. Find the determinant of \[ \begin{bmatrix} 5 & 0 \\\ 0 & 9 \end{bmatrix} \].

3. Find the inverse of \[ \begin{bmatrix} 3 & 0 \\\ 0 & 6 \end{bmatrix} \].

4. Compute \( D^4 \) for \[ D = \begin{bmatrix} 2 & 0 \\\ 0 & 1 \end{bmatrix} \].

5. Name the diagonal matrix whose order is 2×2 with both diagonal entries equal to 5.

**Answer to Question 1:** Yes, it is diagonal (every off-diagonal entry is zero and it is square), but it is not invertible because a zero sits on the diagonal, so \( |D| = 0 \).

**Answer to Question 2:** \( |D| = 5 \times 9 = 45 \).

**Answer to Question 3:** \[ D^{-1} = \begin{bmatrix} \tfrac{1}{3} & 0 \\\ 0 & \tfrac{1}{6} \end{bmatrix} \].

**Answer to Question 4:** \[ D^4 = \begin{bmatrix} 16 & 0 \\\ 0 & 1 \end{bmatrix} \].

**Answer to Question 5:** A scalar matrix (a diagonal matrix with all equal diagonal entries), \( 5I_2 \).
