How to handle rounding error?

1 次查看(过去 30 天)
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 中查找有关 Polynomials 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by