With very kind & generous help of Robert Samal following solution was 
proposed:

bool(x.n() != NaN)

should give out True iff x is a real number. It seems to work:
http://aleph.sagemath.org/?z=eJxLVLBV0DXUNzTSKshU0FYAs4oLi0o0DM0gIgWZcUZAysjUTBNImegbcyUBtSQWJSfnF2sYaXJxFRRl5pUoJOXn52gk6uVpaCoo2ir4JfppIkskIUsAAIR8Hfg%3D

Is this a correct & proper method to recognize real numbers?


On Saturday, April 28, 2012 6:40:55 PM UTC+2, Volker Braun wrote:
>
> The floating point "fields" in Sage (RR or RDF) can represent both 
> infinity and NaN. So you'll have to check separately if this is the case. 
> Note that "x in RR" checks that x can be represented in RR.
>
>
>
> On Saturday, April 28, 2012 7:38:44 AM UTC-4, Duc Trung Ha wrote:
>>
>> Hola,
>>
>> I'm stuck at the problem of determinating whether a given expression is 
>> known to be real number or not.
>>                                                                              
>>                                                                              
>>                 
>>
>> So far, I've been testing this either 
>> with                                                                         
>>                                                        
>>
>> expr.is_real()                                                               
>>                                                                              
>>                 
>>
>> or                                                                           
>>                                                                              
>>                 
>>
>> expr in 
>> RR                                                                           
>>                                                                              
>>         
>>
>> succesfully.
>>
>> Now, if I give Sage this expression of real number:
>> -1/12*pi + 1/12*sqrt(16*pi + pi^2 + 256) + 4/3
>> the following results will occur:
>>
>> http://aleph.sagemath.org/?z=eJxLVLBV0DXUNzTSKshU0FYAs4oLi0o0DM0gIgWZcUZAysjUTBNImegbc3EVFGXmlSgk6mUWxxelJuZoaMKFFDLzFIKCAHCUFik%3D
>>
>> On the other hand, non-real value below:
>> arccos(2)
>> would produce the very same results, though it should give opposite 
>> results for at least 1 test:
>>
>> http://aleph.sagemath.org/?c=a+%3D+arccos%282%29%0A%0Aprint+a.is_real%28%29%0A%0Aprint+a+in+RR
>>
>> Is there any other/standard way to test membership to real numbers?
>>
>> Is this a bug or is it covered somewhere else?
>> Duc Trung Ha
>> Sage Version 4.8, Release Date: 2012-01-20
>> Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz
>> Kubuntu 12.04
>>
>

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to