Post Reply 
Bernoulli numbers and large factorials
02-12-2014, 08:56 PM
Post: #8
RE: Bernoulli numbers and large factorials
(02-09-2014 09:44 PM)Paul Dale Wrote:  The 34S is computing the Bernoulli numbers from the zeta function. A short series expansion like you've got here will be faster I expect.

Well, this series expansion, i.e. the sum in the formula, actually is the Zeta function. ;-)

\( \begin{align*}
B_n  &=  2 n! {(2\pi)^{-n}}  \sum\limits_{i=1}^{\infty}i^{-n}\\
&=  2 n! {(2\pi)^{-n}}  \zeta (n)
\end{align*} \)

The 35s program works so fast because the larger n gets, the less terms are required. The following table shows the number of terms needed for an error of at most 0,1 ULP in Zeta:

Code:
 n      10      12      16    34 digits
---------------------------------------
 8      17      31     100     17782
10      10      15      39      2511
12       6      10      21       681
14       5       7      13       268
16       4       5      10       133
20       3       3       6        50
24       2       3       4        26
30       2       2       3        13
40       1       1       2         7

This also explains why up to n = 8 the result is given directly. Otherwise the number of required terms would increase rapidly.

I tried a program with the same algorithm on the 34s. In SP mode it is much faster than the internal Bernoulli function. For large n the result appears within a fraction of a second. As you will expect after a look at the above table, DP mode with 34 digit precision is a different story, at least for small n. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Bernoulli numbers and large factorials - Dieter - 02-12-2014 08:56 PM



User(s) browsing this thread: 1 Guest(s)