Comment #30 on issue 1598 by smichr: New polynomials manipulation module http://code.google.com/p/sympy/issues/detail?id=1598
The functionality for gcdfactor is there, but a simple wrapper for someone who doesn't want to get into Polys is not there. Compare expr = gcdfactor(expr) with if (expr.is_Add or expr.is_Mul): expo, poly = Poly(expr, expand=False).terms_gcd() if not all(i is S.Zero for i in expo): terms = [x**expo[i] for i,x in enumerate(poly.gens)] terms.append(poly.as_basic()) expr = Mul(*terms) That's a lot of overhead for someone that just wants to factor out the gcd from an expression. gcdfactor isn't duplicating terms_gcd, it is just putting a non-Poly wrapper on it. I put it in the simplify module since separatevars should be using gcdfactor (and not pure factor). As for fraction and magic...it's a little underwhelming. You have to do as_numer_denom() to get an expression to have a numer and denom or else fraction doesn't do anything for you...and even then, a simple removal of a gcd is not done. >>> eq = 1/x + 1/x**2 >>> fraction(eq) (1/x + x**(-2), 1) >>> n,d=(1/x**2+1/x).as_numer_denom() >>> fraction(n/d) (x + x**2, x**3) I (and root finders) would really like to see (1 + x, x**2) come back from eq.as_numer_denom(). Whether this slows things down too much, that's an issue to consider. If it is, then having gcdfactor in simplify is a nice tool since before doing as_numer_denom() one can pull out a gcd and run as_numer_denom on the residual and build the result on their own: ### simulated output >> eq = 1/x+1/x**2 >> gcdfactor(eq) 1/x*(1+1/x) >> Mul(*[m.as_numer_denom() for m in make_list(_, Mul)]) #existing >> as_numer_denom() (1+x)/x**2 ### -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups "sympy-issues" group. To post to this group, send email to sympy-iss...@googlegroups.com. To unsubscribe from this group, send email to sympy-issues+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy-issues?hl=en.