Ask Your Question
2

.is_real function

asked 2014-02-13 23:29:11 +0100

jstroud gravatar image

updated 2014-02-16 18:35:38 +0100

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 10:25:40 +0100 )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 13:29:56 +0100 )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 19:46:18 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-06-29 15:06:19 +0100

vdelecroix gravatar image

updated 2014-06-29 16:55:33 +0100

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 23:29:11 +0100

Seen: 625 times

Last updated: Jun 29 '14