ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 24 May 2017 15:19:58 +0200Sage seems to be improperly computing an infinite sum, and giving an incorrect answerhttps://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/Reference this question: https://ask.sagemath.org/question/35305/how-i-can-test-this-equality-with-sage/
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?Wed, 02 Nov 2016 18:23:14 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/Comment by slelievre for <p>Reference this question: <a href="https://ask.sagemath.org/question/35305/how-i-can-test-this-equality-with-sage/">https://ask.sagemath.org/question/353...</a></p>
<p>Here is the evaluation of an infinite sum in sage:</p>
<pre><code>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
</code></pre>
<p>Evaluating the same sum in Mathematica: </p>
<pre><code>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])
</code></pre>
<p>Sage seems to be giving an incorrect solution. Am I missing something?</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35372#post-id-35372Thanks for reporting this bug!Thu, 03 Nov 2016 04:33:40 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35372#post-id-35372Answer by tmonteil for <p>Reference this question: <a href="https://ask.sagemath.org/question/35305/how-i-can-test-this-equality-with-sage/">https://ask.sagemath.org/question/353...</a></p>
<p>Here is the evaluation of an infinite sum in sage:</p>
<pre><code>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
</code></pre>
<p>Evaluating the same sum in Mathematica: </p>
<pre><code>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])
</code></pre>
<p>Sage seems to be giving an incorrect solution. Am I missing something?</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?answer=37683#post-id-37683This 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 !
Wed, 24 May 2017 15:19:58 +0200https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?answer=37683#post-id-37683Answer by John Palmieri for <p>Reference this question: <a href="https://ask.sagemath.org/question/35305/how-i-can-test-this-equality-with-sage/">https://ask.sagemath.org/question/353...</a></p>
<p>Here is the evaluation of an infinite sum in sage:</p>
<pre><code>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
</code></pre>
<p>Evaluating the same sum in Mathematica: </p>
<pre><code>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])
</code></pre>
<p>Sage seems to be giving an incorrect solution. Am I missing something?</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?answer=35358#post-id-35358I 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.
Wed, 02 Nov 2016 19:59:51 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?answer=35358#post-id-35358Comment by John Palmieri for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35367#post-id-35367It 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/3236/.Thu, 03 Nov 2016 02:00:04 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35367#post-id-35367Comment by kcrisman for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35360#post-id-35360I've opened https://trac.sagemath.org/ticket/21801 though I don't have time to report upstream now (meeting in a few minutes)Wed, 02 Nov 2016 21:07:26 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35360#post-id-35360Comment by rtc for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35363#post-id-35363@krisman thanks!Wed, 02 Nov 2016 21:29:13 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35363#post-id-35363Comment by Masacroso for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35373#post-id-35373If 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](https://sagecell.sagemath.org/?z=eJwrSyzSUM9T17RWSCwuLs1N1cjTUc_MK0lNTy0CCaZp5GnaGupr5Glp6BpqxuVpG2nychVn5hbkZKZVaqRpGGnlaWqDKW1DTU0AeH0Vow==&lang=sage). Maybe this is unrelated to the problem and is just some kind of non very standard notation.Thu, 03 Nov 2016 05:11:35 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35373#post-id-35373Comment by John Palmieri for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35398#post-id-35398That term is just (1/2) multiplied by 1/(n+1).Thu, 03 Nov 2016 15:24:04 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35398#post-id-35398Comment by rtc for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35585#post-id-35585In the upstream bug report it seems to have now been fixed.Tue, 15 Nov 2016 06:25:54 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35585#post-id-35585Comment by kcrisman for <p>I don't think you're missing anything: Sage is not computing the infinite sum correctly. The summand is half of <code>1/((n+1)*(2n-1))</code>, and that's easier to type:</p>
<pre><code>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
</code></pre>
<p>The infinite sum differs from the partial sum by about 8/9, which is consistent with what Mathematica says.</p>
https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35588#post-id-35588Thanks, I've updated the Trac ticket to that effect.Tue, 15 Nov 2016 14:56:42 +0100https://ask.sagemath.org/question/35354/sage-seems-to-be-improperly-computing-an-infinite-sum-and-giving-an-incorrect-answer/?comment=35588#post-id-35588