Thank you! Sorry for newbie question. /Johan On Tue, Aug 4, 2009 at 12:59 AM, Ondrej Certik <[email protected]> wrote:
> On Mon, Aug 3, 2009 at 4:42 PM, Johan Ekh<[email protected]> wrote: > > Hi all, > > I am new to SymPy. I'm trying to simplify an expression that contains > > "sqrt". > > SymPy refuses to do what I want. I want to simplify the expression f2 > > below into > > x**2/y but I can't get it, see my session below. I use version 0.64 > > on OpenSuSE 11.1 64bit. > > > > Best regards, > > Johan > > > > > > In [91]: x = Symbol('x') > > In [93]: y = Symbol('y') > > In [94]: f = x**4/y**2 > > In [95]: f > > Out[95]: x**4/y**2 > > In [96]: f2 = sqrt(f) > > In [97]: f2 > > Out[97]: (x**4)**(1/2)*(y**(-2))**(1/2) > > In [98]: simplify(f2) > > Out[98]: (x**4)**(1/2)*(y**(-2))**(1/2) > > SymPy assumes that your symbols are complex, so it can't do anything > about it. If you tell it that they are real (or even positive), it can > do more simplifications: > > In [5]: x = Symbol('x', real=True) > > In [6]: y = Symbol('y', real=True) > > In [7]: f = x**4/y**2 > > In [8]: f > Out[8]: > 4 > x > ── > 2 > y > > In [9]: f2 = sqrt(f) > > In [10]: f2 > Out[10]: > 2 > x > ─── > │y│ > > > > Ondrej > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
