Skip to content

StirlingS1 ​

The signed Stirling number of the first kind, relating falling factorials to powers of n.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaStirling numbers of the first kindMathWorldStirlingNumberoftheFirstKindWikidataQ2657556DLMF26.8.i.p1FungrimStirlingS1Fungrim entry071a9418ec99OEISA008275Wolfram LanguageStirlingS1✓
StirlingS1(n, k)the signed Stirling number of the first kind s(n,k)s(n, k).
CombinatoricaFunction[{n, k}, (-1)^(n - k) StirlingFirst[n, k], Listable][n, k]SageMathstirling_number1(n, k)!SymPystirling(n, k, kind=1, signed=True)mpmathstirling1(n, k)JuliaCombinatorics.stirlings1(big(n), k)
Typed signatures
TypePackageApplies
(integer, integer) -> integercompute-enginealways
(integer, integer) -> integernumber-theoryreplaces compute-enginealways

Domain: Combinatorics

Details
  • Coefficients relating falling factorials to ordinary powers: (x)n=∑ks(n,k) xk(x)_n = \sum_{k} s(n, k)\, x^k.
  • ∣s(n,k)∣|s(n, k)| counts the permutations of n elements with exactly k cycles.
  • s(n,n)=1s(n, n) = 1 and s(n,0)=0s(n, 0) = 0 for n>0n > 0, with the boundary case s(0,0)=1s(0, 0) = 1.
  • The unsigned values in each row sum to n!n!: ∑k∣s(n,k)∣=n!\sum_k |s(n, k)| = n!
  • s(n,1)=(−1)n−1(n−1)!s(n, 1) = (-1)^{n-1}(n-1)!.
  • Threads element-wise over a list of nn, as Wolfram's Listable heads do.

Plot

Examples

2 more kept as data, checked against the oracles
Basic #
live ↗
InStirlingS1(5,2)\mathrm{StirlingS1}(5, 2)Out−50-50
live ↗
InStirlingS1(4,2)\mathrm{StirlingS1}(4, 2)Out1111

s(n, n) is always 1

live ↗
InStirlingS1(3,3)\mathrm{StirlingS1}(3, 3)Out11

s(n, 0) is 0 for n > 0

live ↗
InStirlingS1(5,0)\mathrm{StirlingS1}(5, 0)Out00
live ↗
InStirlingS1(20,10)\mathrm{StirlingS1}(20, 10)Out381 922 055 502 195381\,922\,055\,502\,195
Scope #

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

live ↗
InStirlingS1([2,4,6],2)\mathrm{StirlingS1}(\bigl\lbrack2, 4, 6\bigr\rbrack, 2)Out[1,11,274]\bigl\lbrack1, 11, 274\bigr\rbrack

Exact for large n

live ↗
InStirlingS1(50,2)\mathrm{StirlingS1}(50, 2)Out2 724 619 372 591 264 761 651 711 494 187 624 530 726 005 154 239 846 809 600 000 0002\,724\,619\,372\,591\,264\,761\,651\,711\,494\,187\,624\,530\,726\,005\,154\,239\,846\,809\,600\,000\,000
Applications #

The number of permutations of 5 elements with exactly 3 cycles is ∣s(5,3)∣=35|s(5, 3)| = 35

live ↗
InStirlingS1(5,3)\mathrm{StirlingS1}(5, 3)Out3535
live ↗
In∣StirlingS1(n,1..n)∣\vert\mathrm{StirlingS1}(n, 1..n)\vertOutMap(_1⁡↦∣_1⁡∣,Map(_1⁡↦StirlingS1(n,_1⁡),1..n))\mathrm{Map}(\operatorname{\_1}↦\vert\operatorname{\_1}\vert, \mathrm{Map}(\operatorname{\_1}↦\mathrm{StirlingS1}(n, \operatorname{\_1}), 1..n))
Properties #

The unsigned values in a row sum to n!n!

live ↗
In∑k=04∣StirlingS1(4,k)∣=4!\sum_{k=0}^4\vert\mathrm{StirlingS1}(4, k)\vert=4!OutTrue\mathrm{True}

The signed row sum vanishes for n≥2n \ge 2

live ↗
In∑k=06StirlingS1(6,k)\sum_{k=0}^6\mathrm{StirlingS1}(6, k)Out00

s(n,n−1)=−(n2)s(n, n-1) = -\binom{n}{2}

live ↗
InStirlingS1(6,5)=−(62)\mathrm{StirlingS1}(6, 5)=-\binom{6}{2}OutTrue\mathrm{True}

The generating property: ∑ks(n,k) xk=x(x−1)⋯(x−n+1)\sum_k s(n, k)\,x^k = x(x-1)\cdots(x-n+1)

live ↗
In∑k=04StirlingS1(4,k)xk=Expand(x×(x−1)(x−2)(x−3))\sum_{k=0}^4\mathrm{StirlingS1}(4, k)x^{k}=\mathrm{Expand}(x×(x-1)(x-2)(x-3))OutTrue\mathrm{True}

A 100-digit-scale signed value, evaluated numerically

live ↗
InN(StirlingS1(100,11))N(\mathrm{StirlingS1}(100, 11))Out−390 376 773 476 389 796 543 585 013 048 065 552 669 095 304 773 071 088 642 650 967 777 941 539 595 016 786 090 531 126 519 978 928 664 992 958 028 261 781 883 437 197 859 800 964 094 681 415 680 000 000 000-390\,376\,773\,476\,389\,796\,543\,585\,013\,048\,065\,552\,669\,095\,304\,773\,071\,088\,642\,650\,967\,777\,941\,539\,595\,016\,786\,090\,531\,126\,519\,978\,928\,664\,992\,958\,028\,261\,781\,883\,437\,197\,859\,800\,964\,094\,681\,415\,680\,000\,000\,000

No ways to arrange nothing into one cycle

live ↗
InStirlingS1(0,1)\mathrm{StirlingS1}(0, 1)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

Zero cycles can't hold an element

live ↗
InStirlingS1(1,0)\mathrm{StirlingS1}(1, 0)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

A single fixed point

live ↗
InStirlingS1(1,1)\mathrm{StirlingS1}(1, 1)Out11

Known value · Wolfram MathematicalFunctionData, StirlingS1

More cycles than elements: 00

live ↗
InStirlingS1(1,2)\mathrm{StirlingS1}(1, 2)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

Zero cycles can't hold any element, for n≥1n\ge1

live ↗
InStirlingS1(2,0)\mathrm{StirlingS1}(2, 0)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

Signed: one 2-cycle counts as −1-1

live ↗
InStirlingS1(2,1)\mathrm{StirlingS1}(2, 1)Out−1-1

Known value · Wolfram MathematicalFunctionData, StirlingS1

Two fixed points, sign ++

live ↗
InStirlingS1(2,2)\mathrm{StirlingS1}(2, 2)Out11

Known value · Wolfram MathematicalFunctionData, StirlingS1

Too many cycles

live ↗
InStirlingS1(2,3)\mathrm{StirlingS1}(2, 3)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

No arrangement into zero cycles

live ↗
InStirlingS1(3,0)\mathrm{StirlingS1}(3, 0)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

Two 3-cycles, positive sign since 3−13-1 is even

live ↗
InStirlingS1(3,1)\mathrm{StirlingS1}(3, 1)Out22

Known value · Wolfram MathematicalFunctionData, StirlingS1

Three permutations with one transposition, signed −-

live ↗
InStirlingS1(3,2)\mathrm{StirlingS1}(3, 2)Out−3-3

Known value · Wolfram MathematicalFunctionData, StirlingS1

k>nk>n gives 00

live ↗
InStirlingS1(3,4)\mathrm{StirlingS1}(3, 4)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

Zero for any n≥1n\ge1

live ↗
InStirlingS1(4,0)\mathrm{StirlingS1}(4, 0)Out00

Known value · Wolfram MathematicalFunctionData, StirlingS1

(−1)n−1(n−1)!(-1)^{n-1}(n-1)! at k=1k=1, here −3!-3!

live ↗
InStirlingS1(4,1)\mathrm{StirlingS1}(4, 1)Out−6-6

Known value · Wolfram MathematicalFunctionData, StirlingS1

Six transpositions in S4S_4, with sign −-

live ↗
InStirlingS1(4,3)\mathrm{StirlingS1}(4, 3)Out−6-6

Known value · Wolfram MathematicalFunctionData, StirlingS1

Possible issues #

The empty case s(0,0)=1s(0, 0) = 1 by convention, distinct from s(n,0)=0s(n, 0) = 0 for n>0n > 0

live ↗
InStirlingS1(0,0)\mathrm{StirlingS1}(0, 0)Out11

k>nk > n is 0

live ↗
InStirlingS1(5,6)\mathrm{StirlingS1}(5, 6)Out00
Neat examples #

s(n,1)=(−1)n−1(n−1)!s(n, 1) = (-1)^{n-1}(n-1)!, so s(10,1)=−9!s(10, 1) = -9!

live ↗
InStirlingS1(10,1)\mathrm{StirlingS1}(10, 1)Out−362 880-362\,880
About
Examples34
Checked againstWolfram Language 34 agreeCombinatorica 32 agree2 differSageMath 21 agree8 differ1 unevaluated3 errorSymPy 29 agree1 unevaluated2 errormpmath 29 agree1 errormathlib4 19 agree7 differ4 errorJulia 20 agree7 differ1 unevaluated2 error
CrosswalkWikipediaMathWorldWikidataDLMFFungrimFungrim entry ×2OEISWolfram LanguageCombinatoricaSageMathSymPympmathJulia

Implementation

mappedwolframpackages/oracle/src/mappings.ts

Signed in Wolfram and compute-engine; Sage's stirling_number1, Combinatorics.jl's stirlings1 and Mathlib's Nat.stirlingFirst are UNSIGNED, so a sign difference here is expected, not a bug. Combinatorics.jl's stirlings1 also needs n as a BigInt past its Int64 lookup table (n > 20).

mappedsagepackages/oracle/src/mappings.ts

Signed in Wolfram and compute-engine; Sage's stirling_number1, Combinatorics.jl's stirlings1 and Mathlib's Nat.stirlingFirst are UNSIGNED, so a sign difference there is expected, not a bug. Combinatorics.jl's stirlings1 also needs n as a BigInt past its Int64 lookup table (n > 20).

mappedjuliapackages/oracle/src/mappings.ts

Signed in Wolfram and compute-engine; Sage's stirling_number1, Combinatorics.jl's stirlings1 and Mathlib's Nat.stirlingFirst are UNSIGNED, so a sign difference here is expected, not a bug. Combinatorics.jl's stirlings1 also needs n as a BigInt past its Int64 lookup table (n > 20).

mappedmathlib4packages/oracle/src/mappings.ts

Signed in Wolfram and compute-engine; Sage's stirling_number1, Combinatorics.jl's stirlings1 and Mathlib's Nat.stirlingFirst are UNSIGNED, so a sign difference here is expected, not a bug. Combinatorics.jl's stirlings1 also needs n as a BigInt past its Int64 lookup table (n > 20).

mappedcombinatoricapackages/oracle/src/mappings.ts

Signed in Wolfram and compute-engine; Combinatorica's StirlingFirst, like Sage's stirling_number1, is UNSIGNED, so the template carries the sign (-1)^(n-k). Combinatorics.jl's stirlings1 and Mathlib's Nat.stirlingFirst are UNSIGNED too, so a sign difference there is expected, not a bug. Combinatorics.jl's stirlings1 also needs n as a BigInt past its Int64 lookup table (n > 20).

mappedsympypackages/oracle/src/mappings.ts

SymPy's stirling defaults to the second kind and unsigned; kind=1, signed=True is the signed first kind, as ours and Wolfram's.

mappedmpmathpackages/oracle/src/mappings.ts

Signed, as ours.

See also: Binomial, Stirling