= Solution
On a nonconstant branch with $\sin y\ne0$, regard $x$ as a function of $y$. The equation becomes the <linear ordinary differential equation>
$$
\frac{dx}{dy}+x\cot y=2\cos y.
$$
An <integrating factor> is $\sin y$, giving
$$
\frac d{dy}(x\sin y)=2\sin y\cos y.
$$
Taking an <antiderivative> yields the implicit family
$$
\boxed{x\sin y-\sin^2y=C}.
$$
On a regular branch this can also be written $x=\sin y+C/\sin y$. The latter form loses the constant solutions $y=n\pi$, which must be restored separately.
The implicit relation is a <first integral of an ordinary differential equation>: along any differentiable solution of the original equation,
$$
\frac d{dx}(x\sin y-\sin^2y)
=\sin y-(2\sin y-x)\cos y\,y'=0.
$$
Conversely, a differentiable graph satisfying this relation solves the original equation wherever $\cos y\ne0$. The original equation is undefined when $\cos y=0$; points at which $2\sin y-x=0$ also need separate attention before solving explicitly for $y'$. This is why dividing immediately by $\tan y$ can lose valid solutions and obscure nonuniqueness.
Back to article page