Skip to content

BellNumber ​

The nth Bell number, counting the ways to partition a set of n elements.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaBell numberMathWorldBellNumberWikidataQ816063DLMF26.7.iFungrimBellNumber✓Fungrim entry60dc3e✓f4e249✓OEISA000110Wolfram LanguageBellB!
BellNumber(n)the nth Bell number BnB_n, the number of partitions of an n-element set.
SageMathbell_number(n)✓SymPybell(n)Oscarbell(n)Juliabell(ZZ(n))
BellNumber(n, x)the Bell (Touchard) polynomial Bn(x)=∑kS(n,k) xkB_n(x) = \sum_k S(n,k)\,x^k, exact for a nonnegative integer n.
Typed signatures
TypePackageApplies
(integer) -> integercompute-enginealways
(integer, any?) -> anynumber-theoryreplaces compute-enginealways

Domain: Combinatorics

Details
  • Recurrence Bn+1=∑k=0n(nk) BkB_{n+1} = \sum_{k=0}^{n} \binom{n}{k}\, B_k, built from Binomial and the lower Bell numbers.
  • Generating function ∑nBntnn!=eet−1\sum_{n} B_n \frac{t^n}{n!} = e^{e^t - 1}.
  • Equals the sum of Stirling numbers of the second kind over all block counts, Bn=∑k=0nS(n,k)B_n = \sum_{k=0}^{n} S(n, k).
  • Also arise as the nth moment of a Poisson distribution with mean 1.
  • compute-engine requires a nonnegative integer argument; a negative n is left unevaluated.
  • The two-argument form Bn(x)B_n(x) is the Bell (Touchard) polynomial; Bn(1)=BnB_n(1) = B_n.

Examples

1 more kept as data, checked against the oracles
Basic #
live ↗
InBellNumber(0)\mathrm{BellNumber}(0)Out11
live ↗
InBellNumber(1)\mathrm{BellNumber}(1)Out11
live ↗
InBellNumber(3)\mathrm{BellNumber}(3)Out55
live ↗
InBellNumber(5)\mathrm{BellNumber}(5)Out5252
live ↗
InBellNumber(10)\mathrm{BellNumber}(10)Out115 975115\,975
Scope #

Threads element-wise over a list, as Wolfram's Listable heads do

live ↗
InBellNumber([1,2,3,4])\mathrm{BellNumber}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack)Out[1,2,5,15]\bigl\lbrack1, 2, 5, 15\bigr\rbrack

Exact for large n

live ↗
InBellNumber(30)\mathrm{BellNumber}(30)Out846 749 014 511 809 332 450 147846\,749\,014\,511\,809\,332\,450\,147

The two-argument form gives the Bell (Touchard) polynomial ∑kS(n,k) xk\sum_k S(n, k)\,x^k

live ↗
InBellNumber(5,x)\mathrm{BellNumber}(5, x)Outx5+10x4+25x3+15x2+xx^5+10x^4+25x^3+15x^2+x

The Bell polynomial at a real point, B20(0.5)B_{20}(0.5)

live ↗
InBellNumber(20,0.5)\mathrm{BellNumber}(20, 0.5)Out270 190 131 940.151 92270\,190\,131\,940.151\,92

Threads over a list of indices

live ↗
InBellNumber([1,2,3,4,5,6])\mathrm{BellNumber}(\bigl\lbrack1, 2, 3, 4, 5, 6\bigr\rbrack)Out[1,2,5,15,52,203]\bigl\lbrack1, 2, 5, 15, 52, 203\bigr\rbrack
Applications #

The number of ways to partition a 4-element set into non-empty, unlabeled subsets

live ↗
InBellNumber(4)\mathrm{BellNumber}(4)Out1515
Properties #

Recurrence: Bn+1=∑k=0n(nk)BkB_{n+1} = \sum_{k=0}^n \binom{n}{k} B_k, here at n=4n = 4

live ↗
InBellNumber(5)=(40)BellNumber(0)+(41)BellNumber(1)+(42)BellNumber(2)+(43)BellNumber(3)+(44)BellNumber(4)\mathrm{BellNumber}(5)=\binom{4}{0}\mathrm{BellNumber}(0)+\binom{4}{1}\mathrm{BellNumber}(1)+\binom{4}{2}\mathrm{BellNumber}(2)+\binom{4}{3}\mathrm{BellNumber}(3)+\binom{4}{4}\mathrm{BellNumber}(4)OutTrue\mathrm{True}

The Bell polynomial at 1 is the Bell number: Bn(1)=BnB_n(1) = B_n

live ↗
InBellNumber(5,1)\mathrm{BellNumber}(5, 1)Out5252

Dobinski's formula Bn=1e∑k≥0knk!B_n = \frac{1}{e}\sum_{k \ge 0} \frac{k^n}{k!}

live ↗
In1e(∑k=0∞k5k!)\frac{1}{e}(\sum_{k=0}^{∞}\frac{k^5}{k!})Out5252

Touchard's congruence Bp+n≡Bn+Bn+1(modp)B_{p+n} \equiv B_n + B_{n+1} \pmod p, here p=7p = 7, n=2n = 2

live ↗
InBellNumber(9) mod 7=(BellNumber(2)+BellNumber(3)) mod 7\mathrm{BellNumber}(9)\bmod7=(\mathrm{BellNumber}(2)+\mathrm{BellNumber}(3))\bmod7OutTrue\mathrm{True}

Exponential generating function is eex−1e^{e^x-1}

live ↗
InExponentialGeneratingFunction(BellNumber(n),n,x)\mathrm{ExponentialGeneratingFunction}(\mathrm{BellNumber}(n), n, x)Outeex−1e^{e^{x}-1}

Two elements split into set partitions in 2 ways

live ↗
InBellNumber(2)\mathrm{BellNumber}(2)Out22

Known value · Wolfram MathematicalFunctionData, BellB

203 set partitions of a 6-element set

live ↗
InBellNumber(6)\mathrm{BellNumber}(6)Out203203

Known value · Wolfram MathematicalFunctionData, BellB

877 set partitions of a 7-element set

live ↗
InBellNumber(7)\mathrm{BellNumber}(7)Out877877

Known value · Wolfram MathematicalFunctionData, BellB

Growth is fast: 4140 partitions at n=8n=8

live ↗
InBellNumber(8)\mathrm{BellNumber}(8)Out4 1404\,140

Known value · Wolfram MathematicalFunctionData, BellB

21147 set partitions of 9 elements

live ↗
InBellNumber(9)\mathrm{BellNumber}(9)Out21 14721\,147

Known value · Wolfram MathematicalFunctionData, BellB

The Bell polynomial B1(x)=xB_1(x)=x vanishes at 0

live ↗
InBellNumber(1,0)\mathrm{BellNumber}(1, 0)Out00

Known value · Wolfram MathematicalFunctionData, BellB:Polynomial

The Bell polynomial B2(x)=x2+xB_2(x)=x^2+x vanishes at 0

live ↗
InBellNumber(2,0)\mathrm{BellNumber}(2, 0)Out00

Known value · Wolfram MathematicalFunctionData, BellB:Polynomial

Possible issues #

A negative argument is left unevaluated

live ↗
InBellNumber(−1)\mathrm{BellNumber}(-1)OutBellNumber(−1)\mathrm{BellNumber}(-1)
Neat examples #

The first ten Bell numbers

live ↗
InBellNumber(1..10)\mathrm{BellNumber}(1..10)Out[1,2,5,15,52,203,877,4 140,21 147,115 975]\bigl\lbrack1, 2, 5, 15, 52, 203, 877, 4\,140, 21\,147, 115\,975\bigr\rbrack
About
Examples26
Checked againstWolfram Language 25 agree1 differSageMath 17 agree2 errorSymPy 17 agree2 errormathlib4 14 agree5 errorOscar 8 agree4 errorJulia 16 agree2 error
CrosswalkWikipediaMathWorldWikidataDLMFFungrimFungrim entry ×2OEISWolfram LanguageSageMathSymPyOscarJulia

Implementation

mappedwolframpackages/oracle/src/mappings.ts

Wolfram spells it BellB. Julia's bare bell(::Int) tries to fit an arbitrary-precision result into an Int64 past n≈25; ZZ keeps it exact.

mappedsympypackages/oracle/src/mappings.ts

Wolfram spells it BellB. Julia's bare bell(::Int) tries to fit an arbitrary-precision result into an Int64 past n≈25; ZZ keeps it exact.

mappedsagepackages/oracle/src/mappings.ts

Wolfram spells it BellB. Julia's bare bell(::Int) tries to fit an arbitrary-precision result into an Int64 past n≈25; ZZ keeps it exact.

mappedoscarpackages/oracle/src/mappings.ts

Wolfram spells it BellB. Julia's bare bell(::Int) tries to fit an arbitrary-precision result into an Int64 past n≈25; ZZ keeps it exact.

mappedjuliapackages/oracle/src/mappings.ts

Wolfram spells it BellB. Julia's bare bell(::Int) tries to fit an arbitrary-precision result into an Int64 past n≈25; ZZ keeps it exact.

mappedmathlib4packages/oracle/src/mappings.ts

Nat.bell counts the partitions of an n-element set, B(0) = 1; natural n only.

See also: StirlingS1