
Bernoulli Number generator
function fB(nB) // recursive function for Bernoulli Number variable nB // number index argument variable v if(nB==0) return 1 else make/O/D/FREE/N=(nB) wB wB = binomial(nB+1,p)*fB(p) v = -sum(wB)/(nB+1) return v // Bernoulli number value endif end

Forum

Support

Gallery
Igor Pro 10
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
The second argument, 1, in
zeta(n,1,400)
makes it the Riemann zeta function; the third argument improves the precision for small 'n'.October 2, 2017 at 08:18 am - Permalink
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
October 5, 2017 at 07:06 am - Permalink
I think the importance of computation speed depends on what the user needs. For computing many Bn at the same time a recursive approach is widely used. As Brent notes (https://arxiv.org/abs/1108.0286v3): "However, this is unsatisfactory if floating-point numbers are used, because the recurrence in numerically unstable." Harvey (http://web.maths.unsw.edu.au/~davidharvey/talks/bernoulli.pdf) gives an interesting approach wherein ONE division operation provides all necessary coefficients for the Bn up to a given order. The hitch is that huge numerators and denominators are required, and the division is best done in base 2. I tested the concept using
APmath
in base 10, and it works!October 5, 2017 at 08:21 am - Permalink
I agree. I was posting more to explore other options.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
October 9, 2017 at 06:19 pm - Permalink