How to handle rounding error?

15 vues (au cours des 30 derniers jours)
Gobi
Gobi le 16 Mai 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?

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Mai 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

Plus de réponses (0)

Catégories

En savoir plus sur Numeric Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by