How to handle rounding error?

조회 수: 13 (최근 30일)
Gobi
Gobi 2015년 5월 16일
답변: Walter Roberson 2015년 5월 16일
I want to check if the roots of a polynomial have absolute value <= 1. tried to handle roundoff error by using eps, but only eps does not work as follows:
p=[1 1 0 0 1 0 0 1 1];
abs(roots(p)) <= 1+eps
abs(roots(p)) <= 1+8*eps
The result:
ans =
0
0
0
0
0
0
1
1
ans =
1
1
1
1
1
1
1
1
So in usual, how should I write a code? Should I use something like 100*eps?

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 16일
By the binomial theorem,
(a+b)^n = a^n + n*a^(n-1)*b + n*(n-1)/2 * a^(n-2)*b^2 + more terms
when b is very small compared to a, then b^2 will be even smaller, and when dealing with floating-point-roundoff-small indicates a term that can probably be neglected unless a is relatively large. So with round-off taken into consideration,
(a+b)^n <=> a^n + n*a^(n-1)*b
and when a is 1, then this naturally simplifies to 1 + n*b
You had an 8th order polynomial (your vector was length 9), so your n=8, and that is the source of your 8 for 8*eps

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by