$m$-th derivative of an $n$-times iterated function I'm trying to calculate multiple derivatives of iterated functions, but I'm already having trouble at the the thrid one, which is worrying, because I started with the ambition of calculating arbitrary numbers of derivatives of arbitrarily often iterated functions.
I defined iterated functions like this:
$$f_0(x)=x$$
$$f_1(x)=f(x)$$
$$f_n(x)=f(f_{n-1}(x))$$
I know it is usually written as $f^n(x)$, but since I have to write lots of derivatives like this $\frac{d^k}{dx^k}f(x)=f^{(k)}(x)$
I went for a subscript.
Then I started calculating and trying to spot the pattern. The first derivative was obvious pretty soon:
$$\frac{d}{dx}f_n(x)=\prod_{k=0}^{n-1}f^{(1)}(f_k(x))$$
Which is just the chain-rule used $n$ times.
But already at the second derivative, things got complicated pretty quickly. I ended up writing it like this:
$$\frac{d^2}{dx^2}f_n(x)=\sum_{i=0}^{n-1}\left[f^{(2)}\left(f_i(x)\right)
\prod_{j=0}^{i-1}f^{(1)}(f_j(x))\prod_{\substack{k=0\\k\neq i}}^{n-1}f^{(1)}(f_k(x))\right]$$
I obtained this by using the product rule on the first derivative.
$f^{(2)}\left(f_i(x)\right)\prod_{j=0}^{i-1}f^{(1)}(f_j(x))$ Is the derivative of the $i$-th factor of the first derivative. The remaining terms in the product are: $\prod_{\substack{k=0\\k\neq i}}^{n-1}f^{(1)}(f_k(x))$

The important part is that I never wanted sub- and superscripts mixed on one $f$.
Otherwise I could write the second derivative like this (leaving out the dependency upon $x$):
$$f_n^{(2)}=\sum_{i=0}^{n-1}\left[f^{(2)}\left(f_i\right)
f_i^{(1)}\frac{f^{(1)}_n}{f^{(1)}\left(f_i\right)}\right]$$

That's how far I got, but now I can't find a expression for even just the next derivative. I feel like I'm missing some sort of formalism for writing more and more stacked sums/products, but I'm not sure. The pattern is so nice, but it eludes me to put it into words or onto paper somehow.
I tried defining $f_n(x) = f_{n-1}\left(f(x)\right)$, but that made the derivatives even more horrible expressions to deal with.
Question: Is there a general formula for $\frac{d^m}{dx^m}f_n(x)$?
Or, if that is too much, just a way to get to $\frac{d^3}{dx^3}f_n(x)$ would be much appreciated.
 A: \begin{align}f_{n+1}'''(x)&=\frac{\mathrm d^3}{\mathrm dx^3}f_{n+1}(x)\\&=\frac{\mathrm d^3}{\mathrm dx^3}f(f_n(x))\\&=\frac{\mathrm d^2}{\mathrm dx^2}f_n'(x)f'(f_n(x))\\&=\frac{\mathrm d}{\mathrm dx}f_n''(x)f'(f_n(x))+f_n'(x)^2f''(f_n(x))\\&=f'''_n(x)f'(f_n(x))+3f_n''(x)f_n'(x)f''(f_n(x))+f_n'(x)^3f'''(f_n(x))\end{align}
Writing it out this way has the advantage of avoiding plugging in complicated expressions into the already complicated derivatives. As for putting this into a non-recursive form, let $f_n'''(x)=g_n(x)\prod_{k<n}f'(f_k(x))$ to get
$$g_{n+1}(x)=g_n(x)+\begin{bmatrix}3f_n''(x)f_n'(x)f''(f_n(x))\\+f_n'(x)^3f'''(f_n(x))\end{bmatrix}\prod_{k\le n}f'(f_k(x))^{-1}$$
$$g_n(x)=\sum_{i<n}\begin{bmatrix}3f_i''(x)f_i'(x)f''(f_i(x))\\+f_i'(x)^3f'''(f_i(x))\end{bmatrix}\prod_{k\le i}f'(f_k(x))^{-1}$$

$$f_n'''(x)=\sum_{i<n}\begin{bmatrix}3f_i''(x)f_i'(x)f''(f_i(x))\\+f_i'(x)^3f'''(f_i(x))\end{bmatrix}\prod_{i<k<n}f'(f_k(x))$$

Similar such formulas can be easily derived in the same manner for higher derivatives using $f_{n+1}=f\circ f_n$ using Faà di Bruno's formula, though it is extremely messy.
