(factors, x, v, dom=QQ, prec=200, bound=5)
Return a factor having root ``v``
    It is assumed that one of the factors has root ``v``.
Return a factor having root ``v``
    It is assumed that one of the factors has root ``v``.
Return a factor having root v It is assumed that one of the factors has root v .
def _choose_factor(factors, x, v, dom=QQ, prec=200, bound=5):
    """
    Return a factor having root ``v``
    It is assumed that one of the factors has root ``v``.
    """
    if isinstance(factors[0], tuple):
        factors = [f[0] for f in factors]
    if len(factors) == 1:
        return factors[0]

    points = {x:v}
    symbols = dom.symbols if hasattr(dom, 'symbols') else []
    t = QQ(1, 10)

    for n in range(bound**len(symbols)):
        prec1 = 10
        n_temp = n
        for s in symbols:
            points[s] = n_temp % bound
            n_temp = n_temp // bound

        while True:
            candidates = []
            eps = t**(prec1 // 2)
            for f in factors:
                if abs(f.as_expr().evalf(prec1, points)) < eps:
                    candidates.append(f)
            if candidates:
                factors = candidates
            if len(factors) == 1:
                return factors[0]
            if prec1 > prec:
                break
            prec1 *= 2

    raise NotImplementedError("multiple candidates for the minimal polynomial of %s" % v)
def _choose_factor ( factors , x , v , dom = QQ , prec = 200 , bound = 5 ) : if isinstance ( factors [ 0 ] , tuple ) : factors = [ f [ 0 ] for f in factors ] if len ( factors ) == 1 : return factors [ 0 ] points = { x : v } symbols = dom . symbols if hasattr ( dom , 'symbols' ) else [ ] t = QQ ( 1 , 10 ) for n in range ( bound ** len ( symbols ) ) : prec1 = 10 n_temp = n for s in symbols : points [ s ] = n_temp % bound n_temp = n_temp // bound while True : candidates = [ ] eps = t ** ( prec1 // 2 ) for f in factors : if abs ( f . as_expr ( ) . evalf ( prec1 , points ) ) < eps : candidates . append ( f ) if candidates : factors = candidates if len ( factors ) == 1 : return factors [ 0 ] if prec1 > prec : break prec1 *= 2 raise NotImplementedError ( "multiple candidates for the minimal polynomial of %s" % v )