Your question is somewhat vague, because anything could be considered
the square of its square root.  Clearly sqrt(x) will give you such a
y, though I think this is not what you want.

I'm assuming that for polynomials, you only want y that is also a
polynomial.  In that case, you should first apply sqf() to it, which
will do a partial factorization useful for getting square powers.
sqf_list() will return a form more useful for modifying the powers.
For example, you can do all(not i[1] % 2 for i in sqf_list(poly)[1])
to determine if poly is a perfect square.  I'll leave the command to
reduce each power by a half and multiply them back together as an
exercise.

For generic expressions, it really depends on how you want to limit
what y can be.  If you have x, is sqrt(x) a suitable y?  If you have
exp(x), is exp(x/2) a suitable y?

Aaron Meurer

On Mon, Apr 2, 2012 at 7:21 AM, Alan Bromborsky <[email protected]> wrote:
> What is the best way of determining if a sympy expression 'x' is the square
> of another expression 'y' that is 'x = y**2=y*y'?  How should one simplify
> 'x' if 'x' is a general symbolic expression, for the best chance of
> determining 'y'? What if 'x' is a polynomial in multiple variables?
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>

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

Reply via email to