<s>[INST] Derivative of $\tan^{-1}\left(\sqrt{\frac{a-b}{a+b}}\tan \frac x2\right)$. 
Find the derivative of $\tan^{-1}\left(\sqrt{\frac{a-b}{a+b}}\tan \frac x2\right)$.

I'm learning differentiation and this is an exercise problem from my book. I used chain rule and got the following:
$\begin{align}
\dfrac d{dx}\left[\tan^{-1}\left(\sqrt{\frac{a-b}{a+b}}\tan\frac x2\right)\right] &= \dfrac{1}{1+\frac{a-b}{a+b}\tan^2\frac x 2}\cdot\dfrac{d}{dx}\left(\sqrt{\frac{a-b}{a+b}}\tan \frac x2\right)\\ &= \dfrac{1}{1+\frac{a-b}{a+b}\tan^2\frac x 2}\cdot\frac 1 2\sqrt{\frac{a-b}{a+b}}\sec^2\frac x 2
\end{align}$
But this doesn't match the answer in the book. The given answer is $\frac{\sqrt{a^2-b^2}}{2(a+b\cos x)}$. So, where did I go wrong and what is the correct solution?
 [/INST] Just keep going from where you stopped: Taking things one or two steps at a time, we have
$$\begin{align}
{1\over1+{a-b\over a+b}\tan^2{x\over2}}\cdot{1\over2}\sqrt{a-b\over a+b}\sec^2{x\over2}
&={a+b\over a+b+(a-b)\tan^2{x\over2}}\cdot{1\over2}\sqrt{a-b\over a+b}\sec^2{x\over2}\\
&={1\over2}\cdot{\sqrt{(a+b)(a-b)}\over a+b+(a-b)\tan^2{x\over2}}\cdot{1\over\cos^2{x\over2}}\\
&={1\over2}\cdot{\sqrt{a^2-b^2}\over(a+b)\cos^2{x\over2}+(a-b)\sin^2{x\over2}}\\
&={1\over2}\cdot{\sqrt{a^2-b^2}\over a\left(\cos^2{x\over2}+\sin^2{x\over2}\right)+b\left(\cos^2{x\over2}-\sin^2{x\over2}\right)}\\
&={1\over2}\cdot{\sqrt{a^2-b^2}\over a+b\cos x}
\end{align}$$
</s>