Accuracy of solving a system
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!