3.7.6 Matrix Inversion
Here is a simple matrix.
This gives the inverse of m. In producing this formula, Mathematica implicitly assumes that the determinant a d - b c is non-zero.
Multiplying the inverse by the original matrix should give the identity matrix.
You have to use Together to clear the denominators, and get back a standard identity matrix.
Here is a matrix of rational numbers.
Mathematica finds the exact inverse of the matrix.
Multiplying by the original matrix gives the identity matrix.
If you try to invert a singular matrix, Mathematica prints a warning message, and returns the inverse undone.
If you give a matrix with exact symbolic or numerical entries, Mathematica gives the exact inverse. If, on the other hand, some of the entries in your matrix are approximate real numbers, then Mathematica finds an approximate numerical result.
Here is a matrix containing approximate real numbers.
This finds the numerical inverse.
Multiplying by the original matrix gives you an identity matrix with small numerical errors.
You can get rid of the small off-diagonal terms using Chop.
When you try to invert a matrix with exact numerical entries, Mathematica can always tell whether or not the matrix is singular. When you invert an approximate numerical matrix, Mathematica can usually not tell for certain whether or not the matrix is singular: all it can tell is for example that the determinant is small compared to the entries of the matrix. When Mathematica suspects that you are trying to invert a singular numerical matrix, it prints a warning.
Mathematica prints a warning if you invert a numerical matrix that it suspects is singular.
If you work with high-precision approximate numbers, Mathematica will keep track of the precision of matrix inverses that you generate.
This generates a numerical matrix with entries of 50-digit precision.
This takes the matrix, multiplies it by its inverse, and shows the first row of the result.
This generates a 50-digit numerical approximation to a Hilbert matrix. Hilbert matrices are notoriously hard to invert numerically.
The result is still correct, but the zeros now have lower accuracy.
Inverse works only on square matrices. Section 3.7.10 discusses the function PseudoInverse, which can also be used with non-square matrices.