Accuracy of solving a system

2 次查看(过去 30 天)
Eric Schols
Eric Schols 2016-2-24
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?

回答(1 个)

Roger Stafford
Roger Stafford 2016-2-24
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 个评论
Eric Schols
Eric Schols 2016-2-24
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. :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by