8.161. $3 \cos ^{2} x=\sin ^{2} x+\sin 2 x$.

Translate the above text into English, keeping the original text's line breaks and format, and output the translation result directly.

8.161. $3 \cos ^{2} x=\sin ^{2} x+\sin 2 x$.
Solution.

From the condition $\sin ^{2} x+2 \sin x \cos x-3 \cos ^{2} x=0$. Dividing this equation by $\cos ^{2} x \neq 0$, we get $\operatorname{tg}^{2} x+2 \operatorname{tg} x-3=0$. Solving the equation as a quadratic equation in terms of $\operatorname{tg} x$, we find $(\operatorname{tg} x)_{1}=-3, x_{1}=-\operatorname{arctg} 3+\pi k$, $k \in Z ;(\operatorname{tg} x)_{2}=1, x_{2}=\frac{\pi}{4}+\pi n=\frac{\pi}{4}(4 n+1), n \in Z$.

Answer: $x_{1}=-\operatorname{arctg} 3+\pi k, x_{2}=\frac{\pi}{4}(4 n+1), k, n \in Z$.