Find $f'(x)$ where $f(x) = \sqrt{\dfrac{1-\cos(2x)}{1 + \cos(2x)}}$.
This question is given in my textbook but I don't agree with the solution given in my book and various sites on the internet.
The book shows the following method:
$$f(x) = \sqrt{\dfrac{1-\cos(2x)}{1 + \cos(2x)}} =\sqrt{\dfrac{2\sin^2(x)}{2\cos^2(x)}}=\sqrt{\tan^2x}= \tan(x)$$ So the derivative of $\tan(x)$ is $\sec^2(x).$
But my confusion is that, $\sqrt{\tan^2(x)}$ should be $|\tan(x)|$ and so, it's derivative cannot be equal to $\sec^2x$.
Derivative of $|x|$ is $\dfrac{x}{|x|}$.
So, the derivative of $|\tan(x)|$ should be $\dfrac{\tan(x) \cdot \sec^2(x)}{|\tan(x)|}.\bf\qquad\qquad\qquad\qquad....(1)$
Or we can also say that derivative of $|\tan(x)|= \begin{cases}\sec^2{x},\rm If\, tan(x)\ge0\\-\sec^2x, \rm If \tan(x) < 0 \end{cases}.\bf\qquad....(2)$
Am, I right in (1) and (2)?