(f, *gens, **args)
return sorted(factors, key=default_sort_key)
Returns all factors of a univariate polynomial.

    Examples
    ========

    >>> from sympy.abc import x, y
    >>> from sympy.polys.polyroots import root_factors

    >>> root_factors(x**2 - y, x)
    [x - sqrt(y), x + sqrt(y)]
Returns all factors of a univariate polynomial.
Returns all factors of a univariate polynomial .
def root_factors(f, *gens, **args):
    """
    Returns all factors of a univariate polynomial.

    Examples
    ========

    >>> from sympy.abc import x, y
    >>> from sympy.polys.polyroots import root_factors

    >>> root_factors(x**2 - y, x)
    [x - sqrt(y), x + sqrt(y)]

    """
    args = dict(args)
    filter = args.pop('filter', None)

    F = Poly(f, *gens, **args)

    if not F.is_Poly:
        return [f]

    if F.is_multivariate:
        raise ValueError('multivariate polynomials not supported')

    x = F.gens[0]

    zeros = roots(F, filter=filter)

    if not zeros:
        factors = [F]
    else:
        factors, N = [], 0

        for r, n in zeros.items():
            factors, N = factors + [Poly(x - r, x)]*n, N + n

        if N < F.degree():
            G = reduce(lambda p, q: p*q, factors)
            factors.append(F.quo(G))

    if not isinstance(f, Poly):
        factors = [ f.as_expr() for f in factors ]

    return sorted(factors, key=default_sort_key)
def root_factors ( f , * gens , * * args ) : args = dict ( args ) filter = args . pop ( 'filter' , None ) F = Poly ( f , * gens , * * args ) if not F . is_Poly : return [ f ] if F . is_multivariate : raise ValueError ( 'multivariate polynomials not supported' ) x = F . gens [ 0 ] zeros = roots ( F , filter = filter ) if not zeros : factors = [ F ] else : factors , N = [ ] , 0 for r , n in zeros . items ( ) : factors , N = factors + [ Poly ( x - r , x ) ] * n , N + n if N < F . degree ( ) : G = reduce ( lambda p , q : p * q , factors ) factors . append ( F . quo ( G ) ) if not isinstance ( f , Poly ) : factors = [ f . as_expr ( ) for f in factors ] return sorted ( factors , key = default_sort_key )