First time here? Check out the FAQ!

Ask Your Question
2

.is_real function

asked 11 years ago

jstroud gravatar image

updated 11 years ago

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.

Preview: (hide)

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

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

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

vdelecroix gravatar image

updated 10 years ago

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

Preview: (hide)
link

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: 11 years ago

Seen: 660 times

Last updated: Jun 29 '14