Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If p is a simple polynomial with variable x, then sometimes the following (too) simple function can work

def rad_factor(p):
    s=solve(p,x,multiplicities=True)
    z=zip(map(lambda x:x.rhs(),s[0]),s[1])
    return p.leading_coeff(x)*prod([(x-y[0])^y[1] for y in z])

If p is a simple polynomial with variable x, then sometimes the following (too) simple function can work

def rad_factor(p):
    s=solve(p,x,multiplicities=True)
    z=zip(map(lambda x:x.rhs(),s[0]),s[1])
    return p.leading_coeff(x)*prod([(x-y[0])^y[1] for y in z])

Or using the suggestion by John Palmieri

def rad_factor(p):
    return p.leading_coeff(x)*(prod((x-_[0])^_[1] for _ in p.roots()))