Y = inv(X)
X^(-1)is equivalent to
x = A\bis computed differently than
x = inv(A)*band is recommended for solving systems of linear equations
he backslash calculation is quicker and has less residual error by several orders of magnitude. The fact that err_inv and err_bs are both on the order of 1e-6 simply reflects the condition number of the matrix.
The behavior of this example is typical. Using A\b instead of inv(A)*b is two to three times faster, and produces residuals on the order of machine accuracy relative to the magnitude of the data.