(alg, eps=None, fast=False)
return (a, b)
Give a rational isolating interval for an algebraic number.
Give a rational isolating interval for an algebraic number.
Give a rational isolating interval for an algebraic number .
def isolate(alg, eps=None, fast=False):
    """Give a rational isolating interval for an algebraic number. """
    alg = sympify(alg)

    if alg.is_Rational:
        return (alg, alg)
    elif not ask(Q.real(alg)):
        raise NotImplementedError(
            "complex algebraic numbers are not supported")

    func = lambdify((), alg, modules="mpmath", printer=IntervalPrinter())

    poly = minpoly(alg, polys=True)
    intervals = poly.intervals(sqf=True)

    dps, done = mp.dps, False

    try:
        while not done:
            alg = func()

            for a, b in intervals:
                if a <= alg.a and alg.b <= b:
                    done = True
                    break
            else:
                mp.dps *= 2
    finally:
        mp.dps = dps

    if eps is not None:
        a, b = poly.refine_root(a, b, eps=eps, fast=fast)

    return (a, b)
def isolate ( alg , eps = None , fast = False ) : alg = sympify ( alg ) if alg . is_Rational : return ( alg , alg ) elif not ask ( Q . real ( alg ) ) : raise NotImplementedError ( "complex algebraic numbers are not supported" ) func = lambdify ( ( ) , alg , modules = "mpmath" , printer = IntervalPrinter ( ) ) poly = minpoly ( alg , polys = True ) intervals = poly . intervals ( sqf = True ) dps , done = mp . dps , False try : while not done : alg = func ( ) for a , b in intervals : if a <= alg . a and alg . b <= b : done = True break else : mp . dps *= 2 finally : mp . dps = dps if eps is not None : a , b = poly . refine_root ( a , b , eps = eps , fast = fast ) return ( a , b )