# dup_count_complex_roots() can't handle degenerate cases #14738

Open
opened this Issue May 23, 2018 · 1 comment

Projects
None yet
1 participant
Contributor

### skirpichev commented May 23, 2018

 At least, if length of the real interval for the initial rectangle is zero: In [4]: dup_count_complex_roots([1, 0, 1], ZZ, inf=(ZZ(0),ZZ(-1)), sup=(ZZ(0), ZZ(2))) --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) in () ----> 1 dup_count_complex_roots([1, 0, 1], ZZ, inf=(ZZ(0),ZZ(-1)), sup=(ZZ(0), ZZ(2))) ~/src/sympy/sympy/polys/rootisolation.py in dup_count_complex_roots(f, K, inf, sup, exclude) 1266 Q_L4 = _intervals_to_quadrants(I_L4, f1L4F, f2L4F, t, v, F) 1267 -> 1268 T = _traverse_quadrants(Q_L1, Q_L2, Q_L3, Q_L4, exclude=exclude) 1269 1270 return _winding_number(T, F) ~/src/sympy/sympy/polys/rootisolation.py in _traverse_quadrants(Q_L1, Q_L2, Q_L3, Q_L4, exclude) 1160 rules.append((_rules_ambiguous[qq], corners[(j, i)])) 1161 else: -> 1162 raise NotImplementedError("3 element rule (corner): " + str(qq)) 1163 1164 q1, k = Q[0], 1 NotImplementedError: 3 element rule (corner): ('OO', 'OO', 'A1') The output should be 2, I think. Consider In [6]: dup_count_complex_roots([1, 0, 1], ZZ, inf=(ZZ(0),ZZ(-1)), sup=(QQ(1, 100000), ZZ(2))) Out[6]: 2

Contributor

### skirpichev commented May 31, 2018

 Thinking more, I'm not sure if 2 is a correct output here. According to the algorithm paper, it's important that roots which lie on the boundaries of adjacent rectangles be counted with exactly one rectangle. This condition is met by counting roots on the north edge, the east edge and on the north east corner. I see two options how degenerate rectangles fit this picture. Either don't count roots on them or forbid such rectangles completely (raise an exception). Simple, but not too useful.