You should listen to Matlab and use the second option. inv(A)*b
and A\b
are computed with different algorithms under the hood, and \
is indeed more accurate.
The documentation for inv
states:
In practice, 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 this is with x = inv(A)*b. A better way, from both an execution time and numerical accuracy standpoint, is to use the matrix division operator x = A\b. This produces the solution using Gaussian elimination, without forming the inverse. See mldivide () for further information.