Ask Your Question
0

Bug in series evaluated at 0

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

Roland765 gravatar image

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

tmonteil gravatar image

Hello!

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 trac.sagemath.org/ticket/22027.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

Emmanuel Charpentier gravatar image

FWIW :

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

but :

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

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

Stats

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

Seen: 181 times

Last updated: Mar 05 '22