# Problem with infinite sum With Maple everything is so simple.

R := n -> sum(bernoulli(2*k)/n^(2*k), k = 1..infinity);
seq(evalf(R(i)), i = 1..5);
0.1449340668,0.03986813370,...


With Sage that's another story.

def R(n):
var('k')
return sum(bernoulli(2*k)/n^(2*k), k, 1, infinity)

[R(i) for i in (1..5)]


TypeError: unable to convert x (=2*k) to an integer. What do I miss?

EDIT with errors deleted.

edit retag close merge delete

Yes, you suggested import mpmath. Because of the effects you describe I always work with different worksheets, one with mpmath and one without. Of course this is peripheral here with regard to the problem.

Yes, I swapped n and k. Sorry for this. I deleted the edit.

Sort by » oldest newest most voted

bernoulli is not a "symbolic function" in Sage, so it can't accept inputs that aren't integers like 2*k. We are working on converting many previously only numerical functions in Sage to accept symbolic input (like Bessel functions), but probably the first priority of number theorists in Sage wasn't to allow that particular functionality for Bernoulli numbers. Even if clever power series tricks can allow summations of such things.

So I don't think you can directly do the sum from 1 to infinity this way. However, the magic of lambda functions might make things nearly as good? I don't know what you are looking for exactly.

sage: F = lambda k,n: bernoulli(2*k)/n^(2*k)


But some experimentation suggests that if e.g. the sum for n=1 really does converge to -1/4/(e - e^(3/2)), it must do so VERY slowly, so probably you would only be interested in the symbolic solution, which Maxima doesn't seem to have either.

more

1

We should really start leveraging more of mpmath and sympy. As a workaround for the numerics, import mpmath; R = lambda n: mpmath.nsum(lambda k: mpmath.bernoulli(2*k)/n**(2*k), [1, mpmath.inf]) should work. BTW, you've almost hit 6k!!

1

@kcrisman Both types of solutions would be nice, of course. Thank you, I will help you to get the 6k for the case n=1 ;-)) @DSM mpmath is nice and even faster than Maple. Thank you. Write it as an answer and I will help you to reach the 5k. (By the way I soon will reach 100, nobody noticed this? :-)

The series certainly doesn't converge for n=1, since abs(bernoulli(2*k)) tends to infinity as k tends to infinity. In fact I don't believe that the series converges for any integral value of n, for I think $sum_{k=1}^{\infty}B_{2k}x^{2k}$ has zero radius of convergence. This should follow from knowing that $sum_{k=1}^{\infty}B_{2k}x^{2k}/(2k)!$ has radius of convergence $2\pi$; the value is $x/(e^x-1)-1-x/2$.

@Francis Clarke "The series certainly doesn't converge for n=1, since abs(bernoulli(2k)) tends to infinity as k tends to infinity." Hmmm, abs((-1)^k(k+1/k)) tends to infinity as k tends to infinity but sum((-1)^k(k+1/k)/n^k,k=1..infinity) converges, for n>1, if I am not mistaken.

The remark that $|B_{2k}|\to\infty$ was intended only to justify divergence for $n=1$. The final sentence implies divergence for $n>1$.