Accuracy of solving a system

3 views (last 30 days)
Eric Schols
Eric Schols on 24 Feb 2016
Commented: Eric Schols on 24 Feb 2016
With
k = 12;
eps = 10^(-k);
A = [[1+eps,1];[1,1+eps]];
I can control the condition number of A to be approximately 2*10^k. Then, when I solve an equation and examine its accuracy:
x = unifrnd(0,2,2,1);
y = A*x;
disp(norm(A\y-x))
This seems to give accuracy up to 16-k digits. Is this a general rule of thumb regarding accuracy in MATLAB?
MATLAB returns a warning when the condition number is above 1e16, and a condition number of 10^k roughly leads to losing k digits in acccuracy, so we lose 16-k digits?

Answers (1)

Roger Stafford
Roger Stafford on 24 Feb 2016
There is no hard and fast rule as to the number of significant digits in computations. It depends on the values and the nature of the computation. However, it is helpful to realize that the double precision floating point numbers which matlab uses are in binary form and have 53 bits (binary digits) in their significands (mantissas) which is about equivalent to 16 decimal digits. Thus, many computations have roughly an accuracy of 16 decimal places. As you can imagine, it is easy to have computations with far less accuracy in the result, as say in the subtraction of two values that are nearly equal. If two values with equal exponential parts differ only in the least n bits of their significands, the subtraction result will have lost 53-n bits of relative accuracy. Your example looks rather similar.
  1 Comment
Eric Schols
Eric Schols on 24 Feb 2016
Thank you for your answer. I figured it would be case dependent and no hard and fast rule, as you put it, was available, but your answer clarifies things for me. I now know how to describe the situation in a report I am writing. :)

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!