ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 29 Jun 2014 15:06:19 +0200.is_real functionhttps://ask.sagemath.org/question/11032/is_real-function/Why does "sqrt(5).is_real()" come up false when it is obviously not? This seems to happen with any square root.Thu, 13 Feb 2014 23:29:11 +0100https://ask.sagemath.org/question/11032/is_real-function/Comment by kcrisman for <p>Why does "sqrt(5).is_real()" come up false when it is obviously not? This seems to happen with any square root.</p>
https://ask.sagemath.org/question/11032/is_real-function/?comment=16259#post-id-16259I 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`.Fri, 14 Feb 2014 13:29:56 +0100https://ask.sagemath.org/question/11032/is_real-function/?comment=16259#post-id-16259Comment by moroplogo for <p>Why does "sqrt(5).is_real()" come up false when it is obviously not? This seems to happen with any square root.</p>
https://ask.sagemath.org/question/11032/is_real-function/?comment=16266#post-id-16266There 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 -> TrueFri, 14 Feb 2014 10:25:40 +0100https://ask.sagemath.org/question/11032/is_real-function/?comment=16266#post-id-16266Comment by moroplogo for <p>Why does "sqrt(5).is_real()" come up false when it is obviously not? This seems to happen with any square root.</p>
https://ask.sagemath.org/question/11032/is_real-function/?comment=16256#post-id-16256"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.Fri, 14 Feb 2014 19:46:18 +0100https://ask.sagemath.org/question/11032/is_real-function/?comment=16256#post-id-16256Answer by vdelecroix for <p>Why does "sqrt(5).is_real()" come up false when it is obviously not? This seems to happen with any square root.</p>
https://ask.sagemath.org/question/11032/is_real-function/?answer=23116#post-id-23116Hi,
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.
VincentSun, 29 Jun 2014 15:06:19 +0200https://ask.sagemath.org/question/11032/is_real-function/?answer=23116#post-id-23116