On 04/30/2013 12:46 PM, Chris Smith wrote:
def product_bases(w):
    nc = w.args_cnc()[1]
return len(nc) == 2 or len(nc) == 1 and nc[0].is_Pow and nc[0].exp == 2

but could you have b1**2*b1**2 -> b1**4 in which case the test above would be nc[0].exp.is_Integer and sqrt(nc[0].exp).is_Integer might be better? Could you have (b1**(x*Rational(1, 3)))**2?
--
You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


There is a problem with your method (not with product bases) -
consider (1+5*ex+2*ey)*(ex+2*ex) = [15*ex**2 + 6*ey*ex]

Then in -

(15*ex**2 + 6*ey*ex).xreplace(Transform(lambda k: m[k] if k in m else m.setdefault(k, ok(k)), lambda w: product_bases(w)))

k = [15*ex*2, 6*ey*ex]

so that the new keys in m would be 15*ex*2 and 6*ey*ex and not ex*2 and ey*ex so that the amended dictionary would be useless for replacing ex**2 and ey*ex in 7*ex**2+13*ey*ex. Any suggestions?

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to