det
det(M)
Matrix determinant
Examples
-
Calculate the determinant of a 2x2 matrix:
julia> M = [1 2; 3 4]; julia> det(M) -2.0
This example calculates the determinant of the 2x2 matrix
M
. -
Compute the determinant of a 3x3 matrix:
julia> M = [1 2 3; 4 5 6; 7 8 9]; julia> det(M) 0.0
It calculates the determinant of the 3x3 matrix
M
. - Handle non-square matrices:
julia> M = [1 2 3; 4 5 6]; julia> det(M) ERROR: LinearAlgebra.SingularException(2)
In this example, the function throws a
SingularException
because the matrixM
is not square. The determinant can only be calculated for square matrices.
Common mistake example:
julia> M = [1 2; 3 4; 5 6];
julia> det(M)
ERROR: DimensionMismatch("matrix must be square")
Here, the mistake is providing a non-square matrix as input to the det
function. Ensure that the matrix passed to det
is square (same number of rows and columns) to avoid this error.
See Also
Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.