Ask Your Question

what happened to square_root() for rationals?

asked 2013-02-11 15:21:08 +0100

anonymous user


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?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-11 15:29:46 +0100

fidbc gravatar image

updated 2013-02-13 10:49:10 +0100

For 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!

edit flag offensive delete link more


No I am sure they are different in their behavior.

sopsku gravatar imagesopsku ( 2013-02-11 15:41:50 +0100 )edit

Or are you thinking of `sqrt_approx` - deprecated since ?

kcrisman gravatar imagekcrisman ( 2013-02-11 20:46:05 +0100 )edit

answered 2013-02-12 13:41:53 +0100

sopsku gravatar image

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."

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.

edit flag offensive delete link more



In this case, maybe `x.sqrt(extend=False)` would do the job.

fidbc gravatar imagefidbc ( 2013-02-12 14:02:31 +0100 )edit

Wow, 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.

kcrisman gravatar imagekcrisman ( 2013-02-13 10:24:12 +0100 )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


Asked: 2013-02-11 15:21:08 +0100

Seen: 233 times

Last updated: Feb 13 '13