Skip to content

Matrix Determinant Calculator

Enter a 2×2, 3×3, or 4×4 square matrix to calculate its determinant, follow the cofactor expansion, and see immediately whether the matrix is singular or invertible.

Free linear algebra calculator

Calculate a matrix determinant

Enter a 2×2, 3×3, or 4×4 matrix. The result updates immediately and shows the cofactor expansion.

Matrix size

Changing the size loads a small example matrix. Replace any entry with an integer or decimal.

Determinant

-9

Invertible matrix det(A) ≠ 0, so the matrix has an inverse.
Cofactor expansion steps
  1. Expand det(A) along its first row.
  2. det(A) = (2)det(A₁₁) − (-1)det(A₁₂) + (0)det(A₁₃)
  3. det(A₁₁) = (3 × 1) − (2 × 4) = -5
  4. det(A₁₂) = (1 × 1) − (2 × 0) = 1
  5. det(A₁₃) = (1 × 4) − (3 × 0) = 4
  6. det(A) = -10 + 1 + 0 = -9

Quick reference

Matrix sizeDirect calculationBest way to use this page
2×2ad − bcCheck the basic formula and sign order
3×3Expand into three 2×2 minorsFollow each cofactor contribution
4×4Expand into four 3×3 minorsAudit a hand calculation without hiding intermediate steps

For every supported size, det(A) = 0 means the matrix is singular and has no inverse. A nonzero determinant means the square matrix is invertible.

What is a determinant, and why does it matter?

The determinant is one number computed from a square matrix that tells you whether the represented linear transformation collapses space and how it scales oriented area or volume.

The zero-versus-nonzero test solves an immediate problem: before attempting to invert a matrix or solve a linear system with a unique solution, you can check whether the transformation has lost a dimension. The determinant's magnitude gives the area or volume scale factor, while its sign records whether orientation flips.

The determinant is not matrix multiplication. If you are composing transformations or multiplying compatible arrays, use the NumPy matrix multiplication guide. If an array has the wrong shape, NumPy reshape explains how to reorganize it without changing its values.

How cofactor expansion works

This calculator expands along the first row. For each entry a₁ⱼ, it removes row 1 and column j to form a minor matrix M₁ⱼ, then applies the alternating sign pattern + − + −.

For an n × n matrix:

det(A) = a₁₁det(M₁₁) − a₁₂det(M₁₂) + a₁₃det(M₁₃) − ...

The process repeats until each remaining minor is 2×2. That base case uses:

det([[a, b], [c, d]]) = ad − bc

Worked 3×3 example

For the matrix below, expand along the first row:

A = [[2, -1, 0],
     [1,  3, 2],
     [0,  4, 1]]

The minors for the first two nonzero entries have determinants -5 and 1. Therefore det(A) = 2(-5) − (-1)(1) + 0 = -9. The negative sign says the transformation reverses orientation, and the nonzero value says the matrix is invertible.

Singular matrices and numerical zero

A matrix is singular when its rows or columns are linearly dependent. For example, if one row is twice another, the determinant is zero because the transformation collapses at least one dimension.

With decimal input, floating-point arithmetic can produce a tiny value such as 2.2e-16 instead of exact zero. The interactive tool treats an absolute determinant within 1e-10 of zero as singular. In production numerical work, choose a tolerance that reflects the scale and conditioning of your data.

For ways to construct test arrays, see NumPy zeros. To inspect array structure visually, use Visualize a NumPy Array.

The same determinant computation in Python

NumPy computes determinants with np.linalg.det. Because it uses floating-point linear algebra, compare against zero with np.isclose rather than det == 0.

import numpy as np
 
A = np.array([
    [3, 2, 0, 1],
    [4, 0, 1, 2],
    [3, 0, 2, 1],
    [9, 2, 3, 1],
], dtype=float)
 
determinant = np.linalg.det(A)
is_singular = np.isclose(determinant, 0.0, atol=1e-10)
 
print(determinant)  # approximately 24.0
print(is_singular)  # False

To verify several matrices in the same notebook as the rest of your analysis, RunCell (opens in a new tab) can run this NumPy cell in Jupyter context while keeping the tolerance visible.

Common determinant traps

  • Cofactor signs alternate + − + −; missing the minus sign in column 2 changes the result.
  • A determinant exists only for a square matrix.
  • A * B, A @ B, and np.linalg.det(A) are three different operations.
  • A determinant close to zero can indicate an ill-conditioned matrix even when it is not exactly singular.
  • Cofactor expansion is useful for explanation and small matrices, but decomposition-based numerical methods are better for large matrices.

FAQ

How do you calculate a 2×2 determinant?

For [[a, b], [c, d]], calculate ad − bc. Multiply the main diagonal, multiply the other diagonal, and subtract the second product from the first.

What does a determinant of zero mean?

It means the matrix is singular. Its rows or columns are linearly dependent, the associated transformation collapses a dimension, and the matrix has no inverse.

Can a determinant be negative or decimal?

Yes. A negative determinant indicates an orientation reversal. Integer or decimal entries can produce positive, negative, zero, integer, or decimal determinants.

Why is NumPy's determinant slightly different from a hand calculation?

np.linalg.det uses floating-point arithmetic and matrix factorization, so rounding can leave a very small error. Use np.isclose with a scale-appropriate tolerance when testing for zero.

Does this calculator use Gaussian elimination?

No. It uses recursive cofactor expansion so the minors and alternating signs remain visible. Elimination or LU factorization is usually more efficient for larger matrices.

Related Guides