# Re: [sage-devel] Re: How to check that something is a real number?

```
Le mardi 20 septembre 2016 04:02:16 UTC+2, Bill Page a écrit :
>
> In keeping with Richard's suggestion, in Sage I think a good
> _algebraic_ definition of 'real' is
>
>     bool(x/2+conjugate(x)/2 == x)
>```
```
why not bool(SR(x).imag_part()==0) ?

>
> So
>
> sage: def RN(x):
> ....:     try:
> ....:         return bool(x/2+conjugate(x)/2 == x)
> ....:     except:
> ....:         return false
>
> which also works whenever conjugate is defined, including
>
> sage: assume(x,'real')
> sage: assume(y,'real')
> sage: RN(sqrt(x^2+y^2))
> True
>
>
>
> On 19 September 2016 at 19:51, rjf <fat...@gmail.com <javascript:>>
> wrote:
> > If arg(x) is 0 and x is a number, then it is a real number.  Maxima
> calls
> > this carg()  for complex arg.
> >
> > Carg will also work for some things that are not of numeric type, but
> > symbolic in some way.
> > .
> >  Like sqrt(x^2+y^2)   is real  if domain=real
> >
> > Good luck
> >
>

--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email