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

Here is the evaluation of an infinite sum in sage:

var('n')
f(n) = (-1)^(n+1)/(3*n+6*(-1)^n)
sum(f(2*n)+f(2*n+1),n,0,oo)

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)


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

edit retag close merge delete

Sort by » oldest newest most voted 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()
-0.205068171626375
sage: sum(1/((n+1)*(2*n-1)), n, 0, 10000).n()
-0.204618542543703
sage: sum(1/((n+1)*(2*n-1)), n, 0, 100000).n()  # seems to be converging
-0.204573546255870
sage: sum(1/((n+1)*(2*n-1)), n, 0, oo).n()      # but not to this number
-1.09345743518226

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()
-0.888838892638556


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

more

I've opened https://trac.sagemath.org/ticket/21801 though I don't have time to report upstream now (meeting in a few minutes)

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 https://sourceforge.net/p/maxima/bugs....

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.

2

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 !

more