You are doing the right thing, but AA (and QQbar) are very slow at
testing equality -- and hence also at division since the denominator
must be tested for equality with 0.

In this case since el1.minpoly() and el2.minpoly() are the same, and
the roots in RR are very different:

sage: el1.minpoly()
x^4 - 2238072*x^2 + 44133904
sage: el2.minpoly()
x^4 - 2238072*x^2 + 44133904
sage: el2.minpoly().roots(RR)
[(-1496.01212569203, 1),
 (-4.44069616336440, 1),
 (4.44069616336440, 1),
 (1496.01212569203, 1)]

it is hard to believe that there is not a quicker way of doing the
test.  (It is also relevant that
sage: el1.minpoly().is_irreducible()
True

here, since in general during a computation in AA/QQbar, the
polynomials carried around are not factored.  i think.)  Also note
that

sage: el1.minpoly()(el2) ==0
True
!

John

On 17 September 2014 15:40, Jonas Jermann <jjerma...@gmail.com> wrote:
> Hi
>
> How can I do exact comparison of numbers in AA?
> I noticed that this doesn't work very reliably:
>
> el1 = AA((x^4 - 2238072*x^2 + 44133904).roots()[1][0])
> el2 = (791264*AA(2*cos(pi/8))^2 - 463492).sqrt()
> el1 == el2
>
> ^- This fails for me (resp. never stops)
> [el1-el2 gives "0.?e-15"]
>
>
> Best
>     Jonas
>
> --
> 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 to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to