Multiple comparisons between AA and Rational yeild different answers

36 views
Skip to first unread message

Pat Hooper

unread,
Feb 18, 2020, 9:52:59 PM2/18/20
to sage-devel
Hi all,

I've discovered a bizarre bug in repeatedly comparing a rational with an element of AA:

sage: left_side = AA(2**(1/2) - 2**(1/3))
sage
: right_side = 808620184/5240825825
sage
: left_side < right_side
True
sage
: left_side < right_side
False

The fraction in right_side was obtained via:
continued_fraction(left_side).convergent(15)

One can see because the contined fraction convergents alternate from smaller than to larger than the number they are approximating, that the correct answer is True. There seems to be something rather special about this fraction as demonstrated below:

sage: for n in range(30):
....:     print("{}: {}".format(n, left_side < continued_fraction(left_side).convergent(n)))
....:    
0: False
1: True
2: False
3: True
4: False
5: True
6: False
7: True
8: False
9: True
10: False
11: True
12: False
13: True
14: False
15: False
16: False
17: True
18: False
19: True
20: False
21: True
22: False
23: True
24: False
25: True
26: False
27: True
28: False
29: True

The comparison with the convergent 15 is the only one it gets wrong! Bizarre...

I first noticed the issue in stable version 8.9, but it seems to still be present in the development branch.

Best regards,
Pat Hooper


Vincent Delecroix

unread,
Feb 19, 2020, 3:59:13 AM2/19/20
to sage-...@googlegroups.com
Dear Pat, dear all,

I confirm the bug on 9.1.beta4. I opened

https://trac.sagemath.org/ticket/29220

Vincent

Vincent Delecroix

unread,
Feb 19, 2020, 8:41:10 AM2/19/20
to sage-...@googlegroups.com
That was a subtle one... needs review :-)
Reply all
Reply to author
Forward
0 new messages