Determinant of symbolic matrix
Compute Determinant of Matrix with Symbolic Scalar Variables
Compute the determinant of a matrix that contains symbolic scalar variables.
syms a b c d A = [a b; c d]; B = det(A)
Compute Determinant of Matrix with Symbolic Numbers
Compute the determinant of a matrix that contains symbolic numbers.
A = sym([2/3 1/3; 1 1]); B = det(A)
Compute Determinant Using Minor Expansion
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]
Compute the determinant of the matrix using minor expansion.
B = det(A,'Algorithm','minor-expansion')
Compute Determinant of Block Matrix
This example shows how to compute the determinant of a block matrix. For example, find the determinant of a 4-by-4 block matrix
where , , and are 2-by-2 submatrices.
Use symbolic matrix variables to represent the submatrices in the block matrix.
syms A B C [2 2] matrix Z = symmatrix(zeros(2))
M = [A Z; C B]
Find the determinant of the matrix .
Convert the result from symbolic matrix variable to symbolic scalar variables using
D1 = simplify(symmatrix2sym(det(M)))
Check if the determinant of matrix is equal to the determinant of times the determinant of .
D2 = symmatrix2sym(det(A)*det(B))
ans = logical 1
A — Input matrix
square numeric matrix | square matrix of symbolic scalar variables
Input, specified as a square numeric matrix, or matrix of symbolic scalar variables.
M — Input matrix
square symbolic matrix variable
Input, specified as a square symbolic matrix variable (since R2021a).
Matrix computations involving many symbolic scalar variables can be slow. To increase the computational speed, reduce the number of symbolic scalar 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.
 Khovanova, T. and Z. Scully. "Efficient Calculation of Determinants of Symbolic Matrices with Many Variables." arXiv preprint arXiv:1304.4691 (2013).