Is it possible to use SymPy library to get intervals (with rational endpoints) such that there is exactly one root in the interval? I would like to use an implementation of RRI algorithm for my purpose. I believe that the interval function does this. Is this correct? Is it guaranteed that the output intervals are guaranteed to not have any common points?
Here we can see that the point -1 is a common endpoint between the second and
the third term. Is it possible to enforce that there be no common point?
Best
ImportError: cannot import name 'find_poly_sign' from 'sympy' (/path_to_python/python3.8/site-packages/sympy/__init__.py)
The documentation of SymPy here does not seem to have this function. Would be great to get some pointers on how to import
the function in the code.
Best
You might try
def distinct_intervals(p): P=Poly(p) iv = P.intervals() print(iv) for i in range(len(iv)-1): (lo,hi),n=iv[i] (LO,HI),N=iv[i+1] while hi==LO: if lo!=hi: (lo,hi),n=iv[i]=P.refine_root(lo,hi,(hi-lo)/2),n else: assert LO!=HI (LO,HI),N=iv[i+1]=P.refine_root(LO,HI,(HI-LO)/2),N return iv >>> distinct_intervals(Poly(x**6 + 19/5*x**5 + 131/50*x**4 - x**2 - 19/5*x - 131/50, x, domain='QQ')) [((-3, -2), 1), ((-1, -1), 1), ((-10/11, -9/10), 1), ((1, 1), 1)]/c