Ask Your Question
1

Problem with infinite sum

asked 2012-12-29 17:00:10 +0200

petropolis gravatar image

updated 2012-12-30 11:11:17 +0200

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 flag offensive close merge delete

Comments

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.

petropolis gravatar imagepetropolis ( 2012-12-30 11:08:06 +0200 )edit

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

petropolis gravatar imagepetropolis ( 2012-12-30 11:12:40 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-12-29 18:34:39 +0200

kcrisman gravatar image

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.

edit flag offensive delete link more

Comments

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!!

DSM gravatar imageDSM ( 2012-12-29 18:52:15 +0200 )edit
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? :-)

petropolis gravatar imagepetropolis ( 2012-12-29 19:17:24 +0200 )edit

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 gravatar imageFrancis Clarke ( 2012-12-30 12:10:19 +0200 )edit

@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.

petropolis gravatar imagepetropolis ( 2012-12-30 13:10:54 +0200 )edit

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

Francis Clarke gravatar imageFrancis Clarke ( 2012-12-30 18:05:47 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-12-29 17:00:10 +0200

Seen: 1,677 times

Last updated: Dec 30 '12