BellY
Details
- Mathematical function, suitable for both symbolic and numeric manipulations.
- The partial Bell polynomial can be used to express the

derivative of a composition of two functions through the Faà di Bruno formula
. » - The BellY polynomial
is given by
⋯
Boole[m1+2 m2+⋯+n mnn∧m1+m2+⋯+mnk]
(xs/s!)ms. » - The generalized Bell polynomial can be used to express the

derivative of a composition of
functions
. - BellY[n,k,m] is equivalent to BellY[
] where
is formed by prepending UnitVector[n,k] to m as a first column. »
Background & Context
- BellY returns the partial Bell polynomial
of given variables
or of a given matrix
having
rows, or the generalized Bell polynomial
of any matrix
. Here,
, where the sum is over all sequences
of non-negative integers satisfying
and
. This allows the partial Bell polynomial
to encode how a set of 
objects can be partitioned into
nonempty subsets
by summing together terms of the form 
, which indicates there are
ways to partition the set of
objects into
subsets each of size
,
subsets each of size
, etc. (so
and
necessarily). For instance,
indicates that when partitioning a set of 6 objects into 2 nonempty subsets, there are 10 partitions consisting of 2 subsets each of size 3, 15 partitions consisting of 1 subset of size 2 and 1 subset of size 4, and 6 partitions consisting of 1 subset of size 1 and 1 subset of size 5. - Faà di Bruno's formula for generalizing the chain rule of differential calculus to express the

derivative of a composition of two functions is given in terms of the partial Bell polynomial by
. The chain rule can be further generalized to express the 
derivative of a composition of
functions using the generalized Bell polynomial
, defined to be the unique function satisfying
(for example,
by the ordinary chain rule). The generalized partial Bell polynomial
is defined in terms of the generalized Bell polynomial
by
so that the generalized version of Faà di Bruno's formula given by
holds. - Several famed integer sequences can be obtained by applying the partial Bell polynomial
to particular arguments. Letting
and
denote Stirling numbers of the first kind and second kind, respectively, given by StirlingS1 and StirlingS2, gives
and
. Furthermore, letting
and
respectively denote the 
Bell polynomial and 
Bell number, both given by BellB, gives
and
.
Examples
open all close allBasic Examples (3)
BellY[4, 2, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}]Generalized partial Bell polynomial:
BellY[4, 2, {{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, {Subscript[y, 1], Subscript[y, 2], Subscript[y, 3]}}]BellY[{{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, {Subscript[y, 1], Subscript[y, 2], Subscript[y, 3]}, {Subscript[z, 1], Subscript[z, 2], Subscript[z, 3]}}]Applications (13)
Calculus (3)
The generalized chain rule allows one to directly compute the ![]()
derivative of
using BellY:
. Verify this with symbolic
and
for low orders of
:
GeneralizedChainRule[{f_, g_}, {x_, n_}] :=
Sum[Derivative[k][f][g[x]]BellY[n, k, Table[D[g[x], {x, i}], {i, n - k + 1}]], {k, n}]For
, this becomes the normal chain rule:
GeneralizedChainRule[{f, g}, {x, 1}]D[f[g[x]], x]For
, this is also known as Faà di Bruno's formula:
D[f[g[x]], {x, 2}]GeneralizedChainRule[{f, g}, {x, 2}]D[f[g[x]], {x, 3}]GeneralizedChainRule[{f, g}, {x, 3}]From the formula, it can be directly seen that the derivative is linear in
with coefficients that are polynomial in
, where
is the polynomial coefficient of
. Define a typesetting rule that makes this relation obvious by paneling the Bell coefficients:
pnl[e_Plus, col_] := Panel[Row[{"(", e, ")"}], Background -> col];
pnl[e_, col_] := Panel[e, Background -> col];
ChainRuleTypeset[{f_, g_}, {x_, n_}] := Row[Table[Row[{pnl[BellY[n, k, Table[D[g[x], {x, i}], {i, n - k + 1}]], StandardBlue], pnl[Derivative[k][f][g[x]], StandardOrange]}, " "], {k, n}], "+"]A few of the first derivatives:
ChainRuleTypeset[{f, g}, {x, 2}]ChainRuleTypeset[{f, g}, {x, 3}]ChainRuleTypeset[{f, g}, {x, 4}]ChainRuleTypeset[{f, g}, {x, 5}]Compute fourth-order derivatives of the Gamma function using the BellY polynomial:
Gamma[n]BellY[Table[{1, PolyGamma[k - 1, n]}, {k, 4}]]//ExpandCompare with the explicit evaluation of the derivative:
D[Gamma[n], {n, 4}]Compute the series of an inverse function:
n = 4;
(x/C[1]) + Underoverscript[∑, j = 2, n](x^j/C[1]^jj!)BellY[Table[{Pochhammer[j, k - 1], -(k - 1)! (C[k]/C[1])}, {k, 2, j}]] + O[x]^n + 1//SimplifyCompare with the result of InverseSeries:
InverseSeries[Underoverscript[∑, j = 1, n]C[j]x^j + O[x]^n + 1]//SimplifyCombinatorics (6)
Compute Stirling numbers of the first kind in terms of the partial Bell polynomials:
Table[BellY[n, k, Table[(-1)^jj!, {j, 0, n}]], {n, 0, 5}, {k, 0, n}]Table[StirlingS1[n, k], {n, 0, 5}, {k, 0, n}]Compute Stirling numbers of the second kind in terms of the partial Bell polynomials:
Table[BellY[n, k, ConstantArray[1, n]], {n, 0, 5}, {k, 0, n}]Table[StirlingS2[n, k], {n, 0, 5}, {k, 0, n}]Compute Bell numbers using generalized Bell polynomials:
Table[BellY[ConstantArray[1, {n, 2}]], {n, 10}]Table[BellB[n], {n, 10}]Compute Bell polynomials BellB[n,z] using generalized Bell polynomials:
Table[BellY[ConstantArray[{1, z}, n]], {n, 5}]Table[BellB[n, z], {n, 5}]Compute Catalan numbers using generalized Bell polynomials:
Table[BellY[Transpose[{1 / Range[n, 1, -1]!, Range[n]!}]], {n, 10}]Table[CatalanNumber[n], {n, 10}]Number of
-level labeled rooted trees with
leaves:
Table[BellY[ConstantArray[1, {n, n}]], {n, 1, 10}]Compare with an alternative formula:
sm = Table[StirlingS2[s, t], {s, 10}, {t, 10}];Table[MatrixPower[sm, n][[n, 1]], {n, 10}]The cycle index polynomial of the symmetric group of degree n:
n = 5;
vars = Table[Subscript[x, k], {k, n}];
BellY[Transpose[{ConstantArray[(1/n!), n], Range[0, n - 1]!vars}]]Compare with the result of CycleIndexPolynomial:
CycleIndexPolynomial[SymmetricGroup[n], vars]The cycle index polynomial of the alternating group of degree n:
BellY[Transpose[{Table[(1 + (-1)^n + k/n!), {k, n}], Range[0, n - 1]!vars}]]Compare with the result of CycleIndexPolynomial:
CycleIndexPolynomial[AlternatingGroup[n], vars]Find the number of ways to partition a set of 6 elements into two subsets from a partial Bell polynomial:
BellY[6, 2, Array[x, 6]]Check by explicit recursive generation of set partitions:
AdjoinElement[s_, el_] := Table[Sequence@@Join[Table[Insert[o, el, {k, -1}], {k, Length[o]}], {Insert[o, {el}, -1]}], {o, s}]SetPartitions[{}] := {{}};
SetPartitions[s_List] := AdjoinElement[SetPartitions[Most[s]], Last[s]]There are 10 ways to partition a set of 6 elements into two subsets of 3+3 elements:
Count[SetPartitions[Range[6]], x_ /; Sort[Length /@ x] == {3, 3}]There are 15 ways to partition a set of 6 elements into two subsets of 4+2 elements:
Count[SetPartitions[Range[6]], x_ /; Sort[Length /@ x] == {2, 4}]There are 6 ways to partition a set of 6 elements into two subsets of 5+1 elements:
Count[SetPartitions[Range[6]], x_ /; Sort[Length /@ x] == {1, 5}]Other Applications (4)
Define the complete Bell polynomial of n variables:
bellComplete[vars__] := With[{tmp = {vars}}, BellY[Transpose[{ConstantArray[1, Length[tmp]], tmp}]]]Show the first few complete Bell polynomials:
{bellComplete[x], bellComplete[x, y], bellComplete[x, y, z], bellComplete[x, y, z, w]}//ColumnCompute the third raw moment in terms of cumulants:
BellY[Table[{1, Cumulant[k]}, {k, 3}]]MomentConvert[Moment[3], "Cumulant"]Compute the third cumulant in terms of raw moments:
BellY[Table[{(-1)^k - 1(k - 1)!, Moment[k]}, {k, 3}]]MomentConvert[Cumulant[3], "Moment"]Construct polynomial sequences of binomial type:
p[n_Integer ? NonNegative, x_] := Sum[BellY[n, k, Array[a, n]]x ^ k, {k, 0, n}]Verify their defining identity:
Table[p[n, x + y] == Sum[Binomial[n, k]p[k, x]p[n - k, y], {k, 0, n}]//Simplify, {n, 0, 10}]Recover BellB[n,z] as a special case:
Table[p[n, z], {n, 5}] /. a[_] -> 1Table[BellB[n, z], {n, 5}]The n
elementary symmetric polynomial can be defined in terms of BellY:
ee[n_, vars_] := BellY[Table[{(1/n!), (-1)^k - 1(k - 1)!Total[vars^k]}, {k, n}]]Compare with SymmetricPolynomial for the case of five variables:
Table[ee[k, {x, y, z, u, v}] == SymmetricPolynomial[k, {x, y, z, u, v}]//Simplify, {k, 5}]Properties & Relations (6)
Compute a partial Bell polynomial using its sum representation:
With[{n = 7, k = 2},
Sum[n!Apply[Times, ((Array[, n]/Range[n]!))^m(1/m!)], {m, FrobeniusSolve[Range[n], n]⋂FrobeniusSolve[ConstantArray[1, n], k]}]]Compare with BellY:
With[{n = 7, k = 2}, BellY[n, k, Array[, n]]]Compute a partial Bell polynomial using Cvijović's iterated sum formula:
With[{n = 7, k = 2},
Sum[(Binomial[n, i[1]]/k!)[n - i[1]][i[k - 1]]Underoverscript[∏, r = 1, k - 2]Binomial[i[r], i[r + 1]][i[r] - i[r + 1]], Evaluate[Sequence@@Prepend[Table[{i[r + 1], k - r - 1, i[r] - 1}, {r, k - 2}], {i[1], k - 1, n - 1}]]]]Compare with BellY:
With[{n = 7, k = 2}, BellY[n, k, Array[, n]]]A linear combination of partial Bell polynomials:
n = 5;
Sum[C[k]BellY[n, k, Table[[k], {k, n}]], {k, n}]The equivalent expression in terms of the generalized Bell polynomial:
BellY[Table[{C[k], [k]}, {k, n}]]%% == %//SimplifyA generalized partial Bell polynomial of a matrix:
n = 4;k = 3;
mat = (| | |
| ------- | ------- |
| [1, 1] | [1, 2] |
| [2, 1] | [2, 2] |
| [3, 1] | [3, 2] |
| [4, 1] | [4, 2] |);
BellY[n, k, mat]This can be computed in terms of the generalized Bell polynomial by prepending a unit vector as a column:
BellY[Join[Transpose[{UnitVector[n, k]}], mat, 2]]A linear combination of generalized partial Bell polynomials of a matrix can be expressed as a generalized Bell polynomial by prepending the column of coefficients to the matrix:
Sum[C[k]BellY[n, k, mat], {k, n}] == BellY[Join[Transpose[{Table[C[k], {k, n}]}], mat, 2]]//SimplifyFaà di Bruno's formula for the third derivative of
:
Sum[Derivative[k][f][g[z]] BellY[3, k, {Derivative[1][g][z], Derivative[2][g][z], Derivative[3][g][z]}], {k, 1, 3}]BellY[{{Derivative[1][f][g[z]], Derivative[1][g][z]}, {Derivative[2][f][g[z]], Derivative[2][g][z]}, {Derivative[3][f][g[z]], Derivative[3][g][z]}}]D[f[g[z]], {z, 3}]Demonstrate an inversion relation for generalized Bell polynomials:
n = 5;
yk = Table[BellY[Table[{1, [j]}, {j, k}]], {k, n}]Table[BellY[Table[{(-1)^j - 1(j - 1)!, Subscript[yk, [[j]]]}, {j, k}]], {k, n}]//SimplifyNeat Examples (2)
Generate Bernoulli numbers using a generalized Bell polynomial:
SeriesCoefficient[(Exp[t] - 1/t), {t, 0, r}, Assumptions -> r ≥ 0]r!SeriesCoefficient[u^-1, {u, 1, r}, Assumptions -> r ≥ 0]r!Table[BellY[Table[{%, %%}, {r, n}]], {n, 20}]Table[BernoulliB[n], {n, 20}]Generate Euler numbers using a generalized Bell polynomial:
SeriesCoefficient[Cosh[t], {t, 0, r}, Assumptions -> r ≥ 0]r!//SimplifySeriesCoefficient[u^-1, {u, 1, r}, Assumptions -> r ≥ 0]r!Table[BellY[Table[{%, %%}, {r, n}]], {n, 20}]Table[EulerE[n], {n, 20}]See Also
Related Guides
History
Text
Wolfram Research (2010), BellY, Wolfram Language function, https://reference.wolfram.com/language/ref/BellY.html.
CMS
Wolfram Language. 2010. "BellY." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BellY.html.
APA
Wolfram Language. (2010). BellY. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BellY.html
BibTeX
@misc{reference.wolfram_2026_belly, author="Wolfram Research", title="{BellY}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/BellY.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_belly, organization={Wolfram Research}, title={BellY}, year={2010}, url={https://reference.wolfram.com/language/ref/BellY.html}, note=[Accessed: 13-June-2026]}