Compute the determinant of any square matrix using LU factorisation with partial pivoting.
The determinant of a square matrix is computed via LU decomposition with partial pivoting. det(A) = (sign from row swaps) × product of diagonal entries of U. This is O(n³) and numerically stable, unlike cofactor expansion which is O(n!).
Via LU Decomposition
det(A) = (−1)^s × ∏ Uᵢᵢ where s = number of row swaps
A non-zero determinant means the matrix is invertible. Geometrically, |det(A)| is the volume scaling factor of the linear transformation represented by A.
Cofactor expansion has O(n!) complexity — impractical for n > 5. LU decomposition computes the determinant in O(n³) time and handles numerical issues via partial pivoting.