Ask Your Question

Sage seems to be improperly computing an infinite sum, and giving an incorrect answer

asked 2016-11-02 18:23:14 +0200

rtc gravatar image

updated 2023-01-10 00:01:11 +0200

tmonteil gravatar image

Reference this question:

Here is the evaluation of an infinite sum in sage:

f(n) = (-1)^(n+1)/(3*n+6*(-1)^n)

1/3*log(2) - 7/9

Evaluating the same sum in Mathematica:

f[n_] := (-1)^(n + 1)/(3*n + 6*(-1)^n)
Sum[f[2*n] + f[2*n + 1], {n, 0, Infinity}]

1/6 (-2 + Log[4])

Sage seems to be giving an incorrect solution. Am I missing something?

edit retag flag offensive close merge delete


Thanks for reporting this bug!

slelievre gravatar imageslelievre ( 2016-11-03 04:33:40 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-11-02 19:59:51 +0200

I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of 1/((n+1)*(2n-1)), and that's easier to type:

sage: sum(1/((n+1)*(2*n-1)), n, 0, 1000).n()
sage: sum(1/((n+1)*(2*n-1)), n, 0, 10000).n()
sage: sum(1/((n+1)*(2*n-1)), n, 0, 100000).n()  # seems to be converging
sage: sum(1/((n+1)*(2*n-1)), n, 0, oo).n()      # but not to this number

sage: sum(1/((n+1)*(2*n-1)), n, 0, oo)
2/3*log(2) - 14/9
sage: sum(1/((n+1)*(2*n-1)), n, 0, oo).n() - sum(1/((n+1)*(2*n-1)), n, 0, 10000).n()

The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.

edit flag offensive delete link more


I've opened though I don't have time to report upstream now (meeting in a few minutes)

kcrisman gravatar imagekcrisman ( 2016-11-02 21:07:26 +0200 )edit

@krisman thanks!

rtc gravatar imagertc ( 2016-11-02 21:29:13 +0200 )edit

It turns out that this is a bug in Maxima, which is what Sage uses for this kind of symbolic manipulation. The Maxima bug is being tracked at

John Palmieri gravatar imageJohn Palmieri ( 2016-11-03 02:00:04 +0200 )edit

If you use simplify over the expression for the sum you get some kind of "double fraction" like 1/2/... what is a bit strange. See here. Maybe this is unrelated to the problem and is just some kind of non very standard notation.

Masacroso gravatar imageMasacroso ( 2016-11-03 05:11:35 +0200 )edit

That term is just (1/2) multiplied by 1/(n+1).

John Palmieri gravatar imageJohn Palmieri ( 2016-11-03 15:24:04 +0200 )edit

answered 2017-05-24 15:19:58 +0200

tmonteil gravatar image

This is now fixed, so i am retagging this question from confirmed_bug to solved_bug:

sage: f(n) = (-1)^(n+1)/(3*n+6*(-1)^n)
sage: sum(f(2*n)+f(2*n+1),n,0,oo)
1/3*log(2) - 1/3

Thanks to all for making this happen !

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: 2016-11-02 18:23:14 +0200

Seen: 979 times

Last updated: May 24 '17