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?$$

Let $a=\cos x$ and $b=\sin x$, then
$$
\left\{\begin{array}{l}
a+b=k a b \\
a^{2}+b^{2}=1
\end{array}\right.
$$
Denoting the sum of $a$ and $b$ by $h$ yields
$$a+b=h \textrm{  and }a b=\frac{h}{k}$$
Now we can construct a quadratic equation (*) with roots $a$ and $b$
$$
k x^{2}-h k x+h=0 \tag*{(*)} 
$$
Since $a$ and $b$ are roots of (*), therefore $$
\left\{\begin{array}{l}
k a^{2}-h k a+h=0 \quad \cdots(1) \\
k b^{2}-h k b+h=0 \quad \cdots(2)
\end{array}\right.
$$
(1) + (2) yields
$$\begin{array}{l} 
k\left(a^{2}+b^{2}\right)-h k(a+b)+2 h=0 \\
 \qquad k h^{2}-2 h-k=0
\end{array}
$$
When $k\neq 0$, using quadratic formula gives
$$
\begin{aligned}
h
&=\frac{1 \pm \sqrt{1+k^{2}}}{k}
\end{aligned}
$$
By $k a b=h$, $$
\begin{aligned}
\frac{k \sin 2 x}{2} &=\frac{1 \pm \sqrt{1+k^{2}}}{k} \\
\sin 2 x &=\frac{2 \pm 2 \sqrt{1+k^{2}}}{k^{2}}
\end{aligned}
$$
Noting that
$$-1 \leqslant \frac{2+2 \sqrt{1+k^{2}}}{k^{2}} \leqslant 1 \Leftrightarrow  |k| \geqslant 2 \sqrt{2}$$
$$
-1 \leqslant \frac{2-2 \sqrt{1+k^{2}}}{k^{2}} \leqslant 1 \Leftrightarrow k\neq 0,
$$
we can conclude that
A. If $k=0,$
$$\displaystyle  x=n \pi-\frac{\pi}{4}$$
B. If $0\neq|k| \geqslant 2 \sqrt{2}$,
$$
x=\frac{1}{2}\left[n \pi+(-1)^{n} \sin ^{-1}\left(\frac{2 \pm 2 \sqrt{1+k^{2}}}{k^{2}}\right)\right]
$$
C. If $0\neq |k|  <2 \sqrt{2}$,
$$
x=\frac{1}{2}\left[n \pi+(-1)^{n} \sin ^{-1}\left(\frac{2-2 \sqrt{1+k^{2}}}{k^{2}}\right)\right],
$$
where $n \in \mathbb{Z}$.
