# 4. Solution:

Note that $\sin x \neq 0, \cos x \neq 0$, and multiply both sides of the equation by $\operatorname{tg} x$. We get $\sqrt{1+\operatorname{tg} x}=\sin x+\cos x$. Given that $\sin x+\cos x \geq 0$, both sides of this equation can be squared. Since $\sin x+\cos x=\sqrt{2} \sin \left(x+\frac{\pi}{4}\right)$, the inequality holds if $-\frac{\pi}{4}+2 \pi n \leq x \leq \frac{3 \pi}{4}+2 \pi n, n \in Z$. Under these constraints and conditions $\sin x \neq 0, \cos x \neq 0$, the equation is equivalent to the following:

$1+\operatorname{tg} x=\sin ^{2} x+2 \sin x \cos x+\cos ^{2} x \quad \Leftrightarrow \quad \operatorname{tg} x-2 \sin x \cos x=0 \quad \Leftrightarrow \quad \frac{\sin x}{\cos x}-2 \sin x \cos x=0$, $\sin x\left(\frac{1}{\cos x}-2 \cos x\right)=0 . \quad$ Thus, we arrive at the equation $\quad \cos ^{2} x=\frac{1}{2}$, $\cos x= \pm \frac{\sqrt{2}}{2}, x= \pm \frac{\pi}{4}+\pi n, n \in Z$. Considering the constraints, we obtain the solutions to the original equation: $x= \pm \frac{\pi}{4}+2 \pi n, \quad x=\frac{3 \pi}{4}+2 \pi n, n \in Z$
Answer: $\pm \frac{\pi}{4}+2 \pi n, \frac{3 \pi}{4}+2 \pi n, n \in Z$.