If sympy automatically pulls apart square roots, then you won't find a function that pulls them together.
On the other hand, you should note that sqrt(x) is equivalent to x**Rational(1,2), not x**(1/2), which is just x**(0.5). Using 1/2 does work at least in your brute force method, if you are willing to deal with 0.5: >>> print (wn.args[0].args[0]*wn.args[1].args[0])**(1/2) ((k1 + k2 + k3)/m)**0.5 I couldn't find any mention of this in the issues, but I am assuming that sympy does this on purpose. Personally, I think that, along with combining exponentials, sympy should not expand square roots automatically. Also, as has been pointed out elsewhere on this list, you can end up getting non-principle roots by doing this, e.g., 1 == sqrt(1) == sqrt(-1*-1) == sqrt(-1)*sqrt(-1) == I*I == -1. Aaron Meurer On Jun 1, 2009, at 6:36 PM, William Purcell wrote: > > I am trying to combine an expression containing similar exponents that > are multiplied to each other ... > > > In [20]: wn > Out[20]: (1/m)**(1/2)*(k1 + k2 + k3)**(1/2) > > In [21]: together(wn) > Out[21]: (1/m)**(1/2)*(k1 + k2 + k3)**(1/2) > > but I would like something like > > In [21]: together(wn) > Out[21]: ((k1+k2+k3)/m)**(1/2) > > I can't even seem to convince sympy to do what I want in a brute > force way > > In [23]: sqrt(wn.args[0].args[0]*wn.args[1].args[0]) > Out[23]: (1/m)**(1/2)*(k1 + k2 + k3)**(1/2) > > Any advice getting this done. > > Thanks, > Bill > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---