       Re: Bernoulli Numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg122610] Re: Bernoulli Numbers
• From: Simon <simonjtyler at gmail.com>
• Date: Thu, 3 Nov 2011 03:46:07 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <j8r9gv\$3jd\$1@smc.vnet.net>

```Bernoulli number generation is already built into Mathematica, so generating them yourself is probably not worthwhile. The formula in your post, which is related to "umbral calculus" and is thus very cool, is not very efficient. To make it tolerably fast, you should combine it with memoization(1) and use

Clear[B]
B = 1;
B[(n_Integer)?Positive] := B[n] = (-(1/(1 + n)))*Sum[Binomial[n + 1, k]*B[k],{k, 0, n - 1}]

Then the first twenty can be generated with

Table[B[i], {i, 1, 20}]
(* Returns: {-(1/2), 1/6, 0, -(1/30),... } *)

Which can be compared to the built in function for the first 1000 values:

And @@ Table[B[i] == BernoulliB[i], {i, 1, 1000}]
(* Returns: True *)

The Wikipedia article(2) discusses algorithms for computing Bernoulli numbers. I think that Mathematica probably uses some hybrid calculational scheme.
A newer algorithm that beat the Mathematica record uses the Chinese Remainder Theorem and is implemented in some CAS is described at http://arxiv.org/abs/0807.1347 There was some discussion of this at the time over at (4).

(1)http://reference.wolfram.com/mathematica/tutorial/FunctionsThatRememberValuesTheyHaveFound.html
(2)http://en.wikipedia.org/wiki/Bernoulli_number
(3)http://blog.wolfram.com/2008/04/29/today-we-broke-the-bernoulli-record-from-the-analytical-engine-to-mathematica/