$$2y'\cos x-y^2=2\cos^2 x-\sin^2 x$$
$$2y'\cos x-2\cos^2 x=y^2-\sin^2 x$$
$$2\cos x(y'-\cos x)=(y-\sin x)(y+\sin x)$$
$$2\cos x(y-\sin x)'=(y-\sin x)(y-\sin x+2\sin x)$$
let $y-\sin x=u$ then
$$2\cos x u'=u^2+2\sin x u$$
$$2\cos x u'-2\sin x u=u^2$$
$$2(\cos x u)'=u^2$$
$$2\dfrac{d(\cos x u)}{\cos^2x u^2}=\dfrac{dx}{\cos^2x}$$
$$-2\dfrac{1}{\cos x u}=\tan x+C$$
$$-2\dfrac{1}{\cos x (y-\sin x)}=\tan x+C$$
Related Questions in ORDINARY-DIFFERENTIAL-EQUATIONS
$$2y'\cos x-y^2=2\cos^2 x-\sin^2 x$$ $$2y'\cos x-2\cos^2 x=y^2-\sin^2 x$$ $$2\cos x(y'-\cos x)=(y-\sin x)(y+\sin x)$$ $$2\cos x(y-\sin x)'=(y-\sin x)(y-\sin x+2\sin x)$$ let $y-\sin x=u$ then $$2\cos x u'=u^2+2\sin x u$$ $$2\cos x u'-2\sin x u=u^2$$ $$2(\cos x u)'=u^2$$ $$2\dfrac{d(\cos x u)}{\cos^2x u^2}=\dfrac{dx}{\cos^2x}$$ $$-2\dfrac{1}{\cos x u}=\tan x+C$$ $$-2\dfrac{1}{\cos x (y-\sin x)}=\tan x+C$$