Matrix solution sensitivity to right side change (ill-conditioned matrix)
First solve the following system of linear equations
by solving the matrix system , where
A = [1 0.99;0.99 0.98]; b = [1.99;1.97]; x = A\b
x = 1 1
Now consider a different RHS,
bt = [1.989903;1.970106]; xt = A\bt
xt = 2.999999999999532 -1.020299999999527
We can see that a small relative change in the right hand side
results in a large relative change in the solution
fprintf('Relative change in RHS: %g\n', norm(b-bt)/norm(b)); fprintf('Relative change in solution: %g \n ', norm(x-xt)/norm(x));
Relative change in RHS: 5.13123e-05 Relative change in solution: 2.01018