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?$$
 A: 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}$.
A: You can rationalize with the Weierstrass substitution, which gives
$$\frac{1-t^2+2t}{1+t^2}=k\frac{2t(1-t^2)}{(1+t^2)^2}$$
or
$$t^4-2(k+1)t^3+2(k-1)t-1=0.$$
The resolution of this quartic is difficult. https://www.wolframalpha.com/input/?i=t%5E4-2%28k%2B1%29t%5E3%2B2%28k-1%29t-1%3D0

The method works similarly for the generalized equation.
A: 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.$$
A: k should be necessarily $> 1$ because each part >1.
Say since there would be 4 solutions verified for a particular numerical case of given k=2
$$  1/\sin(t) + 1/ \cos(t)  = 2, $$
we get 4 approximate solutions by iteration,.. without graphing
$$(2.81901,3.45426,1.14103,-7.55065) $$
By graphing
