Cannot solve the non-exact ODE, I don't know how to find the integrating factor such that make the exact ODE. Solve the ODE $xy' = y-x\cos ^2\left(\dfrac{y}{x}\right)$.
I have tried as below. I'm using exact/non exact method.
We change the ODE into form
$$\left(y-x\cos ^2\left(\dfrac{y}{x}\right)\right) dx-xdy = 0.$$
Let $M(x,y)=y-x\cos ^2\left(\dfrac{y}{x}\right)$ and $N(x,y)=-x$.
\begin{align*}
 \dfrac{\partial M(x,y)}{\partial y}&=
 \dfrac{\partial }{\partial y}\left(y-x\cos ^2\left(\dfrac{y}{x}\right)\right) =
 1+2\cos\left(\dfrac{y}{x}\right)\sin \left(\dfrac{y}{x}\right).\\
 \dfrac{\partial N(x,y)}{\partial x}&=
 \dfrac{\partial }{\partial x}(-x) = -1.
\end{align*}
Since $\dfrac{\partial M(x,y)}{\partial y}\neq \dfrac{\partial N(x,y)}{\partial x}$ then that ODE is non exact ODE.
Now I want to change it into exact ODE. We must find integrating factor to make the exact ODE. But now I don't know how to do it.
\begin{align*}
 \dfrac{\partial M(x,y)}{\partial y}
 -
 \dfrac{\partial N(x,y)}{\partial x}
 =
 2+2\cos\left(\dfrac{y}{x}\right)\sin \left(\dfrac{y}{x}\right)
\end{align*}
Anyone can help me?
 A: $$xy' = y-x\cos ^2\left(\dfrac{y}{x}\right)$$
The DE is homogeneous:
$$y' = \dfrac yx-\cos ^2\left(\dfrac{y}{x}\right)$$
Substitute $y=tx \implies y'=t'x+t$
$$t'x=- \cos ^2 t$$
It's now separable.
$$\int \dfrac {dt}{ \cos^2 t}=-\int \dfrac {dx}{x}$$
A: Hint
Considering $$xy' = y-x\cos ^2\left(\dfrac{y}{x}\right)$$ first let $y=x \,z$ to make
$$x^2 z'+x \cos ^2(z)=0$$ Assume $x\neq 0$ to make
$$x z'+\cos ^2(z)=0$$ Switch variables
$$\frac x {x'}+\cos ^2(z)=0 \implies \frac  {x'} x=-\frac 1 {\cos ^2(z)}$$ which seems to be simple.
A: This's a homogeneous equation, so we can solve this ODE using the sustitution $y=xv$. Indeed,
\begin{eqnarray*}
xy'=y-x\cos^{2}\left(\frac{y}{x}\right) &\overset{y=xv}{\underset{y'(x)=xv'(x)+v(x)}{\iff}}  & x\left(xv'(x)+v(x)\right)=x\cos^{2}(v(x))+xv(x)\\
&\iff& v'(x)=-\frac{\cos^{2}(x)}{x}\\
&\iff& \int \sec^{2}(v(x))dv(x)=\int -\frac{1}{x}dx\\
&\iff& \tan(v(x))=-\ln|x|+c\\
&\implies& v(x)=\arctan(-\ln|x|+c)\\
&\overset{y(x)=xv(x)}{\implies}& \boxed{y(x)=x\arctan(-\ln|x|+c)} & 
\end{eqnarray*}
