Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6143
| From | Simon <simonjtyler@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Bernoulli Numbers |
| Date | 2011-11-03 08:51 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j8tknd$f0o$1@smc.vnet.net> (permalink) |
| 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[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 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/
(4)https://groups.google.com/forum/#!topic/sage-devel/6GHGlW6hpa8
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bernoulli Numbers David Turner <DTurner@faulkner.edu> - 2011-11-02 11:28 +0000 Re: Bernoulli Numbers "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-11-03 08:46 +0000 Re: Bernoulli Numbers Simon <simonjtyler@gmail.com> - 2011-11-03 08:51 +0000 Re: Bernoulli Numbers DrMajorBob <btreat1@austin.rr.com> - 2011-11-04 11:02 +0000 Re: Bernoulli Numbers "Alexander Elkins" <alexander_elkins@hotmail.com> - 2011-11-04 11:04 +0000
csiph-web