Find a closed-form solution for a Riccati equation $$y' + y^{2}+ \sin(2x)y =\cos(2x)$$
PS: I feel like that substitution may work in this problem. I tried some substitutions but none of them can solve the problem.
 A: Using the standard substitution $u=\exp(\int y(x)\,dx)$ or $y=\frac{u'}{u}$ gives the second order linear DE
\begin{align}
0&=u''+\sin(2x)u'-\cos(2x)u
\\
&=u''+2\sin x\cos x\, u'+(\sin^2x-\cos^2x)u
\end{align}
With a long look on the terms one can see that $u(x)=\sin x$ is a solution,
$$
-\sin x+2\sin x\cos^2x+\sin^3 x-\sin xcos^2x=-\sin x+\sin x(\cos^2x+\sin^2x)=0
$$
The reduction-of-order method then advises to search a second basis solution as $u(x)=\sin x\,v(x)$.
\begin{align}
0&=[\sin x\,v''+2\cos x\,v'-\sin x\,v]+2\sin x\cos x[\sin x\,v'+\cos x\,v]+(\sin^2x-\cos^2x)\sin x\, v
\\
&=\sin x\,v''+[2\cos x+2\sin^2 x\cos x]v'
\\[1em]
\frac{v''}{v'}&=-2\frac{\cos x}{\sin x}-2\sin x\cos x
\\
v'&=-\frac{e^{\cos^2x}}{\sin^2x}
\\[1em]
v(x)&=+e^{\cos^2x}\cot(x)+2\int \cos^2 xe^{\cos^2x}\,dx
\end{align}
As we are looking for a basis solution, the multiplicative constant in $v'$ and the additive constant in $v$ can be arbitrarily fixed. The full solution thus reads as
$$
u(x)=A\sin x+Be^{\cos^2x}\cos(x)+2B\int_0^x\cos^2\xi\, e^{\cos^2\xi}\,d\xi
$$
The expression for $y$ can be computed from this.
