How to handle rounding error?

15 views (last 30 days)
Gobi
Gobi on 16 May 2015
Answered: Walter Roberson on 16 May 2015
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?

Accepted Answer

Walter Roberson
Walter Roberson on 16 May 2015
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

More Answers (0)

Categories

Find more on Numeric Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!