bernoulli: Bernoulli Numbers

Bernoulli numbersR Documentation

Bernoulli Numbers

Description

Generate the Bernoulli numbers.

Usage

bernoulli_numbers(n, big = FALSE)

Arguments

n

integer; starting from 0.

big

logical; shall double or GMP big numbers be returned?

Details

Generate the n+1 Bernoulli numbers B_0,B_1, ...,B_n, i.e. from 0 to n. We assume B1 = +1/2.

With big=FALSE double integers up to 2^53-1 will be used, with big=TRUE GMP big rationals (through the 'gmp' package). B_25 is the highest such number that can be expressed as an integer in double float.

Value

Returns a matrix with two columns, the first the numerator, the second the denominator of the Bernoulli number.

References

M. Kaneko. The Akiyama-Tanigawa algorithm for Bernoulli numbers. Journal of Integer Sequences, Vol. 3, 2000.

D. Harvey. A multimodular algorithm for computing Bernoulli numbers. Mathematics of Computation, Vol. 79(272), pp. 2361-2370, Oct. 2010. arXiv 0807.1347v2, Oct. 2018.

See Also

pascal_triangle

Examples

bernoulli_numbers(3); bernoulli_numbers(3, big=TRUE)
##                    Big Integer ('bigz') 4 x 2 matrix:
##      [,1] [,2]          [,1] [,2]
## [1,]    1    1     [1,] 1    1   
## [1,]    1    2     [2,] 1    2   
## [2,]    1    6     [3,] 1    6   
## [3,]    0    1     [4,] 0    1   

## Not run: 
bernoulli_numbers(24)[25,]
## [1] -236364091       2730

bernoulli_numbers(30, big=TRUE)[31,]
## Big Integer ('bigz') 1 x 2 matrix:
##      [,1]          [,2] 
## [1,] 8615841276005 14322

## End(Not run)

numbers documentation built on Dec. 29, 2022, 4:07 p.m.