Solve the equation $\sin x+\cos x=k \sin x \cos x$ for real $x$, where $k$ is a real constant. As I had solved the equation when $k=1$ in Quora and MSE by two methods, I started to investigate the equation for any real constant $k$:
$$
\sin x+\cos x=k \sin x \cos x,
$$
I first rewrite the equation as
$$
\sqrt{2} \cos \left(x-\frac{\pi}{4}\right)=\frac{k}{2}  \sin (2 x)
$$
Letting $ \displaystyle y=x-\frac{\pi}{4}$ yields
$$
\begin{array}{l}
\sqrt{2} \cos y=\frac{k}{2}\left(2 \cos ^{2} y-1\right) \\
2 k \cos ^{2} y-2 \sqrt{2} \cos y-k=0
\end{array}
$$
When $k\neq 0$, using quadratic formula gives
$$
\cos y=\frac{1 \pm \sqrt{1+k^{2}}}{\sqrt{2} k}
$$
For real $y$, we have to restrict $\displaystyle \frac{1 \pm \sqrt{1+k^{2}}}{\sqrt{2} k}$ in $[-1,1]$. Then I found that
$$
-1 \leqslant \frac{1+\sqrt{1+k^{2}}}{\sqrt{2} k} \leqslant 1 \Leftrightarrow \quad|k| \geqslant 2 \sqrt{2}
$$ and $$
-1 \leqslant \frac{1-\sqrt{1+k^{2}}}{\sqrt{2} k} \leqslant 1 \Leftrightarrow \quad k<0 \text { or } k>0
$$
Now we can conclude that
A. When $k\neq0$
$$x=n \pi-\frac{\pi}{4}$$
B. When $0\neq|k| \geqslant 2 \sqrt{2}, $
$$x=\frac{(8 n+1) \pi}{4} \pm \arccos \left(\frac{1\pm \sqrt{1+k^{2}}}{\sqrt{2} k}\right)$$
C. When $ 0 \neq|k|<2 \sqrt{2},$
$$ x= \frac{(8 n+1) \pi}{4}  \pm \arccos \left(\frac{1-\sqrt{1+k^{2}}}{\sqrt{2} k}\right)
$$
where $n\in Z.$
I am looking forward to seeing other methods to solve the equation.
Furthermore, how about $$a\sin x+b\cos x+c\sin x\cos x=0?$$

The case of $k=0$ is elementary. Then squaring both members,
$$2\cos x\sin x+1=k^2(\cos x\sin x)^2$$ immediately gives
$$\cos x\sin x=\frac{1\pm\sqrt{k^2+1}}{k^2}$$ and
$$\cos x+\sin x=\frac{1\pm\sqrt{k^2+1}}k.$$
This is a classical sum/product problem, solved with
$$\cos x-\sin x=\pm\sqrt{(\cos x+\sin x)^2-4\cos x\sin x}\\
=\pm\frac{\sqrt{(1\pm\sqrt{k^2+1})^2-4(1\pm\sqrt{k^2+1})}}k.$$
