# Sensitivity of polynomial roots¶

Consider the polynomial $$x^3 - 21 x^2 + 120 x - 100 = 0$$ The roots are 1, 10, 10.

In [3]:
from sympy import N, roots
from sympy import Integer as Int

In [4]:
r= roots([1,-21,120,-100])
for x in r:
print x

1
10


Perturb the coefficient of $x^3$ $$\frac{99}{100}x^3 - 21 x^2 + 120 x - 100 = 0$$

In [5]:
r= roots([Int(99)/100,-21,120,-100])
for x in r:
print N(x)

1.0001235059284 + 0.e-20*I
9.0412990764462 + 0.e-20*I
11.1706986297466 + 0.e-20*I


The double roots are very sensitive. Now perturb the coefficient in the other direction $$\frac{101}{100}x^3 - 21 x^2 + 120 x - 100 = 0$$

In [6]:
r= roots([Int(101)/100,-21,120,-100])
for x in r:
print N(x)

9.89610130781283 + 1.04369535224477*I
9.89610130781283 - 1.04369535224477*I
0.999876592295142


The double roots become complex, again showing they are very sensitive to the coefficient of $x^3$.