On 8 November 2016 at 11:28, Thierry Dumont <tdum...@math.univ-lyon1.fr> wrote:
> Le 08/11/2016 à 11:05, Vincent Delecroix a écrit :
>> On 8 November 2016 at 10:17, Thierry Dumont <tdum...@math.univ-lyon1.fr> 
>> wrote:
>>> Le 08/11/2016 à 08:43, Vincent Delecroix a écrit :
>>>> Concerning representation of algebraic numbers, it is printed as an
>>>> exact rational if and only if it is stored as an exact rational. It
>>>> will be if the method exactify has been called on the underlying
>>>> representation of the number. Here is a simple example that shows the
>>>> difference
>>>>
>>>
>>> Ha, yes...
>>>
>>> But I am not sure to understand.
>>>
>>> sage: y=QQbar(cos(pi/18))
>>> sage: y.radical_expression()
>>> 1/4*(4*(1/128*I*sqrt(3) + 1/128)^(1/3) + 1)/(1/128*I*sqrt(3) + 1/128)^(1/6)
>>>
>>> ok! good!
>>>
>>> sage: y
>>> 0.9848077530122081? + 0.?e-18*I
>>>
>>> ok.
>>> sage: y.imag()
>>> 0.?e-18
>>> sage: y.imag() == 0
>>> True
>>> I accept this as 0 is "in" 0.?e-18
>>>
>>> Now:
>>>
>>> sage: y.exactify()
>>> sage: y
>>> 0.9848077530122081? + 0.?e-18*I
>>>
>>> raaahhh ! grrr !
>>
>> This is *not* a rational!!
>
> sure...
>
>>We might want to special case the
>> representation of real numbers of QQbar. I opened
>> https://trac.sagemath.org/ticket/21838 for that purpose.
>>
>> Vincent
>>
> In my code, all values are real in QQbar

In that case you should use AA ( = real algebraic field) instead of QQbar
{{{
sage: AA(cos(pi/18))
0.9848077530122081?
}}}

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to