Ask Your Question
0

what happened to square_root() for rationals?

asked 12 years ago

anonymous user

Anonymous

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 12 years ago

fidbc gravatar image

updated 12 years ago

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!

Preview: (hide)
link

Comments

No I am sure they are different in their behavior.

sopsku gravatar imagesopsku ( 12 years ago )

Or are you thinking of `sqrt_approx` - deprecated since http://trac.sagemath.org/sage_trac/ticket/4611 ?

kcrisman gravatar imagekcrisman ( 12 years ago )
0

answered 12 years ago

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.

Preview: (hide)
link

Comments

2

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

fidbc gravatar imagefidbc ( 12 years ago )

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 ( 12 years ago )

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 309 times

Last updated: Feb 13 '13