Symbolic Math Toolbox | ![]() ![]() |
Linear Algebraic Operations
Let's do several basic linear algebraic operations.
generates the 3-by-3 Hilbert matrix. With format short
, MATLAB prints
The computed elements of H
are floating-point numbers that are the ratios of small integers. Indeed, H
is a MATLAB array of class double
. Converting H
to a symbolic matrix
This allows subsequent symbolic operations on H
to produce results that correspond to the infinitely precise Hilbert matrix, sym(hilb(3))
, not its floating-point approximation, hilb(3)
. Therefore,
We can use the backslash operator to solve a system of simultaneous linear equations. The commands
All three of these results, the inverse, the determinant, and the solution to the linear system, are the exact results corresponding to the infinitely precise, rational, Hilbert matrix. On the other hand, using digits(16)
, the command
[ 1., .5000000000000000, .3333333333333333] [.5000000000000000, .3333333333333333, .2500000000000000] [.3333333333333333, .2500000000000000, .2000000000000000]
The decimal points in the representation of the individual elements are the signal to use variable-precision arithmetic. The result of each arithmetic operation is rounded to 16 significant decimal digits. When inverting the matrix, these errors are magnified by the matrix condition number, which for hilb(3)
is about 500. Consequently,
[ 9.000000000000082, -36.00000000000039, 30.00000000000035] [-36.00000000000039, 192.0000000000021, -180.0000000000019] [ 30.00000000000035, -180.0000000000019, 180.0000000000019]
shows the loss of two digits. So does
Since H
is nonsingular, the null space of H
produce an empty matrix and a permutation of the identity matrix, respectively. To make a more interesting example, let's try to find a value s
for H(1,1)
that makes H
singular. The commands
substitutes the computed value of sol
for s
in H
to give
because H
is singular. For this matrix, Z = null(H)
and C = colspace(H)
are nontrivial:
It should be pointed out that even though H
is singular, vpa(H)
is not. For any integer value d
, setting
results in a determinant of size 10^(-d)
and an inverse with elements on the order of 10^d
.
![]() | Linear Algebra | Eigenvalues | ![]() |