DET

Computes the determinant of a square matrix. The determinant is a scalar value that indicates whether the matrix is invertible and how linear transformations scale signed volume.

For an n \times n matrix A, the determinant is denoted by \det(A). A key property is that A is invertible if and only if \det(A) \neq 0.

Excel Usage

=DET(matrix)
  • matrix (list[list], required): Square 2D array of numeric values.

Returns (float): The determinant of the matrix.

Example 1: Determinant of 2x2 matrix

Inputs:

matrix
1 2
3 4

Excel formula:

=DET({1,2;3,4})

Expected output:

-2

Example 2: Determinant of 3x3 matrix

Inputs:

matrix
1 2 3
4 5 6
7 8 9

Excel formula:

=DET({1,2,3;4,5,6;7,8,9})

Expected output:

0

Example 3: Determinant of 3x3 identity matrix

Inputs:

matrix
1 0 0
0 1 0
0 0 1

Excel formula:

=DET({1,0,0;0,1,0;0,0,1})

Expected output:

1

Example 4: Determinant of upper triangular matrix

Inputs:

matrix
2 1 3
0 -4 5
0 0 0.5

Excel formula:

=DET({2,1,3;0,-4,5;0,0,0.5})

Expected output:

-4

Python Code

import numpy as np
from scipy.linalg import det as scipy_det

def det(matrix):
    """
    Compute the determinant of a square matrix.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.det.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        matrix (list[list]): Square 2D array of numeric values.

    Returns:
        float: The determinant of the matrix.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        matrix = to2d(matrix)

        if not isinstance(matrix, list) or not matrix or not all(isinstance(row, list) for row in matrix):
            return "Error: matrix must be a non-empty 2D list"

        n = len(matrix)
        if any(len(row) != n for row in matrix):
            return "Error: matrix must be square (n x n)"

        try:
            a = np.array(matrix, dtype=float)
        except (ValueError, TypeError):
            return "Error: matrix entries must contain numeric values"

        if not np.all(np.isfinite(a)):
            return "Error: matrix must contain only finite numbers"

        try:
            res = scipy_det(a)
        except Exception as e:
            return f"Error: {str(e)}"

        return float(res)

    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Square 2D array of numeric values.