Note: Use only in the MuPAD Notebook Interface. This functionality does not run in MATLAB.
To compute the determinant of a square matrix numerically, use
For example, compute the determinant of the 5
×5 Pascal matrix:
When you use numeric functions, the result can be extremely
sensitive to roundoff errors. For example, the determinant of a Pascal
matrix of any size is 1. However, if you use the
numeric::det function to compute the
determinant of a 25×25 Pascal
matrix, you get the following incorrect result:
When computing determinants numerically, you can use the
to employ the hardware or software float arithmetic, respectively.
(You can use the short names for these options:
When you use the
HardwareFloats option, MuPAD® converts
all input data to hardware floating-point numbers, and passes the
data for processing by compiled C code outside of the MuPAD session.
Then, the results get back into the MuPAD session. Hardware arithmetic
often allows you to perform computations much faster than software
arithmetic, which uses the MuPAD kernel for performing computations.
The precision of hardware arithmetic is limited to about 15
digits. By default, the
HardwareFloats option. The function switches
to software arithmetic under one or more of the following conditions:
You use the
MinorExpansion option explicitly.
The current value of
DIGITS is larger than
The input data or computed data involves numbers that are larger than 10308 or smaller than 10- 308. Hardware floats cannot represent such numbers.
The precision of hardware and software arithmetic can differ.
Therefore, the results obtained with the
also can differ. For example, compute the determinant of the 25
×25 Pascal matrix using each of the options.
Both numeric results are several orders larger than the correct answer
because of the roundoff errors. However, the result obtained using
software arithmetic is several orders closer to the correct answer:
P := linalg::pascal(25): detP := det(P): float(detP); numeric::det(P, SoftwareFloats); numeric::det(P, HardwareFloats)
Another example of numerically ill-conditioned matrices is the Hilbert matrices. For example, create the 20×20 Hilbert matrix, compute its determinant symbolically, and then approximate the result numerically:
H := linalg::hilbert(15): detH := det(H): float(detH)
Now, use the
to compute the determinant numerically:
The numeric result obtained with the
is closer to the correct result:
To prevent the conversion of input data to floating-point numbers
while using the
Symbolic option. This option allows you
to compute the determinant exactly (without roundoff errors). For
matrices over particular rings and fields, the determinant computed
Symbolic option can differ from the determinant
The reason is that
computations over the component domain of the input matrix. The
Symbolic option always performs computations
over the field of arbitrary MuPAD expressions. For example, create
the following matrix over the domain
A := Dom::Matrix(Dom::IntegerMod(5))([[1, 2], [3, 4]])
computes the determinant over the component domain
Symbolic option computes the determinant
of the following matrix instead of the original matrix
The determinant of this matrix is an integer number:
switches to the
Symbolic option under one or more
of the following conditions:
You use the
Symbolic option explicitly.
The input data contains symbolic objects.