8.365. $2(1+\sin 2 x)=\tan\left(\frac{\pi}{4}+x\right)$.
## Solution.

Domain of definition: $\cos \left(\frac{\pi}{4}+x\right) \neq 0$.

Rewrite the equation as

$$
\begin{aligned}
& 2\left(\sin ^{2} x+2 \sin x \cos x+\cos ^{2} x\right)-\frac{\sin \left(\frac{\pi}{4}+x\right)}{\cos \left(\frac{\pi}{4}+x\right)}=0 \Leftrightarrow \\
& \Leftrightarrow 2(\sin x+\cos x)^{2}-\frac{\sin \frac{\pi}{4} \cos x+\cos \frac{\pi}{4} \sin x}{\cos \frac{\pi}{4} \cos x-\sin \frac{\pi}{4} \sin x}=0 \Leftrightarrow \\
& \Leftrightarrow 2(\sin x+\cos x)^{2}-\frac{\frac{\sqrt{2}}{2}(\cos x+\sin x)}{\frac{\sqrt{2}}{2}(\cos x-\sin x)}=0 \Leftrightarrow
\end{aligned}
$$

$$
\begin{aligned}
& \Leftrightarrow 2(\sin x+\cos x)^{2}+\frac{\cos x+\sin x}{\sin x-\cos x}=0 \Leftrightarrow \\
& \Leftrightarrow(\sin x+\cos x)\left(2(\sin x+\cos x)+\frac{1}{\sin x-\cos x}\right)=0
\end{aligned}
$$

From this, 1) $\sin x+\cos x=0, 2) 2(\sin x+\cos x)+\frac{1}{\sin x-\cos x}=0$.

1) $\operatorname{tg} x=-1, x_{1}=-\frac{\pi}{4}+\pi k=\frac{\pi}{4}(4 k-1), k \in Z$.
2) $2\left(\sin ^{2} x-\cos ^{2} x\right)+1=0, \cos 2 x=\frac{1}{2}, 2 x= \pm \frac{\pi}{3}+2 \pi n$,

$$
x_{2}= \pm \frac{\pi}{6}+\pi n=\frac{\pi}{6}(6 n \pm 1), n \in Z
$$

Answer: $x_{1}=\frac{\pi}{4}(4 k-1) ; x_{2}=\frac{\pi}{6}(6 n \pm 1)$, where $k$ and $n \in Z$.