Ask Your Question

simplify sqrt(x/y^2)*y

asked 2015-09-20 11:03:09 -0500

miguelython gravatar image

updated 2015-09-27 04:44:29 -0500

Hello my problem is with a bigger equation but the problem is bassicly this : sage: var('x','y', domain=real)
sage: assume(x>0)
sage: assume(y>0)
sage: e = sqrt(1/y^2)y
sage: e.simplify_full()
sage: e = sqrt(x/y^2)
sage: e.simplify_full()

Anyone explain me how to get just sqrt(x) and why it doesn't do directly? Thanks

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-09-20 13:29:23 -0500

nbruin gravatar image

I hope there is no way to coerce Sage into returning just x, because your expression is only equal to that for a very limited number of choices for x. Sage (Maxima, really) can be convinced to make branch choices to simplify the expression to sqrt(x), but not via assumptions, apparently. This does work:

sage: var('x,y')
(x, y)
sage: E=sqrt(x/y^2)*y
sage: E.canonicalize_radical()

See the documentation of canonicalize_radical for details.

edit flag offensive delete link more


thank you, I edited

miguelython gravatar imagemiguelython ( 2015-09-27 04:43:56 -0500 )edit

answered 2015-09-20 14:52:52 -0500

miguelython gravatar image

Yes, I mean just "x" part so sqrt(x)... sorry for not to be clear. Thanks. It works, but I wonder why canonicalize_radical isn't part of simplify_full?

edit flag offensive delete link more


This is because

sage: x = var('x', domain='real')
sage: assume(x<0)
sage: sqrt(x^2).canonicalize_radical()

and I guess you don't want this (note the x<0 assumption).

eric_g gravatar imageeric_g ( 2015-09-20 16:28:18 -0500 )edit

Miguel, note that sqrt(x^2) != x for x<0.

rws gravatar imagerws ( 2015-09-21 02:50:22 -0500 )edit

I don't want this beacause is false. I want sqrt(x^2)=abs(x) or in case ofassume(x>0) or assume(x<0) : sqrt(x^2)=x or sqrt(x^2)=-x resp

miguelython gravatar imagemiguelython ( 2015-09-27 05:17:05 -0500 )edit

I mean if I had the time and knowleage, I change it in the source code. Nevertheless, I'm thankful to all community of sagemath

miguelython gravatar imagemiguelython ( 2015-09-27 05:24:09 -0500 )edit

A fix should be possible with pynac-0.4.x (pynac is part of Sage); pynac git master already does sqrt(x^2) --> x for x>0 as side effect of other changes.

rws gravatar imagerws ( 2015-09-27 09:39:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-09-20 11:03:09 -0500

Seen: 324 times

Last updated: Sep 27 '15