Tutorials › Linear Algebra › Reading Matrix Structure Before Expanding

Determinants by Cofactor Expansion · Tutorial 230 of 1000

Reading Matrix Structure Before Expanding

Use the visible structure of a matrix to select an efficient determinant method, then check the calculation with a suitable expansion.

Beginner 9 min read

What You'll Learn

  • Recognize when a diagonal product gives the determinant immediately.
  • Identify block-triangular matrices and apply the block determinant formula.
  • Use the tridiagonal determinant recurrence and understand its sign.
  • Choose a sparse row or column when structural formulas do not apply.
  • Check a determinant calculation with a second, manageable expansion.

Inspect the Matrix Before Calculating

For a determinant problem, the first decision is often not which row to expand along, but whether cofactor expansion is needed at all. A matrix with zeros in the right places may fit a direct formula or a recurrence that avoids a long expansion. The useful skill is to read the whole pattern first: check for a diagonal or triangular matrix, then for triangular blocks, then for a tridiagonal pattern. If none applies, a row or column with few nonzero entries is often the best place to expand.

All matrices in this tutorial are square matrices over \(\mathbb{R}\). A matrix is diagonal if its entries off the main diagonal are zero. It is upper triangular if all entries below the main diagonal are zero, and lower triangular if all entries above the main diagonal are zero. A matrix is tridiagonal if its only potentially nonzero entries lie on the main diagonal and the diagonals immediately above and below it.

Takeaway: Before expanding, check the matrix in this order: diagonal or triangular structure; block-triangular structure; tridiagonal structure; then the sparsest available row or column. A pattern gives a shortcut only when the matrix has exactly the required form.

Diagonal and Triangular Matrices

For a diagonal matrix, the determinant is the product of its diagonal entries. The same product formula applies to an upper- or lower-triangular matrix. These are results from the earlier material on diagonal and triangular determinants. A diagonal matrix is both upper and lower triangular, so the diagonal case is included. For instance, if a matrix is upper triangular, its entries below the diagonal are zero; expanding successively along the first column reduces the determinant to the product of the diagonal entries.

Worked Example: A Triangular Matrix and a Diagonal Matrix

Consider the upper-triangular matrix \(\mathbf{A}=\begin{bmatrix}2&1&-1\\0&3&4\\0&0&-2\end{bmatrix}\). Its determinant is the product of its diagonal entries:

$$ \det\mathbf{A}=2\cdot3\cdot(-2)=-12. $$

As a check, expand along the first column, which has only one nonzero entry. The remaining minor is \(\begin{bmatrix}3&4\\0&-2\end{bmatrix}\), with determinant \(3(-2)-4(0)=-6\). Thus \(\det\mathbf{A}=2(-6)=-12\), as before.

For the diagonal matrix \(\mathbf{D}=\begin{bmatrix}4&0&0\\0&-1&0\\0&0&5\end{bmatrix}\), the same rule gives \(\det\mathbf{D}=4(-1)5=-20\). Expanding along the first row gives \(4\det\begin{bmatrix}-1&0\\0&5\end{bmatrix}=4((-1)5-0)=-20\), confirming the product.

Look for the zero pattern, not just for a few zeros. One zero below the diagonal does not make a matrix triangular, and a matrix with most entries zero is not necessarily diagonal or triangular. If the whole matrix does not meet the form, another method may still benefit from those zeros.

Block-Triangular Structure

A matrix is block upper triangular when it can be partitioned into square diagonal blocks so that the blocks below them are zero. In the simplest two-block case, its form is \(\begin{bmatrix}\mathbf{A}&\mathbf{B}\\\mathbf{O}&\mathbf{D}\end{bmatrix}\), where \(\mathbf{A}\) and \(\mathbf{D}\) are square and \(\mathbf{O}\) is a zero block. The block \(\mathbf{B}\) can contain any entries; it need not be zero or triangular.

Block-triangular determinant formula: For square diagonal blocks \(\mathbf{A}\) and \(\mathbf{D}\), the determinant of \(\begin{bmatrix}\mathbf{A}&\mathbf{B}\\\mathbf{O}&\mathbf{D}\end{bmatrix}\) is \(\det\mathbf{A}\det\mathbf{D}\). The corresponding formula holds when the zero block is above the diagonal blocks instead. This formula was established in the earlier material on block-triangular determinants.

The important point is that the off-diagonal block does not need to be zero. Compute the determinants of the diagonal blocks, then multiply. Do not treat a block-triangular matrix as an ordinary triangular matrix unless its individual entries also satisfy the triangular pattern.

Worked Example: Two Nontriangular Diagonal Blocks

Let

$$ \mathbf{M}= \begin{bmatrix} 1&2&1&0\\ 3&5&0&2\\ 0&0&2&1\\ 0&0&1&1 \end{bmatrix}. $$

Partition after row 2 and column 2. The lower-left \(2\times2\) block is zero, so the matrix is block upper triangular. Its diagonal blocks are \(\mathbf{A}=\begin{bmatrix}1&2\\3&5\end{bmatrix}\) and \(\mathbf{D}=\begin{bmatrix}2&1\\1&1\end{bmatrix}\). Calculate each determinant:

$$ \det\mathbf{A}=1(5)-2(3)=5-6=-1,\qquad \det\mathbf{D}=2(1)-1(1)=2-1=1. $$

Therefore \(\det\mathbf{M}=(-1)(1)=-1\). The blocks \(\mathbf{A}\) and \(\mathbf{D}\) are not triangular, but the block formula still applies.

Check: Expand the full matrix down its first column. The first minor has determinant \(5(2\cdot1-1\cdot1)+2(0\cdot1-2\cdot0)=5\). The second minor has determinant \(2(2\cdot1-1\cdot1)-1(0\cdot1-1\cdot0)=2\). The signed expansion is \(1(5)-3(2)=5-6=-1\), in agreement.

Tridiagonal Matrices and Their Recurrence

A tridiagonal matrix may have many nonzero entries, so a single cofactor expansion can produce a larger minor. Instead, use the recurrence established in the earlier material on tridiagonal determinants. For clarity, write the leading \(k\times k\) part of a tridiagonal matrix with diagonal entries \(a_1,\ldots,a_k\), superdiagonal entries \(b_1,\ldots,b_{k-1}\), and subdiagonal entries \(c_1,\ldots,c_{k-1}\). Let \(D_k\) be the determinant of that leading \(k\times k\) part, and set \(D_0=1\), the determinant of the empty \(0\times0\) matrix. Then \(D_1=a_1\), and for \(k\ge2\),

$$ D_k=a_kD_{k-1}-b_{k-1}c_{k-1}D_{k-2}. $$

The minus sign is essential. Here is the cofactor argument for the recurrence. Expand the \(k\times k\) determinant along its last row. Only the entries \(c_{k-1}\) in column \(k-1\) and \(a_k\) in column \(k\) can contribute. The \(a_k\) term is \(a_kD_{k-1}\). The \(c_{k-1}\) term has cofactor sign \((-1)^{k+(k-1)}=-1\). In its minor, the final column has just one nonzero entry, \(b_{k-1}\); expanding that column leaves the leading \((k-2)\times(k-2)\) determinant \(D_{k-2}\), with positive sign because the entry is in the last row and column of that minor. Thus the second contribution is \(-c_{k-1}b_{k-1}D_{k-2}\), proving the recurrence. This reasoning also applies at \(k=2\), with \(D_0=1\). \(\square\)

Worked Example: A Four-by-Four Tridiagonal Determinant

Find the determinant of

$$ \mathbf{T}= \begin{bmatrix} 2&1&0&0\\ 1&3&2&0\\ 0&1&2&1\\ 0&0&2&1 \end{bmatrix}. $$

Here the diagonal entries are \(2,3,2,1\). The superdiagonal entries are \(1,2,1\), and the subdiagonal entries are \(1,1,2\). Apply the recurrence in order:

$$ D_0=1,\qquad D_1=2, $$
$$ D_2=3D_1-(1)(1)D_0=3(2)-1=5, $$
$$ D_3=2D_2-(2)(1)D_1=2(5)-2(2)=6, $$
$$ D_4=1D_3-(1)(2)D_2=6-2(5)=-4. $$

Thus \(\det\mathbf{T}=-4\).

Check: Expand along the first row. The first \(3\times3\) minor has determinant \(3(2\cdot1-1\cdot2)-2(1\cdot1-1\cdot0)=0-2=-2\). The second minor has determinant \(1(2\cdot1-1\cdot2)-2(0\cdot1-1\cdot0)=0-0=0\). The first-row expansion is \(2(-2)-1(0)=-4\), confirming the recurrence calculation.

When Cofactor Expansion Is the Better Choice

If the matrix is not diagonal, triangular, block triangular, or tridiagonal, inspect its rows and columns for zeros. Cofactor expansion along a row or column uses one term for each nonzero entry there. A row or column with just one nonzero entry can reduce the calculation particularly quickly; a row or column with several nonzero entries may still be the best option if its minors are simple.

Worked Example: Expand Along a Sparse Row

Consider

$$ \mathbf{C}= \begin{bmatrix} 1&2&0&1\\ 0&0&0&3\\ 2&1&1&0\\ 1&0&2&1 \end{bmatrix}. $$

This matrix is not triangular, block triangular in an evident partition, or tridiagonal. Row 2 has only one nonzero entry, in column 4. Its cofactor sign is \((-1)^{2+4}=1\), so expansion along row 2 gives

$$ \det\mathbf{C} =3\det\begin{bmatrix} 1&2&0\\ 2&1&1\\ 1&0&2 \end{bmatrix}. $$

Expand this \(3\times3\) determinant along its first row:

$$ \begin{aligned} \det\begin{bmatrix}1&2&0\\2&1&1\\1&0&2\end{bmatrix} &=1(1\cdot2-1\cdot0)-2(2\cdot2-1\cdot1)+0\\ &=2-2(3)=-4. \end{aligned} $$

Therefore \(\det\mathbf{C}=3(-4)=-12\). The zero entries in row 2 make the first expansion short, and the resulting minor also has a convenient row.

A Reliable Structure-First Routine

The choice of method is a sequence of checks, not a new determinant formula. Use the first applicable shortcut, but make sure its hypotheses really hold.

1
Check the entire diagonal pattern.
If the matrix is diagonal or triangular, multiply the diagonal entries. Do not infer triangular form from a few isolated zeros.
2
Look for a block partition.
If the matrix has square diagonal blocks and a zero block on one side of the block diagonal, multiply the determinants of its diagonal blocks. The other off-diagonal block may be nonzero.
3
Check for a tridiagonal pattern.
If every entry outside the main and adjacent diagonals is zero, use the recurrence, keeping the adjacent-diagonal product and its minus sign.
4
Choose a sparse row or column.
When the structural formulas do not apply, compare the number and complexity of the nonzero entries in candidate rows and columns, then expand where the resulting minors are most manageable.

Each method has a distinct condition. A block formula applies to the stated zero-block arrangement, not to any matrix that merely looks as if it has clusters of entries. The tridiagonal recurrence requires the entries outside the three central diagonals to be zero. Cofactor expansion, by contrast, applies to any square matrix, but its efficiency depends on the row or column chosen.

Common Sign Pitfall

A frequent error in the tridiagonal recurrence is to replace the minus sign with a plus sign. For the leading \(2\times2\) part of \(\mathbf{T}\), that incorrect rule would give \(D_2=3(2)+(1)(1)(1)=7\). Directly calculating the determinant gives

$$ \det\begin{bmatrix}2&1\\1&3\end{bmatrix} =2(3)-1(1)=6-1=5. $$

The discrepancy comes from the cofactor sign on the entry in row 2, column 1: it is \((-1)^{2+1}=-1\), not \(+1\). The correct recurrence is \(D_2=3(2)-1=5\). When using a recurrence or expansion, keep the cofactor signs attached to the positions of the entries; a zero pattern shortens the arithmetic but does not remove sign rules.

Once a method has produced a value, check it in a way that suits the matrix. A short cofactor expansion is a useful check for a diagonal or triangular product, and a manageable row or column expansion can check a recurrence or block calculation. The check should use the actual entries and signs, rather than simply repeating the same shortcut.

Check Your Understanding

For each question, identify the relevant structure before calculating or explaining your choice.

  1. What is the determinant of \(\begin{bmatrix}3&0&0\\2&-1&0\\4&5&2\end{bmatrix}\), and which pattern allows a direct calculation?
  2. For a block upper-triangular matrix \(\begin{bmatrix}\mathbf{A}&\mathbf{B}\\\mathbf{O}&\mathbf{D}\end{bmatrix}\), which blocks must be square, and must \(\mathbf{B}\) be zero?
  3. For a tridiagonal matrix with \(a_1=4\), \(a_2=2\), \(b_1=3\), and \(c_1=1\), calculate \(D_2\) using \(D_0=1\) and \(D_1=a_1\).
  4. In \(\begin{bmatrix}1&0&2\\0&0&5\\3&1&0\end{bmatrix}\), which row or column gives a one-term cofactor expansion, and what is the cofactor sign of its nonzero entry?
  5. Explain why a matrix with zeros everywhere except on the main diagonal and the two adjacent diagonals can use a recurrence, but a matrix with an additional nonzero entry two columns above the diagonal cannot use that same tridiagonal recurrence.

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