Why This Matters
The determinant is a single number computed from a square matrix that tells you something profound: does this matrix squish space down to a lower dimension, or does it preserve the full dimensionality? If the determinant is zero, the matrix collapses space -- it maps some nonzero vector to zero, it has no inverse, and the associated system of equations either has no solution or infinitely many. If the determinant is nonzero, the matrix is invertible, and everything works cleanly.
Beyond the yes-or-no question of invertibility, the absolute value of the determinant tells you the factor by which the matrix scales areas (in 2D) or volumes (in 3D). A 2x2 matrix with determinant 6 stretches every unit square into a parallelogram with area 6. A negative determinant means the transformation also flips orientation -- it turns a right-handed coordinate system into a left-handed one.
Cofactor expansion is the classic algorithm for computing determinants. You pick a row or column, multiply each entry by its cofactor (a signed minor), and sum the results. For a 2x2 matrix, the formula is simply ad - bc. For larger matrices, cofactor expansion is recursive: each 3x3 determinant requires three 2x2 determinants, each 4x4 requires four 3x3s, and so on. In practice, row reduction is faster for large matrices, but cofactor expansion builds essential intuition.
Define Terms
Visual Model
The full process at a glance. Click Start tour to walk through each step.
The determinant is a single number from a square matrix: nonzero means invertible, zero means singular, and the absolute value measures area or volume scaling.
Code Example
// Determinant calculations in JavaScript
// 2x2 determinant: ad - bc
function det2x2(A) {
return A[0][0] * A[1][1] - A[0][1] * A[1][0];
}
console.log("det [[3,1],[2,4]]:", det2x2([[3, 1], [2, 4]])); // 10
console.log("det [[1,2],[2,4]]:", det2x2([[1, 2], [2, 4]])); // 0 (singular!)
// 3x3 determinant via cofactor expansion along row 0
function det3x3(A) {
return (
A[0][0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) -
A[0][1] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) +
A[0][2] * (A[1][0] * A[2][1] - A[1][1] * A[2][0])
);
}
const M = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
console.log("det 3x3:", det3x3(M)); // 0 (rows are linearly dependent)
const N = [[2, 1, -1], [-3, -1, 2], [-2, 1, 2]];
console.log("det 3x3:", det3x3(N)); // -1
// General NxN determinant (recursive cofactor expansion)
function det(A) {
const n = A.length;
if (n === 1) return A[0][0];
if (n === 2) return det2x2(A);
let result = 0;
for (let j = 0; j < n; j++) {
// Build minor: remove row 0, column j
const minor = A.slice(1).map(row =>
row.filter((_, col) => col !== j)
);
const sign = j % 2 === 0 ? 1 : -1;
result += sign * A[0][j] * det(minor);
}
return result;
}
console.log("det(N) recursive:", det(N)); // -1Interactive Experiment
Try these exercises:
- Compute det([[1,0],[0,1]]). This is the identity matrix. What does a determinant of 1 mean geometrically?
- Compute det([[2,0],[0,3]]). This matrix scales x by 2 and y by 3. How does the determinant relate to the area of a 1x1 square after transformation?
- Find a 2x2 matrix with determinant 0. What happens when you try to solve Ax = b with this matrix?
- Verify that det(AB) = det(A) * det(B) for two 2x2 matrices of your choice.
- Compute the 3x3 determinant of [[1,2,3],[4,5,6],[7,8,9]]. Why is it 0? (Hint: look at the rows.)
Quick Quiz
Coding Challenge
Write two functions: (1) `det2(A)` that computes the determinant of a 2x2 matrix using the formula ad - bc, and (2) `det3(A)` that computes the determinant of a 3x3 matrix using cofactor expansion along the first row.
Real-World Usage
Determinants appear throughout science and engineering:
- Invertibility check: Before solving Ax = b, checking whether det(A) is nonzero tells you whether a unique solution exists. This is fundamental in numerical computing.
- Change of variables: In multivariable calculus, the Jacobian determinant converts between coordinate systems (like polar to Cartesian). It appears in every integral transformation.
- Computer graphics: Determinants detect degenerate triangles (zero area), compute signed volumes, and determine whether a transformation preserves or flips handedness.
- Eigenvalue computation: Eigenvalues are the roots of det(A - lambda*I) = 0. The determinant literally defines the characteristic polynomial.
- Cross product: The cross product of two 3D vectors can be computed as a 3x3 determinant with unit vectors in the first row.