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

2016-09-20 Thread Bill Page
Admittedly, the author of this thread did not consider the case in the list of targets but when comparing 'conjugate' to 'imag_part' in Sage I was surprized to see the following results. sage: Q. = QuaternionAlgebra(SR, -1, -1) sage: a,b,c=var('a,b,c') sage: q = x + a*i + b*j + c*k sage: conjugate

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

2016-09-20 Thread Emmanuel Charpentier
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:

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

2016-09-20 Thread Jeroen Demeyer
On 2016-09-19 19:51, Thierry wrote: you should first remove SR(2.3) and 2*pi from your first list That's a problem with the Symbolic Ring. Obviously, it doesn't coerce to a real field (since it contains things like "sin(x)") but these constants *should* coerce. Anyway, I can always special-

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

2016-09-19 Thread Bill Page
In keeping with Richard's suggestion, in Sage I think a good _algebraic_ definition of 'real' is bool(x/2+conjugate(x)/2 == x) So sage: def RN(x): : try: : return bool(x/2+conjugate(x)/2 == x) : except: : return false which also works whenever conjuga

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

2016-09-19 Thread rjf
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 On Monday, September 19, 2016 at 7:37:18

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

2016-09-19 Thread Thierry
Hi, On Mon, Sep 19, 2016 at 06:54:29PM +0200, Jeroen Demeyer wrote: > On 2016-09-19 18:37, Travis Scrimshaw wrote: > >The closest I can get is "foo in RR". This fails for CC(2.3, 0), but I > >consider that to be a real number. > > I would say it's a complex number which happens to have a real val

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

2016-09-19 Thread Jeroen Demeyer
On 2016-09-19 18:37, Travis Scrimshaw wrote: The closest I can get is "foo in RR". This fails for CC(2.3, 0), but I consider that to be a real number. I would say it's a complex number which happens to have a real value. But it is not a real number. It's the difference between *coercion* and

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

2016-09-19 Thread Travis Scrimshaw
The closest I can get is "foo in RR". This fails for CC(2.3, 0), but I consider that to be a real number. Best, Travis On Monday, September 19, 2016 at 9:37:18 AM UTC-5, Jeroen Demeyer wrote: > > Hello, > > is there a simple way to check in Sage that something is a real number > in some form?