MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bernoulli Numbers

  • To: mathgroup at
  • Subject: [mg122610] Re: Bernoulli Numbers
  • From: Simon <simonjtyler at>
  • Date: Thu, 3 Nov 2011 03:46:07 -0500 (EST)
  • Delivered-to:
  • References: <j8r9gv$3jd$>
  • Reply-to: comp.soft-sys.math.mathematica at

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

B[0] = 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.
There was a nice Wolfram blog post a while back about this(3).
A newer algorithm that beat the Mathematica record uses the Chinese Remainder Theorem and is implemented in some CAS is described at There was some discussion of this at the time over at (4).


  • Prev by Date: Re: iteration question
  • Next by Date: Re: How to eliminate noises?
  • Previous by thread: Re: Bernoulli Numbers
  • Next by thread: Re: Bernoulli Numbers