<s>[INST] How does one treat big O when Taylor expanding $\sin(\sin x)$? I am working on finding the Taylor (Maclaurin expansion) of $\sin(\sin(x))$ to the third order.
We have $$\sin{t} = t - \frac{t^3}{6} + \mathcal{O}(t^5)$$
If I then set $t = \sin(x)$, and expand once more, I end up with a big O which is
$$\mathcal{O}((x - \frac{x^3}{6} + \mathcal{O}(x^5))^5)$$
How does one treat this mathematically? How do I know which order the error will be in my final expansion?
 [/INST] Expanding only the terms to the third order, $$\sin(\sin x)\\
 =  x - \frac{x^3}{6} + \mathcal{O}(x^5) - \frac{x^3\left(1 - \dfrac{x^2}{6} + \mathcal{O}(x^4)\right)^3}{6} + \mathcal{O}\left(x^5\left(1- \frac{x^2}{6} + \mathcal{O}(x^4)\right)^5\right)\\
=x-\frac{x^3}{6}-\frac{x^3}6+\mathcal O(x^5).$$

Check:
Using the chain rule,
$$\frac{df}{dx}=\cos t\cos x\to1$$
$$\frac{d^2f}{dx^2}=-\sin t\cos^2x-\cos t\sin x\to0$$
$$\frac{d^3f}{dx^3}=-\cos t\cos^3x+2\sin t\cos x\sin x+\sin t\sin^2 x-\cos t\cos x\to-2.$$
</s>