$n$th derivative of $\sin(f(x))$ This problem came up in some math that I am working out on my own, not from a textbook, so there may not be any solution.
$$g(x) = \sin(f(x))$$
For any polynomial function $f(x)$,
$$g'(x)=\cos(f(x))f'(x)$$
$$g''(x)=-\sin(f(x))f'(x)^2+f''(x)\cos(f(x))$$
$$g'''(x)=-\cos(f(x))f'(x)^3-3\sin(f(x))f'(x)f''(x)+\cos(f(x))f'''(x) \\ \vdots$$
As you can see, each one is much more complex than the last, and takes much longer to evaluate than the last.
Is there pattern to find $g^{(n)}(x)$ without just brute-forcing it with the chain rule?
EDIT: To make the question more specific to my case, $f(x)$ is a polynomial function, and I only need to find $g^{(n)}(x)$ at $x=0$.
Thanks!
 A: You want Faà di Bruno's formula.
A: If you do not need the symbolic expression but only the Taylor coefficients at $x=0$, you can use Taylor arithmetic based on the differential equations of the sine and cosine (see automatic differentiation, autodiff.org for software). With $g(x)=\cos(f(x))$ and $h(x)=\sin(f(x))$ you get
$$
g'(x)=-h(x)·f'(x)\\
h'(x)=g(x)·f'(x)
$$
which allows coefficient computation by series multiplication rules. Let $f(x)=\sum a_jx^j$, $g(x)=\sum b_jx^j$ and $h(x)=\sum c_jx^j$, then at power $x^{n-1}$ you find
$$
nb_n=-\sum_{j=0}^{n-1}c_j·(n-j)a_{n-j}\\
nc_n=\sum_{j=0}^{n-1}b_j·(n-j)a_{n-j}
$$
which allows the coefficient evaluation in a double loop, initializing with $b_0=\cos(a_0)$ and $c_0=\sin(a_0)$.
A: You have the option of evaluating
$$f(x)-\frac{(f(x))^3}{3!}+\frac{(f(x))^5}{5!}-\cdots$$
where the power of the polynomials are obtained by the multinomial formula. This will lead you to a complicated double summation, but a general formula anyway.
The coefficients of the resulting polynomial give you the requested derivatives.
