Tutorials › Linear Algebra › Determinants of Diagonal Matrices

Determinants by Cofactor Expansion · Tutorial 224 of 1000

Determinants of Diagonal Matrices

Learn why a diagonal matrix’s determinant is the product of its diagonal entries and how to handle zero and negative entries correctly.

Beginner 8 min read

What You'll Learn

  • Identify a diagonal matrix and write its diagonal-product formula.
  • Derive the formula using cofactor expansion and induction.
  • Evaluate diagonal determinants with zero or negative entries.
  • Determine exactly when a diagonal matrix has determinant zero.
  • Check determinant calculations by following the cofactor expansion.

Reading the Determinant from the Diagonal

A diagonal matrix has a simple structure: every entry away from the main diagonal is zero. That structure makes its determinant much easier to compute than a general determinant. Rather than expanding into many terms, we can read the answer directly from the diagonal entries. The formula also makes the effects of zero and negative entries explicit.

For an \(n\times n\) matrix, the main diagonal consists of the entries in positions \((1,1),(2,2),\dots,(n,n)\). A diagonal matrix has zero in every other position. We consider \(n\ge 1\) and real diagonal entries \(d_1,\dots,d_n\).

Definition: A matrix \(\mathbf{D}\in\mathbb{R}^{n\times n}\) is diagonal if \(d_{ij}=0\) whenever \(i\ne j\). We write it as \(\operatorname{diag}(d_1,\dots,d_n)\), meaning $$ \mathbf{D}= \begin{bmatrix} d_1&0&\cdots&0\\ 0&d_2&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ 0&0&\cdots&d_n \end{bmatrix}. $$

The determinant of a \(1\times1\) matrix \([d_1]\) is \(d_1\). For a larger matrix, cofactor expansion along the first row says to multiply each entry in that row by its cofactor and add the results. In a diagonal matrix, only the first entry in that row can be nonzero. After deleting its row and column, the remaining matrix is again diagonal. This observation leads to the diagonal-product formula.

Theorem (Diagonal-product formula): If \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\in\mathbb{R}^{n\times n}\), then $$ \det\mathbf{D}=d_1d_2\cdots d_n=\prod_{i=1}^{n}d_i. $$

Proof. We use induction on the positive integer \(n\). When \(n=1\), the determinant of \([d_1]\) is \(d_1\), which is the stated product. Now suppose \(n\ge2\) and that the formula holds for diagonal matrices of size \(n-1\). Expanding \(\det\mathbf{D}\) along the first row, every term except the first is zero because \(d_{1j}=0\) for \(j\ne1\). The first cofactor has sign \((-1)^{1+1}=1\), and its minor is the diagonal matrix \(\operatorname{diag}(d_2,\dots,d_n)\). Therefore $$ \det\mathbf{D} =d_1\det\bigl(\operatorname{diag}(d_2,\dots,d_n)\bigr) =d_1(d_2\cdots d_n) =d_1d_2\cdots d_n, $$ where the second equality follows from the induction hypothesis. This proves the formula for every \(n\ge1\). \(\square\)

Using the Formula with Zero and Negative Entries

The formula is an ordinary product of real numbers. A zero diagonal entry makes the whole product zero, regardless of the other entries. Negative entries contribute their signs just as they do in any multiplication: an even number of negative factors gives a positive product when none of the factors is zero, while an odd number gives a negative product.

Worked Example: A Four-by-Four Matrix with Negative Entries

Find the determinant of $$ \mathbf{D}= \begin{bmatrix} -2&0&0&0\\ 0&3&0&0\\ 0&0&-1&0\\ 0&0&0&4 \end{bmatrix}. $$

The diagonal entries, in order, are \(-2,3,-1,4\). Applying the formula gives $$ \det\mathbf{D}=(-2)(3)(-1)(4). $$

Multiplying from left to right, \((-2)(3)=-6\), \((-6)(-1)=6\), and \(6(4)=24\). Thus \(\det\mathbf{D}=24\).

Check by cofactor expansion: Expanding first along the first row leaves \((-2)\) times the determinant of the \(3\times3\) diagonal matrix with entries \(3,-1,4\). Expanding that matrix along its first row gives \(3\) times the determinant of the \(2\times2\) diagonal matrix with entries \(-1,4\). The \(2\times2\) determinant is \((-1)(4)-0\cdot0=-4\). Hence the expansions give \((-2)\bigl(3(-4)\bigr)=(-2)(-12)=24\), agreeing with the product.

Worked Example: A Symbolic Diagonal Entry Is Zero

Let \(x,z\in\mathbb{R}\) and consider $$ \mathbf{D}= \begin{bmatrix} -x&0&0\\ 0&0&0\\ 0&0&z \end{bmatrix}. $$ Find its determinant for all real \(x\) and \(z\).

The diagonal-product formula gives $$ \det\mathbf{D}=(-x)(0)(z)=0. $$ This remains true for every choice of \(x\) and \(z\), including choices where one or both of them are zero.

Check by cofactor expansion: Expanding along the first row leaves \((-x)\) times the determinant of \(\begin{bmatrix}0&0\\0&z\end{bmatrix}\). Using the \(2\times2\) formula, that minor has determinant \((0)(z)-(0)(0)=0\). Therefore \(\det\mathbf{D}=(-x)(0)=0\), as the product formula predicts.

Worked Example: Two Negative Symbolic Entries

For real \(a,b,c\), evaluate $$ \det \begin{bmatrix} -a&0&0\\ 0&b&0\\ 0&0&-c \end{bmatrix}. $$

The diagonal entries are \(-a,b,-c\), so their product is $$ (-a)b(-c)=abc. $$ The two negative signs cancel, so the determinant is \(abc\), not \(-abc\). The value may be positive, negative, or zero depending on \(a,b,c\); the expression \(abc\) gives the value in all cases.

Check by cofactor expansion: Expanding along the first row gives \((-a)\) times the determinant of \(\begin{bmatrix}b&0\\0&-c\end{bmatrix}\). The \(2\times2\) determinant is \(b(-c)-0\cdot0=-bc\). Thus the full determinant is \((-a)(-bc)=abc\), agreeing with the diagonal product.

Exactly When Is the Determinant Zero?

The product formula gives a precise test for a zero determinant. Over \(\mathbb{R}\), a product is zero exactly when at least one of its factors is zero. This fact applies no matter how many diagonal entries there are.

Corollary: For \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\in\mathbb{R}^{n\times n}\), \(\det\mathbf{D}=0\) if and only if \(d_i=0\) for at least one index \(i\in\{1,\dots,n\}\).

Proof. By the diagonal-product formula, \(\det\mathbf{D}=d_1\cdots d_n\). If \(d_i=0\) for some \(i\), this product contains a zero factor, so \(\det\mathbf{D}=0\). Conversely, suppose \(\det\mathbf{D}=0\). If every \(d_i\) were nonzero, then each \(d_i\) would have a real multiplicative inverse. Their product would also have an inverse, namely \(1/(d_1\cdots d_n)\), so \(d_1\cdots d_n\) could not equal zero. This contradicts \(\det\mathbf{D}=0\). Therefore at least one diagonal entry must be zero. \(\square\)

When every diagonal entry is nonzero, the determinant is nonzero. For diagonal matrices, this conclusion requires no further determinant calculation: inspect the diagonal and multiply. The corollary concerns the determinant specifically; it does not require a general criterion for when an arbitrary matrix is invertible.

Common Pitfall: Losing a Negative Sign

A common error is to treat negative diagonal entries as if the determinant were the absolute value of their product. For example, for \(\operatorname{diag}(-2,3,-4)\), one might incorrectly write \(\det\mathbf{D}=-|(-2)(3)(-4)|=-24\). The correction is to multiply the entries with their signs intact: $$ (-2)(3)(-4)=(-6)(-4)=24. $$ There are two negative factors, so their signs cancel. Cofactor checkerboard signs do not add an extra minus sign here: the only nonzero entry in the first row is in position \((1,1)\), whose cofactor sign is \((-1)^{1+1}=1\). Further expansions of the remaining diagonal minors follow the same pattern.

Another useful check is to separate the zero case from the sign case. If any diagonal entry is zero, the determinant is zero, even if other entries are negative. Only when all entries are nonzero does counting the negative factors determine whether the product is positive or negative.

Applying the Formula Reliably

For a matrix to use this formula, it must be square and diagonal. A matrix with nonzero entries away from the diagonal is not diagonal, even if most of its entries are zero. For a diagonal matrix, keep the order of the diagonal entries when writing the product, preserve every negative sign, and check whether any factor is zero before deciding the sign.

1
Confirm the structure.
Check that the matrix is square and every off-diagonal entry is zero.
2
Read the diagonal.
List the entries \(d_1,\dots,d_n\) from top left to bottom right.
3
Multiply with signs.
Compute \(d_1\cdots d_n\); any zero factor makes the result zero.
4
Check the result.
For a small matrix, a cofactor expansion along the first row reduces to the same product calculation.

The key point is that the determinant of a diagonal matrix is the product of its diagonal entries, not the product of their absolute values. The formula follows directly from cofactor expansion because each first row has only one potentially nonzero term, and the minor left behind has the same diagonal structure.

Check Your Understanding

Use the diagonal-product formula, and show enough arithmetic to make the sign and zero cases clear.

  1. Find the determinant of \(\operatorname{diag}(2,-5,3)\).
  2. For real \(r,s\), evaluate the determinant of \(\operatorname{diag}(r,0,-s,2)\).
  3. Evaluate the determinant of \(\operatorname{diag}(-a,-b,-c)\) in terms of \(a,b,c\).
  4. State and justify when \(\operatorname{diag}(d_1,\dots,d_n)\) has determinant zero.
  5. Explain why the determinant of \(\operatorname{diag}(-2,3,-4)\) is not \(-24\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon