ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 13 Feb 2013 03:24:12 -0600what happened to square_root() for rationals?https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/I have some old code that takes the square_root() of rational numbers. This function seems to be long gone. How do I replace its functionality?Mon, 11 Feb 2013 08:21:08 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/Answer by sopsku for <p>I have some old code that takes the square_root() of rational numbers. This function seems to be long gone. How do I replace its functionality?</p>
https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?answer=14541#post-id-14541I found online an old (ver 1.4.1) sage manual that says that square_root() for rationals: "Return the positive rational square root of self, or raises a ValueError if self is not a perfect square."
So with this information is easy enough to code up a simple function to replace it.
I do wonder why it went away and or if it has been renamed or replaced somehow. Tue, 12 Feb 2013 06:41:53 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?answer=14541#post-id-14541Comment by fidbc for <p>I found online an old (ver 1.4.1) sage manual that says that square_root() for rationals: "Return the positive rational square root of self, or raises a ValueError if self is not a perfect square."</p>
<p>So with this information is easy enough to code up a simple function to replace it.</p>
<p>I do wonder why it went away and or if it has been renamed or replaced somehow. </p>
https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18244#post-id-18244In this case, maybe `x.sqrt(extend=False)` would do the job.Tue, 12 Feb 2013 07:02:31 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18244#post-id-18244Comment by kcrisman for <p>I found online an old (ver 1.4.1) sage manual that says that square_root() for rationals: "Return the positive rational square root of self, or raises a ValueError if self is not a perfect square."</p>
<p>So with this information is easy enough to code up a simple function to replace it.</p>
<p>I do wonder why it went away and or if it has been renamed or replaced somehow. </p>
https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18240#post-id-18240Wow, 1.4.1 - that is REALLY old. This functionality has probably been gone for quite a few years, long before any deprecation policy. I think that fidelbc should update his answer with that so you can accept it.Wed, 13 Feb 2013 03:24:12 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18240#post-id-18240Answer by fidbc for <p>I have some old code that takes the square_root() of rational numbers. This function seems to be long gone. How do I replace its functionality?</p>
https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?answer=14538#post-id-14538For a rational number `x`, it seems that `x.sqrt(extend=False)` emulates `square_root()`.
Update: Changed `sqrt()` to `x.sqrt(extend=False)`.
Thanks to @kcrisman and @sopsku for their comments!Mon, 11 Feb 2013 08:29:46 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?answer=14538#post-id-14538Comment by kcrisman for <p>For a rational number <code>x</code>, it seems that <code>x.sqrt(extend=False)</code> emulates <code>square_root()</code>.</p>
<p>Update: Changed <code>sqrt()</code> to <code>x.sqrt(extend=False)</code>.</p>
<p>Thanks to <a href="/users/41/kcrisman/">@kcrisman</a> and <a href="/users/1249/sopsku/">@sopsku</a> for their comments!</p>
https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18248#post-id-18248Or are you thinking of `sqrt_approx` - deprecated since http://trac.sagemath.org/sage_trac/ticket/4611 ?Mon, 11 Feb 2013 13:46:05 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18248#post-id-18248Comment by sopsku for <p>For a rational number <code>x</code>, it seems that <code>x.sqrt(extend=False)</code> emulates <code>square_root()</code>.</p>
<p>Update: Changed <code>sqrt()</code> to <code>x.sqrt(extend=False)</code>.</p>
<p>Thanks to <a href="/users/41/kcrisman/">@kcrisman</a> and <a href="/users/1249/sopsku/">@sopsku</a> for their comments!</p>
https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18250#post-id-18250No I am sure they are different in their behavior.Mon, 11 Feb 2013 08:41:50 -0600https://ask.sagemath.org/question/9798/what-happened-to-square_root-for-rationals/?comment=18250#post-id-18250