WOLFRAM

StirlingS2[n,m]

gives the Stirling number of the second kind TemplateBox[{n, m}, StirlingS2].

Details

  • Integer mathematical function, suitable for both symbolic and numerical manipulation.
  • StirlingS2 is defined as the conversion matrix from Power of continuous calculus to FactorialPower of discrete calculus x^n=sum_(m=1)^n TemplateBox[{n, m}, StirlingS2]TemplateBox[{x, m}, FactorialPower], where m,n in TemplateBox[{}, PositiveIntegers].
  • TemplateBox[{n, m}, StirlingS2] gives the number of ways of partitioning a set of elements into nonempty subsets. »
  • StirlingS2 automatically threads over lists.

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

Evaluate a Stirling number of the second kind:

Out[2]=2

Evaluate multiple Stirling numbers:

Out[3]=3

Scope  (2)Survey of the scope of standard use cases

StirlingS2 threads element-wise over lists:

Out[1]=1

TraditionalForm formatting:

Applications  (5)Sample problems that can be solved with this function

Plot Stirling numbers of the second kind on a logarithmic scale:

Out[1]=1

Stirling numbers modulo 2:

Out[1]=1

Define a recursive function for generating set partitions:

Generate all set partitions of n elements:

Out[2]=2

Count the number of set partitions that have 1, 2, n disjoint subsets:

Out[3]=3

The Stirling number of the second kind counts the number of disjoint subsets:

Out[4]=4

Closed form of derivatives of compositions with exponential functions:

Out[1]=1
Out[2]=2

A fair sided die is thrown times independently. The probability that all faces appear at least once is given in terms of Stirling numbers of the second kind:

Plot the probability for a six-sided die:

Out[2]=2

Check with simulations:

Out[3]=3
Out[4]=4

Properties & Relations  (7)Properties of the function, and connections to other functions

Generate values from the ordinary generating function:

Out[2]=2
Out[3]=3

Generate values from the exponential generating function:

Out[1]=1
Out[2]=2

Stirling numbers of the second kind are effectively inverses of Stirling numbers of the first kind:

Calculate large Stirling numbers of the second kind using Cauchy's theorem:

Out[1]=1
Out[2]=2

Generate Stirling numbers of the second kind from the commutation relation :

Out[2]=2
Out[3]=3

The limit of finite differences of powers are Stirling numbers of the second kind:

Out[1]=1
Out[2]=2
Out[3]=3

Stirling numbers of the second kind are given by a partial Bell polynomial with unit arguments:

Out[1]=1
Out[2]=2

Possible Issues  (2)Common pitfalls and unexpected behavior

StirlingS2 can take large values for moderatesize arguments:

Out[2]=2

The value at is defined to be 1:

Out[1]=1

Neat Examples  (2)Surprising or curious use cases

Plot sums of digits:

Out[1]=1

Determinants of a matrix with Stirling number entries:

Out[1]=1

Compare with the closed form:

Out[2]=2
Wolfram Research (1988), StirlingS2, Wolfram Language function, https://reference.wolfram.com/language/ref/StirlingS2.html.
Wolfram Research (1988), StirlingS2, Wolfram Language function, https://reference.wolfram.com/language/ref/StirlingS2.html.

Text

Wolfram Research (1988), StirlingS2, Wolfram Language function, https://reference.wolfram.com/language/ref/StirlingS2.html.

Wolfram Research (1988), StirlingS2, Wolfram Language function, https://reference.wolfram.com/language/ref/StirlingS2.html.

CMS

Wolfram Language. 1988. "StirlingS2." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StirlingS2.html.

Wolfram Language. 1988. "StirlingS2." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StirlingS2.html.

APA

Wolfram Language. (1988). StirlingS2. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StirlingS2.html

Wolfram Language. (1988). StirlingS2. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StirlingS2.html

BibTeX

@misc{reference.wolfram_2025_stirlings2, author="Wolfram Research", title="{StirlingS2}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/StirlingS2.html}", note=[Accessed: 16-April-2025 ]}

@misc{reference.wolfram_2025_stirlings2, author="Wolfram Research", title="{StirlingS2}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/StirlingS2.html}", note=[Accessed: 16-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_stirlings2, organization={Wolfram Research}, title={StirlingS2}, year={1988}, url={https://reference.wolfram.com/language/ref/StirlingS2.html}, note=[Accessed: 16-April-2025 ]}

@online{reference.wolfram_2025_stirlings2, organization={Wolfram Research}, title={StirlingS2}, year={1988}, url={https://reference.wolfram.com/language/ref/StirlingS2.html}, note=[Accessed: 16-April-2025 ]}