I'm trying to investigate the source of residuals of a matrix equation problem (Ax=b). To verify my answer, I subtract Ax-b, expecting 0. Instead of "pure" zeros, I obtain values in the same order of magnitude as machine epsilon, which is fine. The problem, is that these residuals seem to be multiples of each other, so I'm unsure how to interpret them.
I found some details here: Machine epsilon computation issue, this didn't clarify why multiples of the epsilon arise instead of just one or the other.
I checked on my system using np.finfo(float).eps
which produced 2.220446049250313e-16
. One of the residuals I get in the solution x is identical to this value, however, the other seems to be half the epsilon.
Here's the code I used:
# Arbitrary Matrix A and Vector b
A = np.array([[2,-1,0],[1,-2,1],[0,-1,2]])
b = np.array([[1],[0],[1]])
# Solve for Vector x
x = np.linalg.solve(A,b)
# Calculate difference, expected to be column of zeros
diff = A.dot(x) - b
print(diff)
Here's the output:
Output:
[[ 0.00000000e+00]
[-1.11022302e-16] #-------> Is this machine epsilon...
[-2.22044605e-16]] #-------> ...or this?
What is the explanation/interpretation for this? I understand that values smaller than epsilon can still be represented, but in that case why aren't both residuals -1.11022302e-16
?
Thanks in advance!