# Calculating higher order derivative of a power of a function

I asked a related question, and I am placing this separately to make keep it focused.

Let a function $$f(x)$$ and it's derivatives $$\left(\partial /\partial x\right)^k f(x) = f^{(k)}(x)$$

What is a good explicit, systematic, way to express

$$\left(\frac \partial {\partial x}\right)^n \left( f(x) \right)^N$$

As it happens, the product rule obeys something similar to the multinomial theorem. That is, if you have a product of $$N$$ functions $$f_i$$ differentiated $$n$$ times, the result is $$\frac{d^n}{dx^n}\left[\prod_{i=1}^N f_i(x)\right] = \sum_{\sum k_i = n}\binom{n}{k_1 ... k_N}\prod_{i = 1}^Nf_i^{(k_i)}(x) = n!\sum_{\sum k_i = n}\prod_{i = 1}^N\frac{f_i^{(k_i)}(x)}{k_i!}.$$ If all the $$f_i$$ are the same function, this just becomes $$\frac{d^n}{dx^n}\left[f_i(x)^N\right] = \sum_{\sum k_i = n}\binom{n}{k_1 ... k_N}\prod_{i = 1}^Nf^{(k_i)}(x) = n!\sum_{\sum k_i = n}\prod_{i = 1}^N\frac{f^{(k_i)}(x)}{k_i!}.$$ Now some of those terms in the sum are repeats. For example, if $$N = 3$$ and $$n = 5$$, then $$k_i = \{2, 1, 2\}$$ and $$k_i = \{1, 2, 2\}$$ are both going to have $$f''(x)^2f'(x)$$. If that's not a problem for you, we can stop here. On the other hand, if we want to combine like terms, we can do this with an application of the actual multinomial theorem to the powers of the derivatives. Each term of the sum has the form $$\prod_{i = 0}^nf^{(i)}(x)^{p_i}\;\;\;\;;\;\;\;\; \sum_{i= 0}^np_i = N\,,\, \sum_{i = 0}^n ip_i = n$$ Let $$k$$ be a multiset of integers that consists of each $$i$$ repeated $$p_i$$ times. Since $$\sum_i i p_i = n$$, this will have size $$n$$. Then the coefficient of terms of the above form is $$\binom{n}{k_1...k_n}\binom{N}{p_0...p_N} = \frac{n!N!}{\prod_{i=0}^{n}(p_i!)(i!)^{p_i}}$$ So we have $$\frac{d^n}{dx^n}\left[f(x)^N\right] = \sum_{\sum p_i =N,\,\sum ip_i = n}\frac{n!N!}{p_i!(i!)^{p_i}}\prod_{i = 0}^nf^{(i)}(x)^{p_i}.$$ That sum condition may be able to be simplified, but I haven't thought of a way yet.
• Tahnk you for your answer, are you sure you are not swapping $n$ and $N$, in $\sum p_i = N$ and $\sum i p_i = n$, I am interested in in the case $n < N$. Also, the sum over partitions is not trivial to implement (since I will code this in python). I think this could be calculated recursively, eliminating the factorials.