How To Solve a Trigonometric Differential Equation Salutations, I have been trying to approach an ODE with trigonometric functions that I found interesting:
$$y'+x\sin(2y)=xe^{-x^2}\cos^2(y)$$
I tried to find a result with wolfram web page (free version) and I got this one:
$$y=\arctan\left(\frac{1}{2}e^{-x^2}(c+x^2)\right)$$
I have tried to approach this exercise by substitution of variables, also separable variables and I have not had luck by power series, 
and I do not know if methods like those of Ricatti and Bernoulli are appropriate for this case.
This is just for academic curiosity and I would like to understand better this kind of ODEs. So, I require any guidance or starting steps or explanations about how to approach this kind of exercises.
Thanks for your attention.
 A: When I saw the equation which contains $\sin(2y)$ and $\cos^2(y)$, I immediately thought about the tangent hal-angle subsitution (let us call that intuition).
So, let $y=\tan ^{-1}(z)$ which reduces the equation to
$$z'+2 x z=e^{-x^2} x$$ The homogeneous part is simple
$$z'+2 x z=0 \implies z=C \,e^{-x^2}$$
Now, variation of parameters to get 
$$C'=x \implies C=\frac 12 x^2+c_1\implies z=e^{-x^2}\left(\frac 12 x^2+c_1 \right)$$ and, finally, the solution.
A: This is in general so non-linear that you can not expect a closed solution. However, as it is an exercise a closed solution most probably exists, so you have to consider the parts of this equation. With some experience one may see that dividing by $\cos^2y$ gives
$$
\frac{y'}{\cos^2 y}+2x\tan y=xe^{-x^2}
$$
which has the form 
$$
f'(y)y'+2xf(y)=xe^{-x^2}
$$
which now is linear in $u=f(y)=\tan(y)$. For this linear equation, $e^{x^2}$ is an integrating factor which miraculously also simplifies the right side. After integrating you get
$$
e^{x^2}\tan(y(x))=\frac12x^2+c.
$$
