Ask Your Question

Bug in series evaluated at 0

asked 2022-03-05 11:14:33 +0200

Roland765 gravatar image

updated 2023-01-09 23:59:56 +0200

tmonteil gravatar image


Here is a simple example of the problem I have found in sagemath:

var('x n')
print(sum(x^n/factorial(n), n, 0, Infinity))
x = 0
print(sum(x^n/factorial(n), n, 0, Infinity))

The first output is e^x (as expected), and the second output is 0, which I think should be 1, because $0^0=1$. Since the general formula works for every nonzero x, and it also gives a result for x=0, I feel like this could be quite misleading in more complicated examples, where the result is not so obvious. Or try this:

x = 0
print(sum(x^n, n, 0, Infinity))
print(sum(x^n, n, -1, Infinity))

Both outputs are 0, even though the first should be 1, and the second should be infinity/undefined. The issue seems to be about powers of 0 in the sum. Note that in the case of finite sums, both sum(0^n, n, 0, 5) and sum(0^n, n, -1, 5) produce errors, however sum([0^n for n in range(0,5)]) outputs 1. This is probably related to

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-03-05 15:44:45 +0200

Emmanuel Charpentier gravatar image


sage: sum(x^j/factorial(j),j,0,oo)
sage: sum(x^j/factorial(j),j,0,oo).subs(x==0)
sage: sum(x^j/factorial(j),j,0,oo).limit(x=0)

but :

sage: sum(0^j/factorial(j),j,0,oo)

is indeed a bug, bound to Trac#22027, as you pointed out, which I have updated.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-03-05 11:14:33 +0200

Seen: 117 times

Last updated: Mar 05 '22