(f)
return sorted(roots, key=default_sort_key)
Returns a list of roots of a binomial polynomial.
Returns a list of roots of a binomial polynomial.
Returns a list of roots of a binomial polynomial .
def roots_binomial(f):
    """Returns a list of roots of a binomial polynomial."""
    n = f.degree()

    a, b = f.nth(n), f.nth(0)
    alpha = (-cancel(b/a))**Rational(1, n)

    if alpha.is_number:
        alpha = alpha.expand(complex=True)

    roots, I = [], S.ImaginaryUnit

    for k in xrange(n):
        zeta = exp(2*k*S.Pi*I/n).expand(complex=True)
        roots.append((alpha*zeta).expand(power_base=False))

    return sorted(roots, key=default_sort_key)
def roots_binomial ( f ) : n = f . degree ( ) a , b = f . nth ( n ) , f . nth ( 0 ) alpha = ( - cancel ( b / a ) ) ** Rational ( 1 , n ) if alpha . is_number : alpha = alpha . expand ( complex = True ) roots , I = [ ] , S . ImaginaryUnit for k in xrange ( n ) : zeta = exp ( 2 * k * S . Pi * I / n ) . expand ( complex = True ) roots . append ( ( alpha * zeta ) . expand ( power_base = False ) ) return sorted ( roots , key = default_sort_key )