Problem:
Differentiate with respect to x: $\frac{\tan x-\cot x}{\tan x+\cot x}$
My book's solution:
$$\begin{align}
\frac{\tan x-\cot x}{\tan x+\cot x} &=\frac{\dfrac{\sin x}{\cos x}-\dfrac{\cos x}{\sin x}}{\dfrac{\sin x}{\cos x}+\dfrac{\cos x}{\sin x}} \\[0.5em]
&=\frac{\dfrac{\sin^2x-\cos^2x}{\sin x\cos x}}{\dfrac{\sin^2x+\cos^2x}{\sin x\cos x}}\tag{1}\\[0.5em]
&=\frac{\sin^2x-\cos^2x}{\sin^2x+\cos^2x}\tag{2}\\[0.5em]
&=-\cos 2x
\end{align}$$
Now,
$$\frac{d}{dx}(-\cos 2x)=2\sin 2x$$
Question:
$(1)$ and $(2)$ are different because their domains are different. So, isn't saying $(1)=(2)$ wrong?
Best Answer
$\tan x $ is not defined when $\cos x =0$ and $\cot x $ is not defined when $\sin x =0$. So it is implicitly assumed the domain excludes points where $\sin x \cos x=0$.