Get the solution to the differential equation $\cos y \sin2x dx +(cos^2y - cos^2x)dy = 0$ I was helping somebody on some math problems when a wild question appears. It goes like this:

Get the solution to the differential equation $$\cos y \sin2x dx +(\cos^2y - \cos^2x)dy = 0$$

My work
I was able to search the internet on how to get the solution to the differential equation shown above but I do not understand the way.
We could perhaps rearrange the above differential equation into the form
$$M(x,y)dx + N(x,y)dy = 0$$
With the form above, we could see if the given differential equation is variable-separable, homogenous or an exact-type.
Testing the given differential equation as variable-separable:
No. We can't. The differential equation above isn't variable-separable.
Testing the given differential equation as homogenous:
$F(x,y)$ is a homogenous function of degree $n$ in $x$ and $y$ provided $F(kx,ky)$ = $k^nF(x,y)$. For example, $x^2 + y^2$ and $x^2 \sin \left(\frac{y}{x}\right)$ are homogenous functions of degree $2$ in $x$ and $y$. With that in mind...
Looking at the first term $\cos y \sin2x$:
$$F(x,y) = \cos y \sin2x$$
$$F(kx,ky) = \cos (ky) \sin(2kx)$$
Getting deeper, we conclude that
$$F(kx,ky) \neq k^nF(x,y)$$
Looking at the second term $\cos^2y - \cos^2x$:
$$F(x,y) = \cos^2y - \cos^2x$$
$$F(kx,ky) = \cos^2(ky) - \cos^2(kx)$$
Getting deeper, we conclude that
$$F(kx,ky) \neq k^nF(x,y)$$
The terms themselves must be homogenous if the differential equations are homogenous.
No. We can't. The differential equation above isn't homogenous.
Testing the given differential equation if it is an exact-type:
A necessary condition for a differential equation to be exact is
$$\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}$$
So getting the expression for $\frac{\partial M}{\partial y}$:
$$\frac{\partial M}{\partial y} = \frac{\partial}{\partial y}(\cos y \sin2x) $$
$$\frac{\partial M}{\partial y} = \sin 2x\frac{\partial}{\partial y}(\cos y) $$
$$\frac{\partial M}{\partial y} = \sin 2x(-\sin y)$$
$$\frac{\partial M}{\partial y} = -\sin y \sin 2x$$
So getting the expression for $\frac{\partial N}{\partial x}$:
$$\frac{\partial N}{\partial x} = \frac{\partial}{\partial x}(\cos^2y - \cos^2x) $$
$$\frac{\partial N}{\partial x} = 0 - \frac{\partial}{\partial x}(\cos^2x) $$
$$\frac{\partial N}{\partial x} = 0 - \frac{\partial}{\partial x}\left(\frac{1}{2} + \frac{1}{2}\cos 2x\right) $$
$$\frac{\partial N}{\partial x} = \sin 2x $$
We see that $\frac{\partial M}{\partial y} \neq \frac{\partial N}{\partial x}$, so the given differential equation isn't exact either.
Let's try converting it into linear differential equation. 
Let's try rearranging the given differential equation above into a Bernoulli equation, having the form
$$\frac{dy}{dx} + P(x)y = Q(x)$$
Then...
$$\cos y \sin2x dx +(\cos^2y - \cos^2x)dy = 0$$
$$\frac{\cos y \sin2x dx}{dx} +\frac{(\cos^2y - \cos^2x)dy}{dx} = \frac{0}{dx}$$
$$\cos y \sin2x + (\cos^2y - \cos^2x)\frac{dy}{dx} = 0$$
$$\frac{\cos y \sin2x}{\cos^2y - \cos^2x} + \frac{\cos^2y - \cos^2x}{\cos^2y - \cos^2x}\frac{dy}{dx} = \frac{0}{\cos^2y - \cos^2x}$$
$$\frac{\cos y \sin2x}{\cos^2y - \cos^2x} + \frac{dy}{dx} = 0$$
$$\frac{dy}{dx} + \frac{\cos y \sin2x}{\cos^2y - \cos^2x} = 0$$
Screw that. We couldn't even discern what is the expression of $P(x)y$ because the expression $\frac{\cos y \sin2x}{\cos^2y - \cos^2x}$ is irreducible. We can't separate $x$'s from $y$'s. 
How do we get the solution  of the differential equation above?
 A: Just a little hint
This is not a full solution ...
$$\cos(y)\sin(2x)x'=-\cos^2(y)+ {\cos^2(x)}$$
$$\sin(2x)x'=-\cos(y)+\frac {\cos^2(x)}{\cos(y)}$$
$$2\sin(x)\cos(x)x'=-\cos(y)+\frac {1-\sin^2(x)}{\cos(y)}$$
$$2\sin(x)\cos(x)x'+\frac {\sin^2(x)}{\cos(y)}=-\cos(y)+\frac {1}{\cos(y)}$$
$$2\sin(x)\cos(x)x'+\frac {\sin^2(x)}{\cos(y)}=f(y)$$
$$2\sin(x)(\sin(x))'+\frac {\sin^2(x)}{\cos(y)}=f(y)$$
Sustitute $h=\sin(x)$ for a better expression
$$2hh'+\frac {h^2}{\cos(y)}=f(y)$$
$$(h^2)'+\frac {h^2}{\cos(y)}=f(y)$$
Substitute $g(y)=h^2(y)-1$
$$\boxed{g'(y)+\frac {g(y)}{\cos(y)}=-\cos(y)}$$
$$........$$
We have reduced the first equation  to the canonical form of a first order linear equation. But it does not mean that it's easy to integrate such ode. Especially if it involves Gaussian like integrals...
Edit 
Maybe the  ODE could be solved with $tan(x/2)$ susbtitution's formula...
when I write $h=\sin(x)$ it means $h(y)=\sin(x(y))$ both x, and h are functions of the variable y.And so is g ( g(y))  too.
A: Sorry, just now I do not have the time to type the answer in latex. I'll do it tomorrow if it appears useful.
This is only a quick overview, without care about the signs of the square roots. Hoping it will be an useful hint.

The solution is on the form $x(y)$. Probably, there is no closed form for the inverse function $y(x)$. 
Note : 
$(1+\sin(y))\cos^2(x)=c\:\cos(y)-cos^2(y)-\cos(y)\sin^{-1}(\cos(y))$
$\frac{(1+\sin(y))\cos^2(x)}{\cos(y)}=c-\cos(y)-\sin^{-1}(\cos(y))=C-\cos(y)+y$
$$y-\cos(y)-\frac{(1+\sin(y))\cos^2(x)}{\cos(y)}=-C$$
This is consistent with the expected solution (doesn't matter the sign of $C$).
A: 
$$\begin{aligned}\\
\cos y\sin 2xdx+(\cos^2y-\cos^2x)dy&=0\\
\end{aligned}$$

It is of the form:
$$M(x,y)dx+N(x,y)dy=0$$
So, here,
$$M=\cos y\sin 2x, N=(\cos^2y-\cos^2x)$$
$$\therefore \frac{\partial M}{\partial y}=-\sin y\sin 2x\\
\frac{\partial N}{\partial x}=\sin 2x\\
\begin{align}
\therefore \frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{M}&=\frac{-\sin y\sin 2x -\sin 2x}{\cos y\sin 2x}\\
&=-\frac{\sin 2x(1+\sin y)}{\cos y\sin 2x}\\
&=-(sec y+tan y)=-g(y)\\
\end{align}$$
$$\begin{align}
\text{I.F.} &=e^{-\int g(y)dy}\\
&=e^{\int(sec y+tan y)dy}\\
&=e^{\ln(sec y+tan y)+\ln(sec y)}\\
&=sec y(sec y+tan y)\\
\end{align}$$
Multiplying the equation with the integrating factor,
$$\begin{align}
&{\begin{aligned}\\
\cos y\sin 2x \sec y(\sec y+\tan y)dx&+(\cos^2y-\cos^2x)\sec y(\sec y+\tan y)dy&=0\\
\end{aligned}}\\
&{\begin{aligned}\\
\implies\sin 2x(\sec y+\tan y)dx&+(\cos^2y-\cos^2x)(\sec^2y+\sec y&\tan  y)dy=0\\
\end{aligned}}\\
&{\begin{aligned}\\
\implies\sin 2x(\sec y+\tan  y)dx&+(1-\sec^2y\cos^2x+\sin y-\cos^2x \sec y&\tan y)dy&=0\\
\end{aligned}}\\
\end{align}$$
$\text{which is an exact equation.}$
So, the solution is,
$$\begin{align}
&{\begin{aligned}\\
\int_{(\text{y const})}Mdx+&\int(\text{terms of N not containing x})dy=c\\
\end{aligned}}\\
&{\begin{aligned}\\
\implies\int\sin 2x(\sec y+\tan y)dx+&\int(1+\sin y)dy=c\\
\end{aligned}}\\
&{\begin{aligned}\\
\implies -\frac{1}{2}\cos2x(\sec y+\tan y)+y-\cos y&=c\\
\end{aligned}}\\
\end{align}$$
