prove that $\arctan\frac{\cos x-\sin x}{\cos x+\sin x}=\frac{\pi}{4}-x$, where $0I tried to solve this
$$\begin{align} \arctan\frac{\cos x-\sin x}{\cos x+\sin x}&=\arctan\frac{1-\tan x}{1+\tan x}\\&=\arctan\frac{\tan\frac{\pi}{4}-\tan x}{1+\tan\frac{\pi}{4}\tan x}\\&=\arctan\tan\left(\frac{\pi}{4}-x\right)\\&=\frac{\pi}{4}-x \end{align}$$
But suddenly I realised $x$ can be $\frac{\pi}{2}$ where $\cos x=0$ and I can't divide it by $\cos x$.
and also i am wondering that $\frac{\pi}{4}-x$ is only valid fro $\frac{-\pi}{4}<x<\frac{3\pi}{4}$.
what happen when $\pi>x>\frac{3\pi}{4}$.

Another approach. Let $f(x)=\arctan(\frac{\cos x-\sin x}{\cos x+\sin x})$, with $x\in (-\pi/4,3\pi/4)$.
$$f'(x)=\frac{1}{1+\frac{\cos x-\sin x}{\cos x+\sin x}^2}\frac{(\sin x-\cos x)(\cos x +\sin x)+(\sin x-\cos x)(\cos x-\sin x)}{(\cos x+\sin x)^2}$$
It's easy to simplifie that expression and get that $f'(x)=-1$, it implies that $f(x)=C-x$, where $C$ is some constant. To find it we evaluate the function in a point like for example $\pi/2$, where the function is well defined.
$$C-\frac{\pi}{2}=f(\pi/2)=\arctan(\frac{0-1}{0+1})=\arctan(-1)=-\frac{\pi}{4}$$
so $C=\frac{\pi}{4}$ and $f(x)=\frac{\pi}{4}-x$ in the interval where is well defined
