Main Content

det

Determinant of symbolic matrix

Description

example

B = det(A) returns the determinant of the square matrix of symbolic numbers, scalar variables, or functions A.

example

B = det(A,'Algorithm','minor-expansion') uses the minor expansion algorithm to evaluate the determinant of A.

example

B = det(M) returns the determinant of the square symbolic matrix variable or matrix function M.

Examples

collapse all

Compute the determinant of a matrix that contains symbolic scalar variables.

syms a b c d
A = [a b; c d];
B = det(A)
B = ad-bc

Compute the determinant of a matrix that contains symbolic numbers.

A = sym([2/3 1/3; 1 1]);
B = det(A)
B = 

13

Create a symbolic matrix that contains polynomial entries.

syms a x 
A = [1, a*x^2+x, x;
     0, a*x, 2;
     3*x+2, a*x^2-1, 0]
A = 

(1ax2+xx0ax23x+2ax2-10)

Compute the determinant of the matrix using minor expansion.

B = det(A,'Algorithm','minor-expansion')
B = 3ax3+6x2+4x+2

Compute the determinant of a 4-by-4 block matrix

M=[A02,2CB]

where A, B, and C are 2-by-2 submatrices. The notation 02,2 represents a 2-by-2 submatrix of zeros.

Use symbolic matrix variables to represent the submatrices in the block matrix.

syms A B C [2 2] matrix
Z = symmatrix(zeros(2))
Z = 02,2
M = [A Z; C B]
M = 

(A02,2CB)

Find the determinant of the matrix M.

det(M)
ans = 

det(A02,2CB)

Convert the result from symbolic matrix variables to symbolic scalar variables using symmatrix2sym.

D1 = simplify(symmatrix2sym(det(M)))
D1 = A1,1A2,2-A1,2A2,1B1,1B2,2-B1,2B2,1

Check if the determinant of matrix M is equal to the determinant of A times the determinant of B.

D2 = symmatrix2sym(det(A)*det(B))
D2 = A1,1A2,2-A1,2A2,1B1,1B2,2-B1,2B2,1
isequal(D1,D2)
ans = logical
   1

Compute the determinant of the matrix polynomial a0I2+A, where A is a 2-by-2 matrix.

Create the matrix A as a symbolic matrix variable and the coefficient a0 as a symbolic scalar variable. Create the matrix polynomial as a symbolic matrix function f with a0 and A as its parameters.

syms A [2 2] matrix
syms a0
syms f(a0,A) [2 2] matrix keepargs
f(a0,A) = a0*eye(2) + A
f(a0, A) = a0I2+A

Find the determinant of f using det. The result is a symbolic matrix function of type symfunmatrix that accepts scalars, vectors, and matrices as its input arguments.

fInv = det(f)
fInv(a0, A) = deta0I2+A

Convert the result from the symfunmatrix data type to the symfun data type using symfunmatrix2symfun. The result is a symbolic function that accepts scalars as its input arguments.

gInv = symfunmatrix2symfun(fInv)
gInv(a0, A1_1, A1_2, A2_1, A2_2) = A1,1a0+A2,2a0+a02+A1,1A2,2-A1,2A2,1

Input Arguments

collapse all

Input matrix, specified as a square matrix of symbolic numbers, square matrix of symbolic scalar variables, or square matrix of symbolic functions.

Data Types: single | double | sym | symfun

Input matrix, specified as a square symbolic matrix variable or square symbolic matrix function.

Data Types: symmatrix | symfunmatrix

Tips

  • Matrix computations involving many symbolic variables can be slow. To increase the computational speed, reduce the number of symbolic variables by substituting the given values for some variables.

  • The minor expansion method is generally useful to evaluate the determinant of a matrix that contains many symbolic scalar variables. This method is often suited to matrices that contain polynomial entries with multivariate coefficients.

References

[1] Khovanova, T. and Z. Scully. "Efficient Calculation of Determinants of Symbolic Matrices with Many Variables." arXiv preprint arXiv:1304.4691 (2013).

Version History

Introduced before R2006a

expand all

See Also

|