# poly(((x - 1)**2 + 1)*((x - 1)**2 + 2)*(x - 1)).all_roots() hangs #14291

Closed
opened this Issue Feb 20, 2018 · 6 comments

Projects
None yet
3 participants
Contributor

### skirpichev commented Feb 20, 2018

 bisected to 73fafba
Contributor

### vishalg2235 commented Feb 22, 2018

 I found that the infinite loop occurs here. I am having some difficulty in understanding the code/work of this function. @skirpichev @jksuom can you show me some examples that what `_refine_complexes` do ?
Member

### smichr commented Feb 22, 2018

 what _refine_complexes do Isn't this the routine that tries to locate each root within a rectangle that is horizontally and vertically distinct from every other root's rectangle?
Member

### smichr commented Feb 23, 2018

 The problem is that the complex roots of two equations may share the same real value so the roots will never be isolated to satisfy the assumptions of the routine (which wrongly assumed this would not be the case).
Contributor

### vishalg2235 commented Feb 24, 2018

 @smichr I couldn't locate where in code it is checking the same real value of roots? please help! And `complexes` in _refine_complexes() is: ``````[((0, 6) x (-6, 0), Poly(x**2 - 2*x + 3, x, domain='ZZ'), 1), ((0, 6) x (0, 6), Poly(x**2 - 2*x + 3, x, domain='ZZ'), 1), ((0, 4) x (-4, 0), Poly(x**2 - 2*x + 2, x, domain='ZZ'), 1), ((0, 4) x (0, 4), Poly(x**2 - 2*x + 2, x, domain='ZZ'), 1)] `````` What are those `(0, 6)`, `(0, -6)`?
Contributor

### skirpichev commented Feb 24, 2018

 The problem is that the complex roots of two equations may share the same real value Oh, again wrong (: Complex roots of one equation may share the same real part (actually, we care about different conjugated pairs of roots, if coefficients of the equation are real). BTW, @vishalg2235, I wonder what you did to "locate where in code it is"?
Contributor

### vishalg2235 commented Feb 24, 2018

 @skirpichev I was trying to understand `_refine_complexes()` but couldn't understand what logic is applied here. Can you please get me more familiar with this code ?

Merged

### skirpichev added a commit to skirpichev/diofant that referenced this issue Mar 19, 2018

``` Add regression test ```
`Closes sympy/sympy#14291`
``` 79974c5 ```

### skirpichev added a commit to skirpichev/diofant that referenced this issue Mar 27, 2018

``` Add regression test ```
`Closes sympy/sympy#14291`
``` c315ad9 ```