## `combinat::bell` -- Computing Bell numbers

#### Introduction

`combinat::bell`(n) computes the n-th Bell number.

#### Call(s)

`combinat::bell(n)`
`combinat::bell(expression)`

#### Parameters

`n` | - | nonnegative integer
`expression` | - | An expression of type `Type::Arithmetical` which must be a nonnegative integer if it is a number.

#### Returns

A positive integer value if `n` was a nonnegative integer. Otherwise `combinat::bell` returns the unevaluated function call.

#### Details

- The n-th bell number is defined by the exponential generating function:

      exp(exp(x) - 1) = sum(bell(n)/n! * x^n, n = 0..infinity)

  Often another definition is used. The n-th bell number is the number of different ways of partitioning the set 1, 2, ..., n into disjoint nonempty subsets, and bell(0) is defined to be 1.
- Bell numbers are computed using the formula:

                   bell(0)   = 1
                   bell(n+1) = sum(binomial(n,i)*bell(i), i=0..n), n > 0

#### Example 1

    >> combinat::bell(3)

                                         5

This means that you can partition the set 1,2,3 into disjoint subsets in 5 different ways. These are {{1,2,3}}, {{1},{2,3}}, {{2},{1,3}}, {{3},{1,2}}, and {{1},{2},{3}}. Or, that you can write 105 = 3*5*7 as 5 different products. These are 105 = 3*5*7 = 15*7 = 21*5 = 3*35 = 105*1.

#### Example 2

If one uses a wrong argument, an error message is returned

    >> combinat::bell(3.4)

          Error: Nonnegative integer expected [combinat::bell]

#### Example 3

One can see why it is useful to return the unevaluated function call.

    >> a:=combinat::bell(x)

                                 combinat::bell(x)

    >> x :=4

                                         4

    >> a ; delete a:

                                        15

#### Changes

- In older MuPAD versions `combinat::bell` returned 1 for a negative integer. Now it returns an error message if it gets a negative integer as an argument.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000