det

det(x)

Try it yourself:


det(): The Determinant of a Square Matrix

det() calculates the determinant of a square matrix. The determinant is a single number that describes how a linear transformation scales signed area or volume. For a 2×2 matrix [[a, b], [c, d]], det is a×d − b×c.

Why determinants matter

A zero determinant means the matrix is singular: it collapses at least one dimension and cannot have an ordinary inverse. Before calling inv(), det can provide a useful conceptual check. A nonzero determinant indicates an inverse exists, although values very close to zero may still be numerically ill-conditioned.

det requires a square matrix. Check dimensions with size() when a matrix comes from external data. Determinants are not calculated element by element, so do not confuse det with prod(). For decomposition-based work, lu() or qr() can be more informative.

Interpretation

The sign records orientation: a negative determinant includes a reflection, while magnitude records scale. In geometric and engineering calculations, retain full precision and use abs() only when you specifically need unsigned area or volume.

All functions