<s>[INST] Finding a closed formula for calculating $\frac{d^n}{{dx}^n}f\left(x\right)=\frac{d^n}{{dx}^n}e^{x^2}$ For reasons I can't even remember, the other day I wanted to find out if there was a closed formula for calculating the $n$-th derivative $\frac{d^n}{{dx}^n}f\left(x\right)=\frac{d^n}{{dx}^n}e^{x^2}$ for the function $f\left(x\right)=e^{x^2}$. Where I ended up after some trial and error is the formula $$\frac{d^n}{{dx}^n}e^{x^2}=c_n\left(\sum_{0 \leq i \leq \lfloor\frac{n}{2}\rfloor} {p_i x^{n-2i}}\right)e^{x^2}=c_n\left(c_{n-1}x^n + \sum_{1 \leq i \leq \lfloor\frac{n}{2}\rfloor} {p_i x^{n-2i}}\right)e^{x^2},$$ with $c_n=2^{n-\lfloor\frac{n}{2}\rfloor}$.
The $p_{i \geq1}$ turn out to be as follows:




$n$
$p_{i=1}$
$p_{i=2}$
$p_{i=3}$
$p_{i=4}$
$...$




0
–
–
–
–
$...$


1
–
–
–
–
$...$


2
1
–
–
–
$...$


3
3
–
–
–
$...$


4
12
3
–
–
$...$


5
20
15
–
–
$...$


6
60
90
15
–
$...$


7
84
210
105
–
$...$


8
224
840
840
105
$...$


9
288
1512
2520
945
$...$


$...$
$...$
$...$
$...$
$...$
$...$




I have not yet understood the rule behind the $p_i$ sequences $$p_{i=1}:\left(1,3,12,20,60,84,224,288,...\right),$$
$$p_{i=2}:\left(3,15,90,210,840,1512,...\right),$$
$$p_{i=3}:\left(15,105,840,2520,...\right),$$
$$p_{i=4}:\left(105,945,...\right),$$
$$...$$ I suspect it has something to do with binomial coefficients, since the coefficients $p_i$ arise from multiplying binomials during the derivation. One regularity I've noticed so far is that starting at $p_{i=2}$, the first values always correspond to the second ones of the previous $p$ sequence.
Do any of you have an idea how I can formalize the coefficients $p_i$ and the timing of their occurrence and integrate them into the above closed formula? Or do you know if there even already exists a known solution to the problem, namely finding a closed formula to calculate the $n$-th derivative $\frac{d^n}{{dx}^n}f\left(x\right)=\frac{d^n}{{dx}^n}e^{x^2}$?
Thank you and best regards!
 [/INST] Hint: Using Wolfram Alpha we find for small values of $n$
\begin{align*}
\frac{d}{dx}e^{x^2}&=2x^2e^{x^{2}}\\
\frac{d^2}{dx^2}e^{x^2}&=2\left(2x^2+1\right)e^{x^{2}}\\
\frac{d^3}{dx^3}e^{x^2}&=4\left(2x^3+3x\right)e^{x^{2}}\tag{1}\\
\frac{d^4}{dx^4}e^{x^2}&=4\left(4x^4+12x^2+3\right)e^{x^{2}}\\
\end{align*}
Another expression besides Faa di Brunos formula is stated as identity (3.56) in H.W. Gould's Tables of Combinatorial Identities, Vol. I and called:

Hoppe Form of Generalized Chain Rule
Let $D_x$ represent differentiation with respect to $x$ and $y=y(x)$. Hence $D^n_x g(y)$ is the $n$-th derivative of $g$ with respect to $x$. The following holds true
\begin{align*}
D_x^n g(y)=\sum_{k=0}^nD_y^kg(y)\frac{(-1)^k}{k!}\sum_{j=0}^k(-1)^j\binom{k}{j}y^{k-j}D_x^ny^j
\end{align*}

In the special case
\begin{align*}
g(y(x))=e^{y(x)}=e^{x^{2}}
\end{align*}
we have $$D_y^kg(y)=D_y^k e^y=e^y$$ and obtain
\begin{align*}
D_x^ne^y=e^y\sum_{k=0}^n\frac{(-1)^k}{k!}\sum_{j=0}^k(-1)^j\binom{k}{j}y^{k-j}D_x^ny^j\tag{2}
\end{align*}

With $y=y(x)=x^2$ we obtain from (2)
\begin{align*}
\color{blue}{D_x^ne^{x^2}}&=e^{x^2}\sum_{k=0}^n\frac{(-1)^k}{k!}\sum_{j=0}^k(-1)^j\binom{k}{j}x^{2(k-j)}D_x^nx^{2j}\tag{3.1}\\
&=e^{x^2}\sum_{k=\left\lfloor\frac{n+1}{2}\right\rfloor}^n\frac{(-1)^k}{k!}\sum_{j=\left\lfloor\frac{n+1}{2}\right\rfloor}^k(-1)^j\binom{k}{j}x^{2(k-j)}D_x^nx^{2j}\tag{3.2}\\
&\,\,\color{blue}{=e^{x^2}\sum_{k=\left\lfloor\frac{n+1}{2}\right\rfloor}^n\frac{(-1)^k}{k!}\sum_{j=\left\lfloor\frac{n+1}{2}\right\rfloor}^k(-1)^j\binom{k}{j}(2j)^{\underline{n}}x^{2k-n}}\tag{3.3}\\
\end{align*}

Comment:

*

*In (3.1) we apply Hoppe's formula with $y=y(x)=x^2$.


*In (3.2) we observe that we differentiate $x^{2j}$ $n$ times. This implies that terms with indices $k,j< \left\lfloor\frac{n+1}{2}\right\rfloor$ vanish.


*In (3.3) we calculate $D_x^nx^{2j}$ using the falling factorial notation $(2j)^{\underline{n}}=(2j)(2j-1)\cdots(2j-n+1)$.

Let's look at a small example in order to see formula (3.3) in action.
Example: $n=3$ We obtain
\begin{align*}
e^{x^2}&\sum_{k=2}^{3}\frac{(-1)^k}{k!}\sum_{j=2}^k(-1)^j\binom{k}{j}(2j)(2j-1)(2j-2)x^{2k-3}\\
&=4e^{x^2}\sum_{k=2}^{3}\frac{(-1)^k}{k!}\sum_{j=2}^k(-1)^j\binom{k}{j}j(j-1)(2j-1)x^{2k-3}\\
&=4e^{x^2}\left(\frac{1}{2}\left(\sum_{j=2}^2(-1)^j\binom{2}{j}j(j-1)(2j-1)\right)\right)x\\
&\qquad+4e^{x^2}\left(\frac{(-1)}{6}\left(\sum_{j=2}^3(-1)^j\binom{3}{j}j(j-1)(2j-1)\right)\right)x^3\\
&=4e^{x^2}\left(\frac{1}{2}\binom{2}{2}\cdot 6\right)x
+4e^{x^2}\left(-\frac{1}{6}\binom{3}{2}\cdot 6+\frac{1}{6}\binom{3}{3}\cdot 30\right)x^3\\
&\,\,\color{blue}{=4e^{x^2}\left(2x^3+3x\right)}
\end{align*}
in accordance with (1).

</s>