def test_dup_isolate_all_roots(): f = [4, -1, 2, 5, 0] assert dup_isolate_all_roots(f, ZZ) == \ ([((-1, 0), 1), ((0, 0), 1)], [(((0, -QQ(5,2)), (QQ(5,2), 0)), 1), (((0, 0), (QQ(5,2), QQ(5,2))), 1)]) assert dup_isolate_all_roots(f, ZZ, eps=QQ(1,10)) == \ ([((QQ(-7,8), QQ(-6,7)), 1), ((0, 0), 1)], [(((QQ(35,64), -QQ(35,32)), (QQ(5,8), -QQ(65,64))), 1), (((QQ(35,64), QQ(65,64)), (QQ(5,8), QQ(35,32))), 1)]) raises(NotImplementedError, "dup_isolate_all_roots([1, 1, -2, -2, 1, 1], ZZ)")
def test_dup_isolate_all_roots(): f = [4, -1, 2, 5, 0] assert dup_isolate_all_roots(f, ZZ) == \ ([((-1, 0), 1), ((0, 0), 1)], [(((0, -QQ(5,2)), (QQ(5,2), 0)), 1), (((0, 0), (QQ(5,2), QQ(5,2))), 1)]) assert dup_isolate_all_roots(f, ZZ, eps=QQ(1,10)) == \ ([((QQ(-7,8), QQ(-6,7)), 1), ((0, 0), 1)], [(((QQ(35,64), -QQ(35,32)), (QQ(5,8), -QQ(65,64))), 1), (((QQ(35,64), QQ(65,64)), (QQ(5,8), QQ(35,32))), 1)]) raises(NotImplementedError, lambda: dup_isolate_all_roots([1, 1, -2, -2, 1, 1], ZZ))
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")