TITLE: Confusion in finding derivative of $\sqrt{\frac{1-\cos(2x)}{1 + \cos(2x)}}$
QUESTION [10 upvotes]: 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)}} \implies \sqrt{\dfrac{2\sin^2(x)}{2\cos^2(x)}}\implies\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)?

REPLY [2 votes]: There is a little mistake in your answer.
In (1), it should be $\dfrac{\tan(x) \sec^2(x)}{|\tan(x)|}$ with condition $\tan(x)\not= 0$. You should take care of the domain.
Similarly, in (2), it should be $\begin{cases}\sf\sec^2(x), if\, \tan(x) > 0 \\\sf - \sec^2(x), if\, \tan(x) < 0 \end{cases}$
The function is not differentiable at x = 0