def test_dup_isolate_all_roots_sqf(): f = [4, -1, 2, 5, 0] assert dup_isolate_all_roots_sqf(f, ZZ) == \ ([(-1, 0), (0, 0)], [((0, -QQ(5,2)), (QQ(5,2), 0)), ((0, 0), (QQ(5,2), QQ(5,2)))]) assert dup_isolate_all_roots_sqf(f, ZZ, eps=QQ(1,10)) == \ ([(QQ(-7,8), QQ(-6,7)), (0, 0)], [((QQ(35,64), -QQ(35,32)), (QQ(5,8), -QQ(65,64))), ((QQ(35,64), QQ(65,64)), (QQ(5,8), QQ(35,32)))])
def intervals(f, all=False, eps=None, inf=None, sup=None, fast=False, sqf=False): """Compute isolating intervals for roots of `f`. """ if not f.lev: if not all: if not sqf: return dup_isolate_real_roots(f.rep, f.dom, eps=eps, inf=inf, sup=sup, fast=fast) else: return dup_isolate_real_roots_sqf(f.rep, f.dom, eps=eps, inf=inf, sup=sup, fast=fast) else: if not sqf: return dup_isolate_all_roots(f.rep, f.dom, eps=eps, inf=inf, sup=sup, fast=fast) else: return dup_isolate_all_roots_sqf(f.rep, f.dom, eps=eps, inf=inf, sup=sup, fast=fast) else: raise PolynomialError("can't isolate roots of a multivariate polynomial")