TITLE: An almost impossible limit
QUESTION [12 upvotes]: The following limit appeared in a qualification exam: Find the limit of
$$\lim_{x \to 0} \left( \frac{\tan (\sin (x))-\sin (\tan (x))}{x^7} \right).$$
I ended up doing it in Mathematica, is there any other way?
Thanks in advance!

REPLY [12 votes]: Claim: Suppose for some integer $n\gt1$,
$$
f(x)=x+a_nx^n+a_{2n-1}x^{2n-1}+a_{3n-2}x^{3n-2}+o\left(x^{3n-2}\right)
$$
and
$$
g(x)=x+b_nx^n+b_{2n-1}x^{2n-1}+b_{3n-2}x^{3n-2}+o\left(x^{3n-2}\right)
$$
Then
$$
\begin{align}
&f(g(x))-g(f(x))\\
&=\left((n-1)(a_{2n-1}b_n-a_nb_{2n-1})+\frac{n(n-1)}{2}a_nb_n(b_n-a_n)\right)x^{3n-2}+o\left(x^{3n-2}\right)
\end{align}
$$

Applying the claim to
$$
\tan(x)=x+\frac13x^3+\frac2{15}x^5+\frac{17}{315}x^7+o\left(x^7\right)
$$
and
$$
\sin(x)=x-\frac16x^3+\frac1{120}x^5-\frac1{5040}x^7+o\left(x^7\right)
$$
yields
$$
\begin{align}
&\tan(\sin(x))-\sin(\tan(x))\\[9pt]
&=\left(2\left(-\frac2{15}\cdot\frac16-\frac13\cdot\frac1{120}\right)+3\cdot\frac13\cdot\frac16\left(\frac16+\frac13\right)\right)x^7+o\left(x^7\right)\\
&=\frac1{30}x^7+o\left(x^7\right)
\end{align}
$$

Proof of Claim: Simply, compose the series:
$$
\begin{align}
f(g(x))
&=\left(x+b_nx^n+b_{2n-1}x^{2n-1}+b_{3n-2}x^{3n-2}+o\left(x^{3n-2}\right)\right)\\
&+a_n\left(x+b_nx^n+b_{2n-1}x^{2n-1}+b_{3n-2}x^{3n-2}+o\left(x^{3n-2}\right)\right)^n\\
&+a_{2n-1}\left(x+b_nx^n+b_{2n-1}x^{2n-1}+b_{3n-2}x^{3n-2}+o\left(x^{3n-2}\right)\right)^{2n-1}\\
&+a_{3n-2}\left(x+b_nx^n+b_{2n-1}x^{2n-1}+b_{3n-2}x^{3n-2}+o\left(x^{3n-2}\right)\right)^{3n-2}\\
&+o\left(x^{3n-2}\right)\\
&=x+(a_n+b_n)x^n+(a_{2n-1}+b_{2n-1}+na_nb_n)x^{2n-1}\\
&+\left(a_{3n-2}+b_{3n-2}+na_nb_{2n-1}+\frac{n(n-1)}{2}a_nb_n^2+(2n-1)a_{2n-1}b_n\right)x^{3n-2}\\
&+o\left(x^{3n-2}\right)
\end{align}
$$
Note that the first three terms are symmetric in $a$ and $b$, so they will vanish in the difference.
Similarly,
$$
\begin{align}
g(f(x))
&=x+(a_n+b_n)x^n+(a_{2n-1}+b_{2n-1}+na_nb_n)x^{2n-1}\\
&+\left(a_{3n-2}+b_{3n-2}+na_{2n-1}b_n+\frac{n(n-1)}{2}a_n^2b_n+(2n-1)a_nb_{2n-1}\right)x^{3n-2}\\
&+o\left(x^{3n-2}\right)
\end{align}
$$
Subtract.
QED