Learn R Programming

Rmpfr (version 0.2-3)

Bernoulli: Bernoulli Numbers in Arbitrary Precision

Description

Computes the Bernoulli numbers in the desired (binary) precision. The computation happens via the zeta function and the formula $$B_k = -k \zeta(1 - k).$$

Usage

Bernoulli(k, precBits = 128)

Arguments

k
positive integer vector
precBits
the precision in bits desired.

Value

  • an mpfr class vector of the same length as k, with i-th component the k[i]-th Bernoulli number.

References

http://en.wikipedia.org/wiki/Bernoulli_number

See Also

zeta is used to compute them.

Examples

Run this code
Bernoulli(1:10)
plot(as.numeric(Bernoulli(1:15)), type = "h")

## They pretty much explode for larger k :
k2 <- 2*(1:120)
plot(k2, abs(as.numeric(Bernoulli(k2))), log = "y")
title("Bernoulli numbers exponential growth")

Bernoulli(10000)# - 9.0494239636 * 10^27677

Run the code above in your browser using DataLab