In this experiment we will look at both the residual and the error of a calculation using a direct solver.
First set up a problem:
import scipy as sp
import numpy as np
import numpy.linalg as nla
n = 10
A = np.random.rand(n,n)
xstar = np.ones((n,))
b = A.dot(xstar)
for i in range(2):
A = A.dot(A)
print("Cond(A)=",nla.cond(A))
x = nla.solve(A, b)
print("||r|| = ", nla.norm(b-A.dot(x)))
print("||e|| = ", nla.norm(xstar-x))
Here we can see that since the condition number is high, a small residual does not lead to a small error.