inv
Matrix inverse
Syntax
Description
Examples
Input Arguments
More About
Tips
It is seldom necessary to form the explicit inverse of a matrix. A frequent misuse of
inv
arises when solving the system of linear equations Ax = b. One way to solve the equation is withx = inv(A)*b
. A better way, from the standpoint of both execution time and numerical accuracy, is to use the matrix backslash operatorx = A\b
. This produces the solution using Gaussian elimination, without explicitly forming the inverse. Seemldivide
for further information.
Algorithms
inv
performs an LU decomposition of the
input matrix (or an LDL decomposition if the input matrix is Hermitian).
It then uses the results to form a linear system whose solution is
the matrix inverse inv(X)
. For sparse inputs, inv(X)
creates
a sparse identity matrix and uses backslash, X\speye(size(X))
.