<s>[INST] Simplify $\tan^{-1}\Big[\frac{\cos x-\sin x}{\cos x+\sin x}\Big]$, where $x<\pi$ Write in the simplist form 

$$
\tan^{-1}\bigg[\frac{\cos x-\sin x}{\cos x+\sin x}\bigg],\quad x<\pi
$$

My Attempt:
$$
x<\pi\implies -x>-\pi\implies \frac{\pi}{4}-x>\frac{-3\pi}{4}
$$
$$
\frac{\cos x-\sin x}{\cos x+\sin x}=\frac{\cos^2 x-\sin^2 x}{(\cos x+\sin x)^2}=\frac{\cos 2x}{1+2\sin x\cos x}=\frac{\cos 2x}{1+\sin 2x}\\=\frac{\sin(\tfrac{\pi}{2}-2x)}{1+\cos(\tfrac{\pi}{2}-2x)}=\frac{2\sin(\tfrac{\pi}{4}-x)\cos(\tfrac{\pi}{4}-x)}{2\cos^2(\tfrac{\pi}{4}-x)}={\tan(\tfrac{\pi}{4}-x)}\\
\implies {\tan(\tfrac{\pi}{4}-x)}=\tan\big[\tan^{-1}\frac{\cos x-\sin x}{\cos x+\sin x}\big]\\
\implies \tan^{-1}\frac{\cos x-\sin x}{\cos x+\sin x}=n\pi+\frac{\pi}{4}-x
$$
If $-\pi/2<\frac{\pi}{4}-x<\pi/2$,
$$
\tan^{-1}\frac{\cos x-\sin x}{\cos x+\sin x}=\frac{\pi}{4}-x
$$
this is what is given as answer.
But, since we have further restricted the domain to $\frac{-\pi}{2}<\frac{\pi}{4}-x<\frac{\pi}{2}\implies\frac{-\pi}{4}<x<\frac{3\pi}{4}$ from $x<\pi$, how can it be same as the original function ?
 [/INST] Indeed the given answer seems strange, as the usual range of the $\tan^{-1}$ function is $\left(-\frac\pi2,\frac\pi2\right)$, and if $\frac{3\pi}4 \leq x < \pi$ then $\frac\pi4-x$ is not in this range. I think you have the domain right.
</s>