bernoulli
-- the Bernoulli
numbers and polynomialsbernoulli
(n)
returns the n-th
Bernoulli number.
bernoulli
(n, x)
returns the
n-th Bernoulli polynomial in x.
bernoulli(n)
bernoulli(n, x)
n |
- | an arithmetical expression representing a nonnegative integer |
x |
- | an arithmetical expression |
an arithmetical expression.
When called with a floating point value x
, the function
is sensitive to the environment variable DIGITS
which determines the numerical
working precision.
t*exp(x*t)/(exp(t)-1) = sum(bernoulli(n,x)/n!*t^n, n=0..infinity).
bernoulli(n)
=
bernoulli(n,0)
.n
is a numerical value not
representing a nonnegative integer. If n
contains
non-numerical symbolic identifiers, then a symbolic call
bernoulli(n)
is returned. Various simplifications of
bernoulli(n,x)
are implemented for symbolic n
and special numerical values of x
. Cf. example 3.Note that floating point evaluation for high degree polynomials may be numerically unstable. Cf. example 4.
The first Bernoulli numbers are:
>> bernoulli(n) $ n = 0..11
1, -1/2, 1/6, 0, -1/30, 0, 1/42, 0, -1/30, 0, 5/66, 0
The first Bernoulli polynomials:
>> bernoulli(n, x) $ n = 0..4
2 2 x 3 x 3 2 3 4 1, x - 1/2, x - x + 1/6, - - ---- + x , x - 2 x + x - 1/30 2 2
If n
is symbolic, then a symbolic call is
returned:
>> bernoulli(n, x), bernoulli(n + 3/2, x), bernoulli(n + 5*I, x)
bernoulli(n, x), bernoulli(n + 3/2, x), bernoulli(n + 5 I, x)
An error occurs if n
represents a numerical
value that is not a nonnegative integer:
>> bernoulli(sin(3), x)
Error: first argument must be symbolic or a nonnegative \ integer [bernoulli]
If x
is not an indeterminate, then the
evaluation of the Bernoulli polynomial at the point x
is
returned:
>> bernoulli(50, 1 + I)
132549963452557267373179389125/66 + 25 I
>> bernoulli(3, 1 - y), expand(bernoulli(3, 1 - y))
2 2 (1 - y) (3 - 3 y) (1 - y) (3 - 3 y) y 3 y y 3 ------------------ - ----------------- - - + 1/2, ---- - - - y 3 2 2 2 2
Certain simplifications occur for some special numerical
value of x
, even if n
is symbolic:
>> bernoulli(n, -2), bernoulli(n, -1/2), bernoulli(n, -1/6)
n n n - 1 (-1) bernoulli(n, 2) + n (-1) 2 , n 1 - n n n - 1 bernoulli(n) (-1) (2 - 1) + n (-1) (1/2) , n n n - 1 (-1) bernoulli(n, 1/6) + n (-1) (1/6)
>> bernoulli(n, 1/2), bernoulli(n, 2/3), bernoulli(n, 0.7)
1 - n n bernoulli(n) (2 - 1), (-1) bernoulli(n, 1/3), n (-1) bernoulli(n, 0.3)
Float evaluation of high degree polynomials may be numerically unstable:
>> exact := bernoulli(50, 1 + I): float(exact);
2.00833278e27 + 25.0 I
>> bernoulli(50, float(1 + I))
2.00833278e27 + 437450444.9 I
>> DIGITS := 40: bernoulli(50, float(1 + I))
2008332779584201020805748320.075757575758 + 25.000000000000000\ 00000435528380270361207 I
>> delete exact, DIGITS:
n
and special
numerical values of x
were implemented. Efficiency was
improved.