ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 27 Sep 2015 16:39:58 +0200simplify sqrt(x/y^2)*yhttps://ask.sagemath.org/question/29514/simplify-sqrtxy2y/ Hello my problem is with a bigger equation but the problem is bassicly this :
sage: var('x','y', domain=real) <br/>
sage: assume(x>0)<br/>
sage: assume(y>0)<br/>
sage: e = sqrt(1/y^2)*y<br/>
sage: e.simplify_full()<br/>
1<br/>
sage: e = sqrt(x/y^2)*y<br/>
sage: e.simplify_full()<br/>
y*sqrt(x/y^2)<br/>
Anyone explain me how to get just sqrt(x) and why it doesn't do directly? ThanksSun, 20 Sep 2015 18:03:09 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/Answer by miguelython for <p>Hello my problem is with a bigger equation but the problem is bassicly this :
sage: var('x','y', domain=real) <br/>
sage: assume(x>0)<br/>
sage: assume(y>0)<br/>
sage: e = sqrt(1/y^2)<em>y<br/>
sage: e.simplify_full()<br/>
1<br/>
sage: e = sqrt(x/y^2)</em>y<br/>
sage: e.simplify_full()<br/>
y*sqrt(x/y^2)<br/></p>
<p>Anyone explain me how to get just sqrt(x) and why it doesn't do directly? Thanks</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?answer=29516#post-id-29516Yes, 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?Sun, 20 Sep 2015 21:52:52 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?answer=29516#post-id-29516Comment by eric_g for <p>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?</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29517#post-id-29517This is because
sage: x = var('x', domain='real')
sage: assume(x<0)
sage: sqrt(x^2).canonicalize_radical()
x
and I guess you don't want this (note the x<0 assumption).Sun, 20 Sep 2015 23:28:18 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29517#post-id-29517Comment by rws for <p>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?</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29520#post-id-29520Miguel, note that sqrt(x^2) != x for x<0.Mon, 21 Sep 2015 09:50:22 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29520#post-id-29520Comment by miguelython for <p>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?</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29616#post-id-29616I mean if I had the time and knowleage, I change it in the source code. Nevertheless, I'm thankful to all community of sagemathSun, 27 Sep 2015 12:24:09 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29616#post-id-29616Comment by miguelython for <p>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?</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29615#post-id-29615I 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 respSun, 27 Sep 2015 12:17:05 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29615#post-id-29615Comment by rws for <p>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?</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29617#post-id-29617A 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.Sun, 27 Sep 2015 16:39:58 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29617#post-id-29617Answer by nbruin for <p>Hello my problem is with a bigger equation but the problem is bassicly this :
sage: var('x','y', domain=real) <br/>
sage: assume(x>0)<br/>
sage: assume(y>0)<br/>
sage: e = sqrt(1/y^2)<em>y<br/>
sage: e.simplify_full()<br/>
1<br/>
sage: e = sqrt(x/y^2)</em>y<br/>
sage: e.simplify_full()<br/>
y*sqrt(x/y^2)<br/></p>
<p>Anyone explain me how to get just sqrt(x) and why it doesn't do directly? Thanks</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?answer=29515#post-id-29515 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()
sqrt(x)
See the documentation of `canonicalize_radical` for details.Sun, 20 Sep 2015 20:29:23 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?answer=29515#post-id-29515Comment by miguelython for <p>I hope there is no way to coerce Sage into returning just <code>x</code>, because your expression is only equal to that for a very limited number of choices for <code>x</code>. Sage (Maxima, really) can be convinced to make branch choices to simplify the expression to <code>sqrt(x)</code>, but not via assumptions, apparently. This does work:</p>
<pre><code>sage: var('x,y')
(x, y)
sage: E=sqrt(x/y^2)*y
sage: E.canonicalize_radical()
sqrt(x)
</code></pre>
<p>See the documentation of <code>canonicalize_radical</code> for details.</p>
https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29614#post-id-29614thank you, I editedSun, 27 Sep 2015 11:43:56 +0200https://ask.sagemath.org/question/29514/simplify-sqrtxy2y/?comment=29614#post-id-29614