Symbolic Math Toolbox    

Linear Algebraic Operations

Let's do several basic linear algebraic operations.

The command

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

gives

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,

produces

and

yields

We can use the backslash operator to solve a system of simultaneous linear equations. The commands

produce the solution

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

returns

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,

which returns

shows the loss of two digits. So does

which gives

and

which is

Since H is nonsingular, the null space of H

and the column 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

produce

Then

substitutes the computed value of sol for s in H to give

Now, the command

returns

and

produces an error message

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

and then computing

results in a determinant of size 10^(-d) and an inverse with elements on the order of 10^d.


  Linear Algebra Eigenvalues