The determinant of a matrix is a scalar value that provides important information about the matrix. The determinant of a matrix can be used to calculate the inverse matrix or solve a system of equations.
A matrix must be a square matrix so that the determinant can be defined.
The determinant of the matrix can be computed in many ways, using NumPy built-in methods, or using mathematical techniques.
For a 2x2 matrix: $M=\begin{bmatrix} x_1 & x_2 \\ y_1 & y_2 \end{bmatrix} -> det(M) = x_1y_2 - x_2y_1$
E.g., $M=\begin{bmatrix} 4 & 2 \\ 6 & 8 \end{bmatrix} ->det(M)= (4 * 8) - (2 *6)=20$
For a 3x3 matrix: $M=\begin{bmatrix} x_1 & x_2 & x_3 \\ y_1 & y_2 & y_3 \\ z_1 & z_2 & z_3 \end{bmatrix}$ . Apply the rule of Sarrus:
$-> det(M)= x_1(y_2z_3 - z_2y_3) - x_2(y_1z_3-z_1y_3) + x_3(y_1z_2 - z_1y_2)$
E.g., $M=\begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 1 \\ 3 & 5 & 6 \end{bmatrix}$
$-> det(M)=1[(4 6) -(51)] - 2[(62) - (3 * 1)]+3[(2 * 5)-(34)]=-5$
For any n x n matrix, we use the method called the Laplace expansion.
Given $M = [a_{ij}]$