Previous Page Next Page Contents

bernoulli -- the Bernoulli numbers and polynomials

Introduction

bernoulli(n) returns the n-th Bernoulli number.

bernoulli(n, x) returns the n-th Bernoulli polynomial in x.

Call(s)

bernoulli(n)
bernoulli(n, x)

Parameters

n - an arithmetical expression representing a nonnegative integer
x - an arithmetical expression

Returns

an arithmetical expression.

Side Effects

When called with a floating point value x, the function is sensitive to the environment variable DIGITS which determines the numerical working precision.

Details

Example 1

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]

Example 2

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

Example 3

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)

Example 4

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:

Background

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000