sympy/sympy — pull request #8360 by jksuom (2014-10-31 16:17:25+00:00)
Title: polys: Boarderline cases in complex root isolation

Complex polynomial root isolation works by subdividing rectangles
in the complex plane and searching for *axial points* on their
boundaries, i.e., points at which the value of the polynomial lies
on one (or both) of the coordinate axes.

The majority of the axial points are of the 'generic type'. They are
in the middle of a boundary edge, their image is on one axis only, and
the image of the edge under the polynomial map passes from one side to
the other.

However, as the coefficients of the polynomial and the subdivision
points are rational, these conditions are occasionally not met.
The case where an axial point is a root of the polynomial is well
cared for (and quite rare), but there are other situations where
roots are lost or the algorithm is interrupted.
(Changing the subdivision strategy may help but not for all polynomials.)

This commit deals with two exceptional cases.

1) If the image of edge is tangent to the axis and returns to
the same quadrant (axial point of 'even order') there will be
no contribution to the winding number. This is what happens in #8285.

2) If an axial point is also a subdivision point, it has to be
included in both parts of the divided edge (a 'double corner case').
Otherwise roots may be lost as in #8316.