How to avoid rounding error

5 次查看(过去 30 天)
When I use lu[A] for A = [10^(-20) 1 ; 1 2] I get 2 matrices (L and U). When I multiply them, the result is not the same as the original matrix A. What method can I use in order to get the correct matrix A?
  1 个评论
Rik
Rik 2021-4-9
You could try vpa.
The more fundamental problem is that computers have finite precision. If you want infinite precision, you will need to use algebraic tools. Not every problem can be solved perfectly. The general solution for this is to avoid problems that span more than 20 orders of magnitude, so you can rely on eps to estimate if your results are close enough.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-4-9
A = [sym(10)^(-20) 1 ; 1 2]
A = 
[L,U] = lu(A)
L = 
U = 
L*U - A
ans = 
You can see from this that in order to get back A exactly, then you need a system that can distinguish 99999999999999999998 from 100000000000000000000, but
eps(100000000000000000000)
ans = 16384
it certainly is not double precision arithmetic.
  1 个评论
Walter Roberson
Walter Roberson 2021-4-10
syms N real
A = [sym(10)^(-N) 1 ; 1 2]
A = 
[L,U] = lu(A)
L = 
U = 
eqn = U(2,2) == -1/eps
eqn = 
solve(eqn)
ans = 
vpa(ans)
ans = 
15.653559774527022343979915836331
So beyond about 10^15.65 you go beyond what can be represented exactly in double precision.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numbers and Precision 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by