Solve $\frac{d^{2} y}{d x^{2}}+(\tan x-3 \cos x) \frac{d y}{d x}+2 y \cos ^{2} x=\cos ^{4} x$ Solve the differential equation $$\frac{d^{2} y}{d x^{2}}+(\tan x-3 \cos x) \frac{d y}{d x}+2 y \cos ^{2} x=\cos ^{4} x$$
My try:
I multiplied throughout with $\sec^2 x$, getting
$$\sec^{2} x \frac{d^{2} y}{d x}+\sec^{2} x \tan x \frac{d y}{d x}-3 \sec x \frac{d y}{d x}+2 y=\cos ^{2} x$$
Which can be written as:
$$\frac{d}{d x}\left(\sec ^{2} x \frac{d y}{d x}\right)-\tan x\left(\sec ^{2} x \frac{d y}{d x}\right)-3 \sec x \frac{d y}{d x}+2 y=\cos ^{2} x$$
Then I assumed $z=\sec^2 x\frac{dy}{dx}$, so we get
$$\frac{d z}{d x}-z \tan x-3 \sec x \frac{d y}{d x}+2 y=\cos ^{2} x$$
I am stuck now.

The equation has trigonometric coefficients and singularities at the roots of the cosine. On the intervals between these roots, $\sin x$ is an equivalent parametrization to $x$, so try if $y(x)=u(\sin x)$ gives a more simple equation.
$$
y(x)=u(\sin x)\\
y'(x)=\cos x\,u'(\sin x)\\
y''(x)=\cos^2x\,u''(\sin x)-\sin x\, u'(\sin x)\\~\\
[\cos^2x\,u''(\sin x)-\sin x\, u'(\sin x)]+[(\sin x-3\cos^2x)\,u'(\sin x)]
+2\cos^2x\,u(\sin x)=\cos^4 x
$$
So indeed the equation simplifies. Naming the new parameter $s=\sin x$, the trigonometic functions can be completely replaced, giving
$$
u''(s)-3u'(s)+2u(s)=1-s^2
$$
This linear DE with constant coefficients has a general solution of the form
$$
u(s)=Ae^s+Be^{2s}+C+Ds+Es^2.
$$
Inserting gives the equation
$$
2C+(-3+2s)D+(2-6s+2s^2)E=1-s^2\\~\\
E=-\frac12\\
D=3E=-\frac32\\
2C-3D+2E=1\implies C=-\frac54
$$
Substituting back gives the result as
$$
y(x)=Ae^{\sin x}+Be^{2\sin x}-\frac54-\frac32\sin x-\frac12\sin^2x.
$$
