The $n$th Bell polynomial $B_n(x ; g(t))$ is the coefficient of $t^n$ in the Taylor series of $e^{x g(t)}$ at $t=0$. We assume $g(0)=0$. The formula for the Taylor series gives:
$$
e^{x g(t)}=\sum_{k=0}^{\infty} B_n(x) \frac{t^n}{n !}
$$
$\square$ Example 1: $g(t)=t$ :
$$
\begin{aligned}
e^{x t} & =\sum_{k=0}^{\infty} x^n \frac{t^n}{n !} \\
B_n(x ; t) & =x^n
\end{aligned}
$$
$\square$ Example 2: $g(t)=\log (1+t)$ :
$$
\begin{aligned}
e^{x \log (1+t)} & =\sum_{k=0}^{\infty} x^{\underline{n}} \frac{t^n}{n !} \\
B_n(x ; \log (1+t)) & =x^{\underline{n}}
\end{aligned}
$$
The falling factorial $x^{\underline{n}}$ is defined as
$$
x^{\underline{n}}=\prod_{i=0}^{n-1}(x-i)=x(x-1) \ldots(x-n+1) .
$$
Write a package that implements the function $\operatorname{BellP}[n, x, g]$ to compute the Bell polynomial $B_n(x ; g)$.
The identity is a good way to test our function (Example 1).
Here are the falling factorials up to degree four. (Example 2).
Their construction becomes apparent in factored form.
$$
\begin{aligned}
& \operatorname{In}[1]:=\operatorname{BellP}[10, x, \text { Identity }] \\
& \text { Out }[1]=x^{10} \\
& \operatorname{In}[2]:=\operatorname{Table}[\operatorname{BellP}[i, x, \log [1+8] k],\{i, 0,4\}] \\
& \text { Out }[2]=\left\{1, x,-x+x^2, 2 x-3 x^2+x^3,\right. \\
&-6 x\left.+11 x^2-6 x^3+x^4\right\}
\end{aligned}
$$
$$
\begin{aligned}
& \operatorname{In}[3]:=\text { Factor }[\%] \\
& \text { Out }[3]=\{1, x,(-1+x) x,(-2+x)(-1+x) x, \\
& (-3+x)(-2+x)(-1+x) x\}
\end{aligned}
$$