Linear differential equation $y'\sin\left(x\right)+2\cdot y\cdot \cos\left(x\right)=1$ Solve the differential equation $$y'\sin\left(x\right)+2\cdot y\cdot \cos\left(x\right)=1$$
I reckon this is a linear differential equation.
We were taught to solve this by first finding the solution to the homogeneous equation $y'+P\left(x\right)\cdot y\:=\:0$ and then finding the solution to the particular equation and then summing the two, giving us the final solution $y=y_o+y_p$
Solving the homogeneous equation yields $$y_o=\sin^{-2}\left(x\right)\cdot e^{-2C}$$
I solved it by separating the equation thus so:$$\frac{dy}{dx}=-\frac{2\cdot y\cdot \cos\left(x\right)}{\sin\left(x\right)}\:$$
Integrating gives $$-\frac{1}{2}\ln\left|y\right|=\ln\left|\sin\left(x\right)\right|+C$$
And so $$y_o=\sin^{-2}\left(x\right)\cdot e^{-2C}$$
And now for the particular solution I just do $$y_p=\sin^{-2}\left(x\right)\cdot e^{-2C\left(x\right)}$$
!!Derivative calculation was wrong, edit below
Derivative: $$y'_p=-\frac{\cos\left(x\right)}{\sin\left(x\right)}\cdot e^{-2C\left(x\right)}-2\sin^{-2}\left(x\right)\cdot C'\left(x\right)\cdot e^{-2C\left(x\right)}$$
And now replacing it in the initial equation gives: $$-\cos\left(x\right)\cdot e^{-2C\left(x\right)}-2\sin^{-1}\left(x\right)\cdot C'\left(x\right)\cdot e^{-2C\left(x\right)}+2\cdot \sin^{-2}\left(x\right)\cdot e^{-2C\left(x\right)}\cdot \cos\left(x\right)=1$$
Usually at this point I can simplify some stuff so I can calculate the value of $C\left(x\right)$ and replace it in the particular solution. So I'm quite stuck at this point, since nothing can be simplified as far as I can see. What am I doing wrong? I saw that there is some other method for solving linear differential equations but I would really want to solve it using the method that was taught to us. Can anyone give me a few pointers of where I'm messing up?
PS: this is not homework, I'm just prepping for an upcoming exam.
EDIT: Found my error, its when I calculate the derivative
Real derivative was:
$y_p'=-\frac{2cos\left(x\right)}{sin^3\left(x\right)}\cdot e^{-2C\left(x\right)}-\frac{2C'\left(x\right)}{sin^2\left(x\right)}\cdot e^{-2C\left(x\right)}$
And in the end everything will simplify, yielding the final result:
$y\:=\:\frac{e^{-2C}-cos\left(x\right)}{sin^2x}$
 A: Let me give you an alternative for first order ODEs of the form 
$$y' + p y = q$$ where $p$ and $q$ are given functions of $x$. Suppose we want to write this equation in the following easy-to-integrate form
$$ \left( I y \right)' = I q, $$
where $I \neq 0 $ is some suitable function. Expanding the derivative, dividing through $I$ and comparing with your original equation you'll find
$$ I = \exp\left(  \int^x p(s) \, \mathrm{d}s\right)$$ which is commonly known as the integrating factor of the ODE.

Let's work out your case now. You have
\begin{equation}
 y' + \frac{2 \cos{x}}{\sin{x}} y = \frac{1}{\sin{x}}  
\end{equation}
By introducing 
$$ \color{blue}{ 
I =  \exp\left( \int^x \frac{2 \cos{x}}{\sin{x}} \mathrm{d}s \right) = \exp (\log{\sin^2{x}}) = \sin^2{x}
}
$$
the previous equation reduces to

$$ ( \sin^2{(x)} \, y)' = \sin{x} $$

which can be easily integrated to

$$ y = \frac{A}{\sin^2 x} - \frac{\cos{x}}{\sin^2 x} = A \operatorname{csc}^2x - \cot{x} \operatorname{csc}x, \quad A \in \mathbb{R}  $$

Hope you find this alternative helpful.
A: hint
In $(k\pi,k\pi+\pi) $, the equation without RHS is
$$\frac {y'}{y}=-2\frac {\cos (x)}{\sin (x)} $$
$$\ln (\frac {y}{C})=-2\ln (|\sin (x)|) $$
$$y_o=C(\sin (x) )^{-2}$$
you can now find a particular solution
$$y_p=C (x)(\sin (x))^{-2} $$
with
$$C'(x)=\sin^2 (x)=\frac {1-\cos (2x)}{2} $$
thus $$C (x)=\frac {x}{2}-\frac {\sin (2x)}{4} .$$
