Power simplification

48 views
Skip to first unread message

Paul Royik

unread,
Mar 31, 2015, 10:50:59 AM3/31/15
to sy...@googlegroups.com
Is there any way I can rewrite
x^2y^4 to (xy^2)^2 or  x^3(x+y)^6 to (x(x+y)^2)^3


, i.e. combine base?


Exponents are guaranteed to be integers.


Thank you.

Francesco Bonazzi

unread,
Apr 2, 2015, 5:10:38 AM4/2/15
to sy...@googlegroups.com
In [1]: var('x y', positive=True)
Out[1]: (x, y)

In [2]: ex = x**2 * y**4

In [3]: w = Wild('w')

In [4]: mt = ex.match(w**2)

In [5]: mt
Out[5]:
     2
w: xy
     

In [6]: Pow(mt[w], 2, evaluate=False)
Out[6]:
     
2
  2
xy

Paul Royik

unread,
Apr 2, 2015, 9:16:41 AM4/2/15
to sy...@googlegroups.com
Smart solution. Thank you.

Aaron Meurer

unread,
Apr 2, 2015, 11:50:45 AM4/2/15
to sy...@googlegroups.com
I guess we need a reverse of powdenest (like powcollect or something).

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/f2301ef8-16f6-452e-ba58-c580bd1be0bd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages