Bern | R Documentation |
Return the n
-th Bernoulli number B_n
, (or B_n^+
,
see the reference), where B_1 = + \frac 1 2
.
Bern(n, verbose = getOption("verbose", FALSE))
n |
integer, |
verbose |
logical indicating if computation should be traced. |
The number B_n
of type numeric
.
A side effect is the caching of computed Bernoulli numbers in the
hidden environment
.bernoulliEnv
.
Martin Maechler
https://en.wikipedia.org/wiki/Bernoulli_number
Bernoulli
in Rmpfr in arbitrary precision
via Riemann's \zeta
function.
The next version of package gmp is to contain
BernoulliQ()
, providing exact Bernoulli numbers as
big rationals (class "bigq"
).
(B.0.10 <- vapply(0:10, Bern, 1/2))
## [1] 1.00000000 +0.50000000 0.16666667 0.00000000 -0.03333333 0.00000000
## [7] 0.02380952 0.00000000 -0.03333333 0.00000000 0.07575758
if(requireNamespace("MASS")) {
print( MASS::fractions(B.0.10) )
## 1 +1/2 1/6 0 -1/30 0 1/42 0 -1/30 0 5/66
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.