StirlingS1[n,m]
gives the Stirling number of the first kind
.
StirlingS1
StirlingS1[n,m]
gives the Stirling number of the first kind
.
Details
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- StirlingS1 is defined as the conversion matrix from FactorialPower of discrete calculus to Power of continuous calculus
, where
.
gives the number of permutations of
elements that contain exactly
cycles. »- StirlingS1 automatically threads over lists.
Examples
open all close allBasic Examples (1)
Scope (2)
StirlingS1 threads element–wise over lists:
StirlingS1[{2, 4, 6}, 2]TraditionalForm formatting:
StirlingS1[n, m]//TraditionalFormApplications (5)
Plot Stirling numbers of the first kind on a logarithmic scale:
ListPlot3D[Table[Log[Abs[StirlingS1[n, m]] + 1], {n, 60}, {m, 60}]]ArrayPlot[Mod[Table[StirlingS1[n, m], {n, 0, 100}, {m, 0, 100}], 2]]Generate the disjoint cycle representations of all permutations of n elements:
n = 4;
cycles = PermutationCycles[#, Identity]& /@ Permutations[Range[n]]Count the number of permutations that have 1, 2, … n disjoint cycles:
KeySort[Counts[Length /@ cycles]]The unsigned Stirling number of the first kind counts the number of disjoint cycles:
Abs[StirlingS1[n, Range[n]]]Plot the average number of cycles in symmetric group elements:
DiscretePlot[Sum[(-1) ^ (n - k) k StirlingS1[n, k], {k, n}] / n!, {n, 25}]The distribution of the position of the ![]()
record in the infinite sequence, independent, identically distributed, continuous random variables:
recordCount𝒟[n_Integer] = ProbabilityDistribution[(-1)^k - nStirlingS1[k - 1, n - 1] / k!, {k, n, Infinity, 1}];Visualize the probability mass function of the second record:
pl = DiscretePlot[PDF[recordCount𝒟[2], m], {m, 2, 8}, ExtentSize -> 0.5]Code to find the position of the ![]()
record in a given vector, if any:
nthRecordPosition = Compile[{{n, _Integer}, {x, _Real, 1}}, Module[{record = First[x], recordPos = 1, recordCount = 1},
Do[If[x[[k]] > record,
record = x[[k]];
recordPos = k;
If[(++recordCount) == n, Break[]]], {k, 2, Length[x]}];If[recordCount == n, recordPos, Length[x] + 1]], RuntimeAttributes -> Listable];Compute positions of the second record in random exponential sequences and compare their histogram to the expected probability mass function:
With[{rep = 10 ^ 5, len = 10}, Show[Histogram[nthRecordPosition[2, RandomVariate[ExponentialDistribution[1], {rep, len}]], {Range[2, 9] - 1 / 2}, #2 / rep&], pl]]Properties & Relations (5)
Generate values from the ordinary generating function:
Series[FactorialPower[t, 12], {t, 0, 5}]Table[StirlingS1[12, m], {m, 5}]Generate values from the exponential generating function:
With[{n = 12},
Table[n! / m!SeriesCoefficient[Series[Log[1 + t]^m, {t, 0, n}], n], {m, 5}]]Table[StirlingS1[12, m] , {m, 5}]Stirling numbers of the first kind are effectively inverses of Stirling numbers of the second kind:
Table[Sum[StirlingS1[m, l] StirlingS2[l, n], {l, 0, Max[n, m] + 1}], {n, 0, 5}, {m, 0, 5}]//MatrixFormCalculate large Stirling numbers of the first kind using Cauchy's theorem:
With[{n = 100, m = 11, ρ = 1}, ((-1) ^ m /2 Pi)Re[ NIntegrate[Evaluate[Pochhammer[1 + x, n - 1] / x ^ m ρ Exp[I φ] /. x -> ρ Exp[I φ]], {φ, 0, 2Pi}]]]StirlingS1[100, 11]//NStirling numbers of the first kind are given by a partial Bell polynomial with sign‐alternating factorial arguments:
Table[BellY[n, m, Table[(-1)^k - 1(k - 1)!, {k, n}]], {n, 5}, {m, n}]Table[StirlingS1[n, m], {n, 5}, {m, n}]Possible Issues (2)
StirlingS1 can have large values for moderately sized arguments:
StirlingS1[1000, 600]//ShortN[%]The value at
is defined to be 1:
StirlingS1[0, 0]Neat Examples (2)
ArrayPlot[Table[Total[IntegerDigits[StirlingS1[n, m]]], {n, 36}, {m, 36}]]Determinants of a matrix with Stirling number entries:
Table[Det @ Table[((-1)^ji!/(i + j)!)StirlingS1[i + j, i], {i, 0, n}, {j, 0, n}], {n, 10}]Table[2^-n (n + 1) / 2, {n, 10}]Tech Notes
Related Links
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), StirlingS1, Wolfram Language function, https://reference.wolfram.com/language/ref/StirlingS1.html.
CMS
Wolfram Language. 1988. "StirlingS1." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StirlingS1.html.
APA
Wolfram Language. (1988). StirlingS1. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StirlingS1.html
BibTeX
@misc{reference.wolfram_2026_stirlings1, author="Wolfram Research", title="{StirlingS1}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/StirlingS1.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_stirlings1, organization={Wolfram Research}, title={StirlingS1}, year={1988}, url={https://reference.wolfram.com/language/ref/StirlingS1.html}, note=[Accessed: 13-June-2026]}