ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 09 Jan 2016 09:59:25 -0600How to evaluate the infinite sum of 1/(2^n-1) over all positive integers?https://ask.sagemath.org/question/32122/how-to-evaluate-the-infinite-sum-of-12n-1-over-all-positive-integers/ I have tried
s = sum(1/(2^x-1), x, 1, oo)
s.n()
But I got
cannot evaluate symbolic expression numerically
The sum does not have a simple form, but it is finite.
So is there a way to evaluate it numerically in sage?Sat, 09 Jan 2016 08:28:40 -0600https://ask.sagemath.org/question/32122/how-to-evaluate-the-infinite-sum-of-12n-1-over-all-positive-integers/Answer by A.Alharbi for <p>I have tried</p>
<pre><code>s = sum(1/(2^x-1), x, 1, oo)
s.n()
</code></pre>
<p>But I got</p>
<pre><code>cannot evaluate symbolic expression numerically
</code></pre>
<p>The sum does not have a simple form, but it is finite.
So is there a way to evaluate it numerically in sage?</p>
https://ask.sagemath.org/question/32122/how-to-evaluate-the-infinite-sum-of-12n-1-over-all-positive-integers/?answer=32124#post-id-32124Another way to do that is by using SymPy:
from sympy import Sum, Symbol
x = Symbol('x')
s = Sum( 1/(x**2-1), (x, 1, 00))
s.doit()
Give the result[1]:
> 0
I remember seeing a way to convert SymPy expression to SAGE format, but I don't know how exactly.
[1] I apologize I typed another function in the command line which is $\frac{1}{x^2 -1}$. After realizing that, I tried to evaluate your function but ipython always crash.
Sat, 09 Jan 2016 09:59:25 -0600https://ask.sagemath.org/question/32122/how-to-evaluate-the-infinite-sum-of-12n-1-over-all-positive-integers/?answer=32124#post-id-32124Answer by vdelecroix for <p>I have tried</p>
<pre><code>s = sum(1/(2^x-1), x, 1, oo)
s.n()
</code></pre>
<p>But I got</p>
<pre><code>cannot evaluate symbolic expression numerically
</code></pre>
<p>The sum does not have a simple form, but it is finite.
So is there a way to evaluate it numerically in sage?</p>
https://ask.sagemath.org/question/32122/how-to-evaluate-the-infinite-sum-of-12n-1-over-all-positive-integers/?answer=32123#post-id-32123One possibility to get around this infinite sumation is to use truncation
sage: sum(1 / (2^x - 1), x, 1, 10).n()
1.60571827189075
sage: sum(1 / (2^x - 1), x, 1, 30).n()
1.60669515148397
sage: sum(1 / (2^x - 1), x, 1, 100).n()
1.60669515241529
Your sum is converging pretty fast. The tail after $n$ is of the order of $2^{-n}$. In particular, since real numbers have a default of 53 bits of precision, the evaluation of the sum is the same at 53 and 100 (but not at 52)
sage: sum(1 / (2^x - 1), x, 1, 52).n() == sum(1 / (2^x - 1), x, 1, 100).n()
False
sage: sum(1 / (2^x - 1), x, 1, 53).n() == sum(1 / (2^x - 1), x, 1, 100).n()
True
The fact that it is exactly 53 in this case is because the size of the tail is exactly $2^{-n}$... for other sums it might be different. But whatever convergent series you are considering, its numerical evaluation will be constant from a certain point.Sat, 09 Jan 2016 09:04:43 -0600https://ask.sagemath.org/question/32122/how-to-evaluate-the-infinite-sum-of-12n-1-over-all-positive-integers/?answer=32123#post-id-32123