Engineering/Mathematics/Determinants
Computing Determinants
A determinant may be expanded about any row or any column, and all expansions give the same value. Choosing the line with the most zeros turns an intractable recursion into a short calculation.
- Core level
- Stream: computation
- Reading time 13 min
- Ref KVS-ENG-MATH-0076
- Taxonomy
- Engineering / Mathematics
- Prerequisite
- Definition of the determinant; submatrices
- Key result
- Expansion about any row or column (DERC)
- Minor
- Cofactor
- Triangular case
- Determinant is the product of the diagonal entries
Overview
The recursive definition of the determinant fixes attention on the first row, which is a convenient way to make the definition unambiguous but a poor way to organise a calculation. The central computational theorem of the subject removes that restriction: a determinant may be evaluated by expanding about any single row or any single column, and every one of the available expansions returns the same scalar. That freedom is the difference between an exercise and a technique.
Two named quantities make the statement compact. The minor at position is the determinant of the submatrix left after deleting row and column . The cofactor is the same number multiplied by , the chequerboard sign attached to that position. With cofactors in hand, an expansion is simply the sum of the entries of a chosen line, each multiplied by its own cofactor.
The practical payoff is entirely about zeros. A zero entry contributes nothing to the sum, so its cofactor — a determinant one size smaller — never has to be computed. A matrix with two zeros in some column costs two subdeterminants instead of four, halving the work. A triangular matrix, in which everything below the diagonal vanishes, collapses so far that its determinant is just the product of its diagonal entries. That single observation is what connects the determinant to LU factorisation and turns it into a cubic-cost quantity.
None of this rescues cofactor expansion as a general-purpose numerical algorithm; the growth is still factorial for a dense matrix, and expansion is not numerically stable. What it does provide is a rigorous, division-free hand method for small and structured matrices, a symbolic tool for parametric problems, and the theoretical link — through triangular matrices — to the factorisation methods that software actually uses.
Definition
Minor In a Matrix
MIMFor an matrix , the minor of at location is the determinant of the submatrix formed by deleting row and column : .
A minor carries no sign adjustment. It is an unsigned determinant of a smaller matrix, and its value may of course still be negative.
Cofactor In a Matrix
CIMFor an matrix , the cofactor of at location is the signed minor . The factor equals when is even and when it is odd, giving a chequerboard pattern with in the top-left corner.
Determinant Expansion about Rows and Columns
DERCFor a square matrix of size and any fixed index with and , both of the following hold.
- Expansion about row : .
- Expansion about column : .
The recursive definition of the determinant is the special case of expansion about row . The theorem asserts that the definition's arbitrary choice of the first row was harmless.
Concepts
The chequerboard sign and how to read it off
The factor is best held visually rather than arithmetically. Lay a chequerboard over the matrix with in the position; the sign alternates along every row and down every column. Position carries ; position carries . When expanding about a row or column other than the first, the leading sign is not necessarily , and forgetting this is the most frequent source of an answer that is correct in magnitude and wrong in sign.
Why all expansions agree
Expanded fully, every one of the expressions unwinds to the same sum of signed products, each product taking exactly one entry from every row and every column. The row or column chosen for the expansion only determines the order in which that sum is assembled. This is why the choice is free and why the theorem, although it looks like a strong claim, is essentially a bookkeeping identity about the same underlying set of terms.
Zeros are the whole point
If then the term vanishes and the cofactor need never be evaluated. Since each avoided cofactor is a determinant one size smaller, each zero in the chosen line removes an entire branch of the recursion. Expanding a matrix about a column containing three zeros costs one determinant instead of four — a factor of four saving at that level and a compounding saving below it. The rule for hand computation is therefore blunt: count the zeros in every row and column first, and expand about the winner.
Manufacturing zeros with row operations
When no line is sparse, one can be created. Adding a multiple of one row to another leaves the determinant unchanged, so a single such operation can introduce a zero into a chosen column without altering the answer. Applied systematically this is exactly Gaussian elimination, and it converts the factorial cofactor recursion into a cubic-cost procedure. Two related operations behave differently and must be tracked: interchanging two rows negates the determinant, and scaling a row by multiplies the determinant by .
Triangular matrices and the diagonal product
Suppose is upper triangular, so every entry below the main diagonal is zero. Expanding about the first column leaves a single term, times the determinant of the submatrix obtained by deleting row and column — which is itself upper triangular. Repeating the argument gives , the product of the diagonal entries. The same holds for lower triangular matrices by expanding about the first row instead, and hence for diagonal matrices as a special case. This result is the bridge to practical computation: reduce to triangular form, then multiply the diagonal.
Cofactors beyond determinants
The matrix of cofactors has an independent use. Assemble with and form : the result is times the identity matrix. Every off-diagonal entry vanishes because it amounts to expanding a determinant with two equal rows. Rearranged, this gives the adjugate formula , valid whenever . It is a closed-form inverse of great theoretical value and almost no computational value, since it requires subdeterminants.
Choosing and executing an expansion
Equations
Minor at location (i, j)
EQ-CD-01The unsigned determinant of the submatrix obtained by deleting row and column from .
Cofactor at location (i, j)
EQ-CD-02The minor carrying the chequerboard sign of its position. Cofactors, not minors, are what enter an expansion.
Expansion about row i
EQ-CD-03Valid for every choice of row index . The recursive definition is the case .
Expansion about column j
EQ-CD-04The column form. Together with the row form this gives distinct routes to the same value.
Determinant of a triangular matrix
EQ-CD-05Obtained by repeatedly expanding about the first column (upper triangular) or the first row (lower triangular). Diagonal matrices are the special case in which both apply.
Effect of the elementary row operations
EQ-CD-06The rules that permit zeros to be manufactured before expanding. Only the first operation is free; the other two must be recorded and undone at the end.
Cofactor matrix identity and the adjugate inverse
EQ-CD-07With the matrix of cofactors. The inverse formula requires and costs subdeterminants, so it is a theoretical instrument rather than an algorithm.
Variable Definitions
| Symbol | Name | Meaning | Domain / type |
|---|---|---|---|
| Matrix | The square matrix whose determinant is being evaluated | n x n matrix over C | |
| Size | Common row and column count | positive integer | |
| Submatrix | Result of deleting row and column from | (n-1) x (n-1) matrix | |
| Minor | Determinant of the submatrix , without sign adjustment | complex scalar | |
| Cofactor | The minor multiplied by | complex scalar | |
| Entry | The scalar in row , column | complex scalar | |
| Cofactor matrix | The matrix whose entry is ; its transpose is the adjugate | n x n matrix | |
| Triangular matrix | A matrix with all entries on one side of the main diagonal equal to zero | n x n matrix |
Worked Numerical Example
Problem statement
A four-node network model produces a coefficient matrix in which one column is almost entirely zero, because three of the four nodes have no direct coupling to the second state variable. Evaluate the determinant by exploiting that sparsity, then verify the answer by an independent expansion.
State the matrix and survey it
Column contains three zeros — more than any other row or column. Expanding about column will therefore require a single determinant rather than four.
Write the column expansion
Expansion about column has four terms, but three of the entries , and are zero. Only the term at position survives, and its entry is .
Form the surviving submatrix
Delete row and column . The rows , and survive, each keeping columns , and in their original order.
Evaluate the minor
Expand this determinant about its own first row using on each block. The three subdeterminants are , and .
Attach the chequerboard sign
Position has , which is odd, so the sign is . The cofactor is therefore the negative of the minor. Omitting this step is what produces an answer with the correct magnitude and the wrong sign.
Complete the expansion
One entry, one cofactor, one multiplication.
Verify by expanding about row 1
An independent route. Row has entries with signs . The three required minors evaluate to , and ; the second term is skipped because .
Compare the cost of the two routes
The column expansion required one determinant. The row expansion required three. Both give , confirming that the choice of line affects only the labour, never the answer — and confirming the arithmetic of each route against the other.
The determinant is . Being non-zero, the coefficient matrix is non-singular, so the four-node model has a unique solution for every excitation vector. The calculation also illustrates the governing economy of cofactor expansion: identifying the sparsest line before starting cut the work by two-thirds, and the saving compounds at every level of a deeper recursion.
Applications & Industry Use
Banded stiffness matrices
Stiffness matrices from beam and frame models are banded: each degree of freedom couples only to its immediate neighbours. Rows near the boundary contain many zeros, so a cofactor expansion about those rows is tractable by hand for small models and is used to derive closed-form determinant expressions for repetitive structures such as continuous beams and periodic trusses.
Symbolic characteristic polynomials
For a state-space model in companion or block-triangular form, expanding about a sparse row yields the characteristic polynomial in a few lines instead of by full recursion. Block-triangular structure — common in cascaded or weakly coupled subsystems — lets the overall determinant be written as the product of the diagonal blocks' determinants.
Sparse stoichiometric and recycle models
Material balance matrices for process flowsheets are sparse, since each unit operation touches only a few streams. Expanding about a row corresponding to a single-inlet, single-outlet unit reduces the determinant of the whole flowsheet to that of a smaller subnetwork, which is how solvability of a recycle loop can be argued without a full numerical solve.
Predicate evaluation with exact arithmetic
Orientation and in-circle predicates are small determinants that must be evaluated exactly, because a sign error causes mesh generation and hull algorithms to fail catastrophically rather than gracefully. Cofactor expansion is used because it is division-free and therefore exact over the integers, and the expansions are unrolled at compile time for fixed small sizes.
Network admittance and islanding checks
The bus admittance matrix of a power network is highly sparse. Expanding about the row of a radially connected bus repeatedly peels the network back towards its meshed core, and a zero determinant along the way identifies an electrically islanded section with no reference to ground — a condition that must be caught before a load-flow solver is invoked.
Determinants from LU factorisation
Every serious library computes a determinant by reducing to triangular form and multiplying the diagonal, which is the triangular-matrix result applied to the factor. The row-interchange count from partial pivoting supplies the sign. The theorem that permits arbitrary expansion is what makes this reduction legitimate rather than a separate definition.
Design Considerations
Choose the expansion line before computing anything
The cost of an expansion is set entirely by the number of non-zero entries in the chosen line. Spending thirty seconds counting zeros in all candidate lines routinely saves the majority of the arithmetic. This is the single highest-leverage decision in a hand determinant.
Use row operations, but only the free one, without bookkeeping
Adding a multiple of one row to another leaves the determinant untouched and is the safe way to manufacture zeros. Row interchanges and row scalings also help but change the answer, by a sign and by a factor respectively. If you use them, record each one immediately; reconstructing the corrections at the end from memory is unreliable.
Recognise structure before reaching for the general method
Triangular, diagonal and block-triangular matrices have determinants available by inspection. So does any matrix with a zero row or a zero column, whose determinant is zero. Checking for these forms first avoids a great deal of unnecessary expansion, and in symbolic work it avoids expression swell that can be very hard to simplify afterwards.
Do not use cofactor expansion in floating point
Beyond its factorial cost, expansion is numerically unstable: it forms many products of comparable magnitude and adds them with cancellation, so relative error can be large even when the determinant is not small. Restrict cofactor expansion to exact arithmetic and small or structured sizes; use an LU-based routine for everything else.
Treat the adjugate inverse as theory, not method
The identity is exact and elegant, and it is genuinely useful for matrices and for symbolic derivations where the entries are parameters. As an algorithm it requires cofactors, each a determinant of size , and is worse than useless above about .
Keep the minor and the cofactor distinct in notation
The only difference between them is the sign factor, which makes them easy to conflate and hard to debug when conflated. Adopt distinct symbols — and — and never let a bare minor enter an expansion sum.
Standards & Codes
Notation, interchange and numerical standards that govern how this material is written down, stored and computed in production systems.
| Reference | Title | Relevance to this topic |
|---|---|---|
ISO 80000-2 | Quantities and units — Part 2: Mathematics | Fixes the upright operator and the vertical-bar determinant notation, and the italic convention for the index variables and used throughout the cofactor formulae. |
LAPACK xGETRF / xGETRI | LU factorisation and inversion routines | Demonstrates the industrial position of this material: the determinant is obtained from the triangular factor's diagonal, and matrix inversion is done by triangular solves, never by an adjugate of cofactors. |
IEEE 754-2019 | IEEE Standard for Floating-Point Arithmetic | The rounding model that makes cofactor expansion numerically unattractive, and the source of the exceptional cases that motivate exact predicate arithmetic in computational geometry. |
ISO 10303 (STEP) | Industrial automation systems and integration — Product data representation | Geometric tolerance and orientation decisions in exchanged CAD models rest on small determinant predicates; robust evaluation of those predicates is what keeps a solid model topologically valid after translation. |
W3C WCAG 2.1 AA | Web Content Accessibility Guidelines | Matrices and determinants on this page are encoded as semantic MathML rather than images, so the index structure of a cofactor expansion is exposed to assistive technology and remains legible under magnification. |
Material Selection
For a mathematical topic, "material" is the numeric representation: the scalar field, storage format and precision the computation is built from.
| Representation | Select when | Trade-off |
|---|---|---|
| Exact machine integers with unrolled expansion | Fixed small sizes, especially and geometric predicates evaluated millions of times. | Branch-free, division-free and exactly correct, but the expansion must be unrolled per size and the intermediate products can overflow if entry magnitudes are not bounded in advance. |
| Arbitrary-precision integers | Exact determinants of integer matrices where entry magnitude or size defeats a fixed-width type. | No overflow and an unambiguous zero test, at the cost of arithmetic that slows as intermediate operands grow. |
| Symbolic rational or polynomial entries | Parametric matrices where the determinant is wanted as an expression in design variables, as in a characteristic polynomial. | Delivers a factorable result whose roots are the critical parameter values, but expression swell during expansion can dominate the computation unless the sparsest line is chosen deliberately. |
| IEEE 754 binary64 with LU factorisation | Numerical determinants of dense matrices above about size four. | Cubic cost and backward stability, but no exact zero test and a result that may overflow or underflow for large sizes. |
| Sparse storage with a fill-reducing ordering | Large structured matrices from networks, finite element meshes and flowsheets. | Sparse LU preserves much of the zero structure and gives the determinant from the factor's diagonal, but fill-in during factorisation can still be severe without a good ordering. |
| Interval or filtered arithmetic | Geometric predicates where a certified sign is required but exact arithmetic is too slow for the common case. | A floating-point filter answers most queries immediately and falls back to exact evaluation only when the interval straddles zero, but the implementation must be carefully validated. |
Manufacturing Notes
Implementation notes — how the result is actually produced by hand, by algorithm and by library, including cost and numerical behaviour.
Operation counts
A dense cofactor expansion performs more than multiplications regardless of which line is chosen. Each zero in the chosen line removes one subdeterminant of size , so a line with zeros reduces the immediate work by the fraction . Reduction to triangular form followed by a diagonal product costs about operations and is the only route that scales.
Hand procedure
Write the chequerboard of signs alongside the matrix before starting. Choose the sparsest line, list only the non-zero entries with their signs, and evaluate one minor at a time, completing each fully before moving to the next. Where the matrix has no sparse line, spend one or two row-addition operations creating zeros in a column before expanding — the determinant is unchanged and the saving is usually decisive.
Library behaviour
numpy.linalg.det and MATLAB's det use LU factorisation, not cofactors. SymPy's Matrix.det() accepts method='berkowitz', 'bareiss' or 'lu', and exposes Matrix.cofactor(i, j), Matrix.minor(i, j) and Matrix.adjugate() for symbolic work. Eigen specialises determinant() to closed-form expansions for sizes up to four and switches to a factorisation above that.Verification technique
Expand about a second, different line and compare. Independently, transpose the matrix and expand again: the determinant of the transpose must equal the original. For an integer matrix a third check is available by reducing modulo a small prime and repeating the expansion, which catches arithmetic slips without redoing the full-precision work.
Numerical stability
Cofactor expansion has no error bound comparable to that of LU with partial pivoting. It forms and cancels large intermediate products, and for a matrix with entries spanning several orders of magnitude the computed determinant can lose all significant digits. This, rather than cost alone, is why no numerical library offers a cofactor-based determinant.
Failure Modes & Common Mistakes
| Failure mode / mistake | Impact | Root cause | Prevention & detection |
|---|---|---|---|
| Using the minor where the cofactor is required | high | Omitting the factor when assembling an expansion, so terms enter the sum with the wrong sign. | Never write a minor directly into an expansion. Compute as an explicit intermediate with the sign attached. |
| Assuming the leading sign is always positive | high | Starting an expansion about row or column with a sign by analogy with the first-row case. | Evaluate for the actual indices of the first surviving term, or sketch the chequerboard before beginning. |
| Sign error from a negative entry combined with a negative cofactor | high | Two negatives in one term, one from the entry and one from the position, being resolved by inspection rather than by explicit multiplication. | Write each term as three explicit factors — sign, entry, minor — and multiply them in order. |
| Deleting the wrong row or column | medium | Off-by-one indexing when forming , or deleting by position in a reordered copy of the matrix. | Cross out the row and column physically on paper, or index the submatrix construction from the original matrix in code, never from a partially modified one. |
| Scaling a row without correcting the determinant | medium | Clearing fractions by multiplying a row through, which multiplies the determinant by the same factor. | Restrict zero-creation to row-addition operations, which leave the determinant unchanged. Record any scaling or interchange immediately and divide it out at the end. |
| Applying cofactor expansion to a large dense matrix in code | high | Reusing a small teaching implementation on production-sized data, where the runtime becomes effectively infinite. | Cap any recursive implementation at a small size and dispatch to an LU-based determinant above it. |
| Trusting a floating-point cofactor expansion | medium | Catastrophic cancellation between large intermediate products, which can destroy every significant digit of the result. | Use exact arithmetic for cofactor expansion, or use a factorisation-based determinant in floating point. |
| Missing an obvious zero row or column | low | Beginning a full expansion without inspecting the matrix, when a zero line makes the determinant zero immediately. | Scan for zero rows, zero columns, repeated rows and triangular structure before choosing any expansion line. |
FAQs
What is the difference between a minor and a cofactor?
A minor is the determinant of the submatrix obtained by deleting one row and one column. A cofactor is that same determinant multiplied by , the chequerboard sign of its position. Cofactors are what appear in an expansion; using a minor in their place produces sign errors in roughly half the terms.
Can I really expand about any row or column?
Yes. For a matrix of size there are row expansions and column expansions, and all produce the same value. Fully unwound they are simply different orderings of the same signed products. The freedom is used to pick whichever line has the most zeros.
Why is the determinant of a triangular matrix just the product of the diagonal?
Expanding an upper triangular matrix about its first column leaves one non-zero term, since every entry below the first is zero. The surviving submatrix is again upper triangular, so the argument repeats and peels off one diagonal entry at each stage. Lower triangular matrices follow by expanding about the first row instead.
How do row operations affect a determinant?
Adding a multiple of one row to another leaves it unchanged, interchanging two rows negates it, and scaling a row by multiplies it by . Only the first is free, which is why zeros should be manufactured by row addition alone unless you are prepared to track the corrections.
Is cofactor expansion ever the right computational choice?
For very small fixed sizes and for exact arithmetic, yes. Two- and three-dimensional geometric predicates are evaluated by unrolled cofactor expansions precisely because the method is division-free and therefore exact over the integers. For anything dense and larger than about four, LU factorisation is faster by orders of magnitude and far more stable.
Does the cofactor matrix have a use of its own?
Yes. Its transpose is the adjugate, and . Dividing by the determinant gives a closed-form inverse. The identity is genuinely useful for matrices and for symbolic derivations, but computing cofactors makes it impractical as a numerical inversion algorithm.
If a row of the matrix is entirely zero, what is the determinant?
Zero. Expanding about that row makes every term vanish, since each carries a factor of zero. The same argument applies to a zero column. Consequently a matrix with a zero row or column is always singular, which can be seen without any arithmetic at all.
References
- Beezer, R. A. A First Course in Linear Algebra, Version 0.70. University of Puget Sound, 2006. Section DM, Subsection CD. Licensed under the GNU Free Documentation License v1.2.
- ISO 80000-2:2019, Quantities and units — Part 2: Mathematics. International Organization for Standardization.
- Higham, N. J. Accuracy and Stability of Numerical Algorithms, 2nd edition. Society for Industrial and Applied Mathematics, 2002.
- Anderson, E. et al. LAPACK Users' Guide, 3rd edition. Society for Industrial and Applied Mathematics, 1999.
- Shewchuk, J. R. Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates. Discrete & Computational Geometry, 1997.
AI Suggested Questions
- Given a matrix, count the subdeterminants required by expansion about each of its ten rows and columns and identify the cheapest choice.
- Show how two row-addition operations can reduce a dense determinant to a single cofactor, and confirm the determinant is unchanged.
- Derive the adjugate inverse formula from the identity , and explain why the off-diagonal entries of that product vanish.
- Why do robust geometric predicates use exact cofactor expansion rather than a floating-point determinant, and what does an adaptive precision filter add?
- Prove by induction that the determinant of a block upper-triangular matrix equals the product of the determinants of its diagonal blocks.
- Compare SymPy's Bareiss, Berkowitz and cofactor determinant methods on a symbolic matrix with a parameter, in both runtime and expression size.
Related Calculators
Expand a determinant about a chosen row or column, showing every minor, sign and partial product.
Determinant CalculatorEvaluate a determinant by cofactor expansion or LU factorisation, in exact or floating-point arithmetic.
Adjugate & Cofactor Matrix CalculatorBuild the full cofactor matrix, its transpose and the adjugate inverse for a small square matrix.
