Ask Your Question
2

.is_real function

asked 2014-02-13 16:29:11 -0500

jstroud gravatar image

updated 2014-02-16 11:35:38 -0500

tmonteil gravatar image

Why does "sqrt(5).is_real()" come up false when it is obviously not? This seems to happen with any square root.

edit retag flag offensive close merge delete

Comments

There are many problems with this function. - sqrt(5).real_part() -> sqrt(5) - sqrt(5).imag_part() ->0 - sqrt(25).is_real() -> AttributeError: 'sage.rings.integer.Integer' object has no attribute 'is_real' - SR(sqrt(25)).is_real() -> True - SR(sqrt(5)).is_real() -> False - CC(sqrt(5)).is_real -> True

moroplogo gravatar imagemoroplogo ( 2014-02-14 03:25:40 -0500 )edit

I think this is because `sqrt` gives a symbolic thing, which Sage would have to exert possibly significant computational effort to decide whether it is real (think of showing whether an arbitrary expression is zero) and so answers `False` since it can't prove `True`.

kcrisman gravatar imagekcrisman ( 2014-02-14 06:29:56 -0500 )edit
1

"sqrt gives a symbolic thing, ..." perhaps , but Sage knows that sqrt(5).imag_part() is 0 then it isn't so difficult to answer True at this question. But I have only notions of programming.

moroplogo gravatar imagemoroplogo ( 2014-02-14 12:46:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-06-29 08:06:19 -0500

updated 2014-06-29 09:55:33 -0500

Hi,

Never believe the symbolic ring as it can answer False when the result is True (hopefully a True is real True). To get the answer to your question, you would better do:

sage: QQbar(5).sqrt() in AA
True

Note: QQbar is the set of algebraic number and AA is the set of real algebraic numbers.

Vincent

edit flag offensive delete link more

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: 2014-02-13 16:29:11 -0500

Seen: 173 times

Last updated: Jun 29 '14