$n$th derivative of $\sin(f(x))$

3.9k Views Asked by At

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!

3

There are 3 best solutions below

4
On
0
On

Micah has already referred you to Faà di Bruno's formula. Your comment suggests a difficulty understanding the coefficients. One way to look at it is this. Say you want $$ \frac{d^4}{dx^4} \cos(f(x)). $$ First solve the problem as if you were differentiating with respect to a different variable each time; then let the variables coalesce into just one variable and collect all the like terms. In order to do that, first understand that there are $15$ ways to partition a set of four things: $$ \begin{array}{c|l} 4321 & \text{1 part} \\ \hline 432/1 & \text{2 parts,} \qquad 3+1 \\ 431/2 \\ 421/3 \\ 321/4 \\ \hline 43/21 & \text{2 parts,} \qquad 2+2 \\ 42/31 \\ 41/32 \\ \hline 43/2/1 & \text{3 parts,} \qquad 2+1+1 \\ 42/3/1 \\ 41/3/2 \\ 32/1/4 \\ 31/2/4 \\ 21/4/3 \\ \hline 4/3/2/1 & \text{4 parts} \end{array} $$ Now we apply that: \begin{align} & \frac{\partial^4}{\partial x_4\,\partial x_3\,\partial x_2\,\partial x_1} \cos(f) \\[15pt] = {} & \cos'(f) \frac{\partial^4 f}{\partial x_4\,\partial x_3\,\partial x_2\,\partial x_1} & & {[}4{]} \\[15pt] & {} + \cos''(f) \left( \frac{\partial^3 f}{\partial x_4\,\partial x_3\,\partial x_2} \cdot \frac{\partial f}{\partial x_1} + \frac{\partial^3 f}{\partial x_4\,\partial x_3\,\partial x_1}\cdot \frac{\partial f}{\partial x_2} \right. & & {[}3+1{]} \\[5pt] & \phantom{mmmmmm} {} + \frac{\partial^3 f}{\partial x_4\,\partial x_2\,\partial x_1} \cdot \frac{\partial f}{\partial x_3} + \frac{\partial^3 f}{\partial x_3\,\partial x_2\,\partial x_1} \cdot \frac{\partial f}{\partial x_4} & & {[}3+1{]} \\[5pt] & \phantom{mmmmmm} {} + \frac{\partial^2 f}{\partial x_4\,\partial x_3} \cdot \frac{\partial^2 f}{\partial x_2\,\partial x_1} + \frac{\partial^2 f}{\partial x_4\,\partial x_2} \cdot \frac{\partial^2 f}{\partial x_3\,\partial x_1} & & {[}2+2{]} \\[5pt] & \phantom{mmmmmm} \left. {} + \frac{\partial^2 f}{\partial x_4\,\partial x_1} \cdot \frac{\partial^2 f}{\partial x_3\,\partial x_2} \right) & & {[}2+2{]} \\[15pt] & {} + \cos'''(f) \left( \frac{\partial^2 f}{\partial x_4\,\partial x_3} \cdot \frac{\partial f}{\partial x_2} \cdot \frac{\partial f}{\partial x_1} + \frac{\partial^2 f}{\partial x_4\,\partial x_2} \cdot \frac{\partial f}{\partial x_3} \cdot \frac{\partial f}{\partial x_1} \right. & & {[}2+1+1{]} \\[5pt] & \phantom{mmmmmm} {} + \frac{\partial^2 f}{\partial x_4\,\partial x_1} \cdot \frac{\partial f}{\partial x_3} \cdot \frac{\partial f}{\partial x_2} + \frac{\partial^2 f}{\partial x_3\,\partial x_2} \cdot \frac{\partial f}{\partial x_4} \cdot \frac{\partial f}{\partial x_1} & & {[}2+1+1{]} \\[5pt] & \phantom{mmmmmm} \left. {} + \frac{\partial^2 f}{\partial x_3\,\partial x_1} \cdot \frac{\partial f}{\partial x_4} \cdot \frac{\partial f}{\partial x_2} + \frac{\partial^2 f}{\partial x_2\,\partial x_1} \cdot \frac{\partial f}{\partial x_4} \cdot \frac{\partial f}{\partial x_3} \right) & & {[}2+1+1{]} \\[15pt] & {} + \cos''''(f) \left( \frac{\partial f}{\partial x_4} \cdot \frac{\partial f}{\partial x_3} \cdot \frac{\partial f}{\partial x_2} \cdot \frac{\partial f}{\partial x_1} \right) & & {[}1+1+1+1{]} \end{align} Finally, we let the four variables $x_4,x_3,x_2,x_1$ become indistinguishable and collect like terms: \begin{align} \frac{d^4}{dx^4} \cos(f) = {} & \cos'(f) \cdot \frac{d^4 f}{dx^4} + \cos''(f)\left( 4\cdot\frac{d^3 f}{dx^3}\cdot\frac{df}{dx} + 3\cdot\left(\frac{d^2 f}{dx^2} \right)^2 \right) \\[10pt] & {} + \cos'''(f) \left( 6 \cdot \frac{d^2 f}{dx^2} \cdot \left( \frac{df}{dx} \right)^2 \right) + \cos''''(f) \left( \frac{df}{dx} \right)^4. \end{align} That's where the coefficients $\underbrace{1,\,4,\,3,\,6,\,1}$ come from.

0
On

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)$.