series Bug

5 views
Skip to first unread message

Clemens Heuberger

unread,
Feb 9, 2011, 2:26:03 AM2/9/11
to sage-support
A month ago, I encountered a bug while using series. I used the
"Report a problem" link in the sage notebook to report it and never
got a reply. I couldn't find anything in trac either, so in order to
be sure that the problem is not lost, I repost it here once again. My
apologies if this turns out to be a duplicate ...

So:

var('q')
f=(q^13362120470/((q - 1)*(q^5 - 1)*(q^21 - 1)*(q^85 - 1)*(q^341 -
1)*(q^1365 - 1)*(q^5461 - 1)*(q^21845 - 1)*(q^87381 - 1)*(q^349525 -
1)*(q^1398101 - 1)*(q^5592405 - 1)*(q^22369621 - 1)*(q^89478485 -
1)*(q^357913941 - 1)*(q^1431655765 - 1)*(q^5726623061 - 1)) +
1)/(q^7635497409/((q - 1)*(q^5 - 1)*(q^21 - 1)*(q^85 - 1)*(q^341 -
1)*(q^1365 - 1)*(q^5461 - 1)*(q^21845 - 1)*(q^87381 - 1)*(q^349525 -
1)*(q^1398101 - 1)*(q^5592405 - 1)*(q^22369621 - 1)*(q^89478485 -
1)*(q^357913941 - 1)*(q^1431655765 - 1)*(q^5726623061 - 1)) + 1)
print f.series(q==0,2)
print f.subs(q=0)

f.series(q==0,2) gives Order(q^2). However, f.subs(q=0) gives 1. These
two results contradict each other. In fact, the series result is
false, whereas the subs result is correct.

Sorry for the large example, but smaller examples seem to work.

System information: I am using
ftp://ftp.sun.ac.za/pub/mirrors/www.sagemath.org/linux/64bit/sage-4.6.1-linux-64bit-ubuntu_8.04.4_lts-x86_64-Linux.tar.gz
on debian lenny.

regards,

Clemens Heuberger

D. S. McNeil

unread,
Feb 9, 2011, 3:08:19 AM2/9/11
to sage-s...@googlegroups.com
> Sorry for the large example, but smaller examples seem to work.

After some reductions, I think we can find a slightly simpler failure,
of a somewhat suspicious size (4.6.1, OS X 10.6):

q = var('q')
for i in [1..33]:
ix = 2**i
f=(q+1)/(q^(ix) + 1)
res = (f.series(q==0,2), f.subs(q=0), f.taylor(q, 0, 2))
print i, ix, res

1 2 (1 + 1*q + Order(q^2), 1, -q^2 + q + 1)
2 4 (1 + 1*q + Order(q^2), 1, q + 1)
3 8 (1 + 1*q + Order(q^2), 1, q + 1)
4 16 (1 + 1*q + Order(q^2), 1, q + 1)
[...]
28 268435456 (1 + 1*q + Order(q^2), 1, q + 1)
29 536870912 (1 + 1*q + Order(q^2), 1, q + 1)
30 1073741824 (1 + 1*q + Order(q^2), 1, q + 1)
31 2147483648 (Order(q^(-2147483646)), 1, q + 1)
32 4294967296 (1 + 1*q + Order(q^2), 1, q + 1)
33 8589934592 (1 + 1*q + Order(q^2), 1, q + 1)

The case with q^(3^i) is even funnier:

18 387420489 (1 + 1*q + Order(q^2), 1, q + 1)
19 1162261467 (1 + 1*q + Order(q^2), 1, q + 1)
20 3486784401 (Order(q^2), 1, q + 1)
21 10460353203 (1 + 1*q + Order(q^2), 1, q + 1)
22 31381059609 (1 + 1*q + Order(q^2), 1, q + 1)
23 94143178827 (Order(q^2), 1, q + 1)
24 282429536481 (Order(q^2), 1, q + 1)
25 847288609443 (1 + 1*q + Order(q^2), 1, q + 1)
26 2541865828329 (Order(q^2), 1, q + 1)
27 7625597484987 (1 + 1*q + Order(q^2), 1, q + 1)
28 22876792454961 (1 + 1*q + Order(q^2), 1, q + 1)
29 68630377364883 (1 + 1*q + Order(q^2), 1, q + 1)
30 205891132094649 (Order(q^2), 1, q + 1)
31 617673396283947 (1 + 1*q + Order(q^2), 1, q + 1)
32 1853020188851841 (Order(q^2), 1, q + 1)
33 5559060566555523 (Order(q^2), 1, q + 1)

Obvious suspect is overflow due to use of a C int somewhere along the
path (suddenly negative around 2^31; works for small numbers; is
better-behaved for powers of 2; can generate an actual OverflowError
at large enough exponents.)


Doug

--
Department of Earth Sciences
University of Hong Kong

Reply all
Reply to author
Forward
0 new messages