Ask Your Question

what happened to square_root() for rationals?

asked 2013-02-11 08:21:08 -0600

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 08:29:46 -0600

fidbc gravatar image

updated 2013-02-13 03:49:10 -0600

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 08:41:50 -0600 )edit

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

kcrisman gravatar imagekcrisman ( 2013-02-11 13:46:05 -0600 )edit

answered 2013-02-12 06:41:53 -0600

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 07:02:31 -0600 )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 03:24:12 -0600 )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 08:21:08 -0600

Seen: 64 times

Last updated: Feb 13 '13