How should I calculate the $n$th derivative of $f(x)=x^x$?

This approach follows an example (p. 139) of Advanced Combinatorics by L. Comtet. The elaboration here differs in minor aspects and is sometimes more detailed which was helpful to verify the example.

Taylor series (part one):

The idea for this formula of the $n$-th derivative of $x^x$ with $x>0$ is based upon a clever Taylor series expansion.

Recall a Taylor series expansion of a function $f(t)$ at a point $x$ is, assuming $f$ is sufficiently often differentiable \begin{align*} f(t)=\sum_{j=0}^\infty \frac{D_x^jf(x)}{j!}(t-x)^j \end{align*}

Here we use the differential operator $D_x^j:=\frac{d^j}{dx^j}$ and we will also use the coefficient of operator $[x^k]$ to denote the coefficient of $x^k$ in a series.

Since \begin{align*} f(t+x)=\sum_{j=0}^\infty D_x^jf(x)\frac{t^j}{j!}\tag{1} \end{align*}

we can describe the $n$-th derivative of a function $f$ at a point $x$ as \begin{align*} D_x^nf(x)=n![t^n]f(t+x)\tag{2} \end{align*}

Setting $f(x)=x^x, x>0$ we start according to the LHS of (1) with \begin{align*} f(x+t)=(x+t)^{x+t} \end{align*} and obtain with some elementary transformations and series expansion of the exponential function \begin{align*} f(x+t)&=(x+t)^{x+t}\\ &=\exp({(x+t)\ln(x+t)})\\ &=\exp\left({(x+t)\left(\ln(x)+\ln\left(1+\frac{t}{x}\right)\right)}\right)\\ &=x^x\exp\left({t\ln(x)}\right)\exp\left({x\left(1+\frac{t}{x}\right)\ln\left(1+\frac{t}{x}\right)}\right)\\ &=x^x\left(\sum_{i=0}^\infty\frac{\left(t\ln(x)\right)^i}{i!}\right) \left(\sum_{j=0}^\infty\frac{\left(\left(1+\frac{t}{x}\right)\ln\left(1+\frac{t}{x}\right)\right)^j}{j!}x^j\right)\tag{3}\\ \end{align*}

In order to calculate the Taylor series expansion of the RHS of (1) we need to expand (3) in powers of $t$. We use the Ansatz \begin{align*} \frac{1}{j!}\left(\left(1+\frac{t}{x}\right)\ln\left(1+\frac{t}{x}\right)\right)^j =\sum_{k=j}^\infty b_{k,j}\frac{\left(\frac{t}{x}\right)^k}{k!}\qquad\text{and}\qquad b_{0,0}=1 \end{align*} Note that since the series expansion of the logarithm has no constant term we start the series expansion with $\left(\frac{t}{x}\right)^j$, resp. with index $k=j$.

Recurrence relation: $b_{k,j}$

In order to determine $b_{k,j}$ we develop a recurrence relation. We set \begin{align*} B_j(z):=\frac{1}{j!}\left(\left(1+z)\ln(1+z\right)\right)^j=\sum_{k=j}^\infty b_{k,j}\frac{z^k}{k!}\quad\qquad (j\geq 0)\tag{4} \end{align*}

Differentiating the LHS gives \begin{align*} D_zB_j(z)&=\frac{1}{(j-1)!}\left((1+z)\ln(1+z)^{j-1}\right)(1+\ln(1+z))\\ &=B_{j-1}(z)+\frac{j}{1+z}B_j(z) \end{align*}

Differentiating the RHS gives \begin{align*} D_zB_j(z)=\sum_{k=j}^\infty b_{k,j}\frac{z^{k-1}}{(k-1)!} \end{align*}

Equating both sides and multiplying with $1+z$ gives \begin{align*} (1+z)\sum_{k=j}^\infty b_{k,j}\frac{z^{k-1}}{(k-1)!}&=(1+z)B_{j-1}(z)+jB_j(z)\\ &=(1+z)\sum_{k=j-1}^\infty b_{k,j-1}\frac{z^{k}}{k!}+j\sum_{k=j}^\infty b_{k,j}\frac{z^{k}}{k!} \end{align*} Comparing coefficients by calculating $\frac{1}{n!}[z^n]$ gives \begin{align*} b_{n+1,j}+nb_{n,j}=b_{n,j-1}+nb_{n-1,j-1}+jb_{n,j} \end{align*}

Collecting equal terms we finally get \begin{align*} b_{n+1,j}=(j-n)b_{n,j}+b_{n,j-1}+nb_{n-1,j-1}\qquad\qquad n,j\geq 1\tag{5} \end{align*} Since initial values can be easily calculated from (4) we get the following table for $b_{n,j}$

\begin{array}{c|cccccc} n\setminus k&1&2&3&4&5&6\\ \hline 1&1\\ 2&1&1\\ 3&-1&3&1\\ 4&2&-1&6&1\\ 5&-6&0&5&10&1\\ 6&24&4&-15&25&15&1\\ \end{array}

Note: These values can be found in OEIS as A008296. They are called Lehmer-Comtet numbers and were stored in the archive by N.J.A.Sloane by referring precisely to the example we can see here.

Taylor series (part two):

We are now ready to expand (3) further and obtain using (4) \begin{align*} f(x+t)&=(x+t)^{x+t}\\ &=x^x\left(\sum_{i=0}^\infty\frac{\left(t\ln(x)\right)^i}{i!}\right) \left(\sum_{j=0}^\infty\frac{\left(\left(1+\frac{t}{x}\right)\ln\left(1+\frac{t}{x}\right)\right)^j}{j!}x^j\right)\\ &=x^x\left(\sum_{i=0}^\infty\frac{\left(t\ln(x)\right)^i}{i!}\right) \left(\sum_{j=0}^\infty\sum_{k=j}^\infty b_{k,j}\frac{\left(\frac{t}{x}\right)^k}{k!}x^j\right)\tag{6}\\ &=x^x\left(\sum_{i=0}^\infty\frac{\left(t\ln(x)\right)^i}{i!}\right) \left(\sum_{k=0}^\infty\sum_{j=0}^k b_{k,j}x^j\frac{\left(\frac{t}{x}\right)^k}{k!}\right)\tag{7}\\ &=x^x\sum_{l=0}^\infty\left( \sum_{{i+k=l}\atop{i,k\geq 0}}\frac{\left(\ln(x)\right)^i}{i!}\cdot\frac{1}{k!}\sum_{j=0}^kb_{k,j}x^{j-k}\right)t^l\tag{8}\\ &=x^x\sum_{l=0}^\infty\left(\sum_{i=0}^l\binom{l}{i}\left(\ln(x)\right)^i\sum_{j=0}^{l-i}b_{l-i,j}x^{j-l+i}\right)\frac{t^l}{l!}\tag{9}\\ &=x^x\sum_{l=0}^\infty\left(\sum_{i=0}^l\binom{l}{i}\left(\ln(x)\right)^i\sum_{j=0}^{l-i}b_{l-i,l-i-j}x^{-j}\right)\frac{t^l}{l!}\tag{10}\\ \end{align*}

Comment:

  • In (6) we use the representation (4).

  • In (7) we exchange in the right hand double series the indices $k$ and $j$ respecting $0\leq j\leq k<\infty$.

  • In (8) we introduce the index $l$ to collect the terms according to powers of $t$.

  • In (9) we write the series in $t$ as exponential generating series by introducing $\binom{l}{i}$.

  • In (10) we exchange the order of the elements of the rightmost sum by letting $j\rightarrow l-i-j$.

$n$-th derivative of $x^x$:

Now it's time to harvest. We obtain the $n$-th derivative of $f(x)=x^x$ from (2) and (10).

The $n$-th derivative of $x^x$ is

\begin{align*} D_x^n x^x=x^x\sum_{i=0}^n\binom{n}{i}(\ln(x))^i\sum_{j=0}^{n-i}b_{n-i,n-i-j}x^{-j}\tag{11} \end{align*} with $b_{n,j}$ the Lehmer-Comtet numbers given in (5).

Example: $n=2$

Let's look at a small example. Letting $n=2$ we obtain from (11) and the table with $b_{n,j}$: \begin{align*} D_x^2x^x&=x^x\sum_{i=0}^2\binom{2}{i}(\ln(x))^i\sum_{j=0}^{2-i}b_{2-i,2-i-j}x^{-j}\\ &=x^x\left(\binom{2}{0}\sum_{j=0}^2b_{2,2-j}x^{-j}+\binom{2}{1}\ln(x)\sum_{j=0}^1b_{1,1-j}x^{-j}\right.\\ &\qquad\qquad\left.+\binom{2}{2}\left(\ln(x)\right)^2\sum_{j=0}^0b_{0,0-j}x^{-j}\right)\\ &=x^x\left(\left(b_{2,2}+b_{2,1}\frac{1}{x}+b_{2,0}\frac{1}{x^2}\right)+2\ln(x)\left(b_{1,1}+b_{1,0}\frac{1}{x}\right) +(\ln(x))^2b_{0,0}\right)\\ &=x^x\left(1+\frac{1}{x}+2\ln(x)+\left(\ln(x)\right)^2\right) \end{align*} in accordance with the result of Wolfram Alpha.