Ask Your Question
3

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

asked 2016-11-02 12:23:14 -0500

rtc gravatar image

updated 2017-05-24 08:18:15 -0500

tmonteil gravatar image

Reference this question: https://ask.sagemath.org/question/353...

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[4])

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

edit retag flag offensive close merge delete

Comments

Thanks for reporting this bug!

slelievre gravatar imageslelievre ( 2016-11-02 22:33:40 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2016-11-02 13:59:51 -0500

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.

edit flag offensive delete link more

Comments

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

kcrisman gravatar imagekcrisman ( 2016-11-02 15:07:26 -0500 )edit

@krisman thanks!

rtc gravatar imagertc ( 2016-11-02 15:29:13 -0500 )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 https://sourceforge.net/p/maxima/bugs....

John Palmieri gravatar imageJohn Palmieri ( 2016-11-02 20:00:04 -0500 )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-02 23:11:35 -0500 )edit
2

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

John Palmieri gravatar imageJohn Palmieri ( 2016-11-03 09:24:04 -0500 )edit
1

answered 2017-05-24 08:19:58 -0500

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

Stats

Asked: 2016-11-02 12:23:14 -0500

Seen: 286 times

Last updated: May 24