# Second order ODE with variable coefficients.

Consider the following ODE:

$$$$(\cos x)y''-2(\sin x)y'-(\cos x)y=e^x$$$$

The above equation is a second order linear ODE. However, I noticed that it doesn't have constant coefficients, so I cannot "guess" the solution is of the form $$e^{\lambda x}$$. Im very confused by this, since I have never solved a 2nd order ODE with variable coefficients. The first part of the question says:

(a)

Show that the ODE is of the form:

$$$$\frac{d^2}{dx^2}(f(x)y)=e^x$$$$

by finding the function f.

(b)

Hence, find the general soluion of he differential equation.

For part (a) I have have no idea where to begin, but I tink that If i knew how to complete part (a) I would be able to find the general solution since I hae done things like that many times. Any help (part a especially) would be much appreciated. Thanks in advance.

a) you have to find $$f(x)$$ such that $$\frac{d^2}{dx^2}(f(x)y)=e^x$$, but $$e^x=\frac{d^2}{dx^2}(f(x)y)=\frac{d}{dx}(f'(x)y+f(x)y')=f''(x)y+f'(x)y'+f'(x)y'+f(x)y''$$ So from the equation $$(\cos x)y''-2(\sin x)y'-(\cos x)y=e^x=f''(x)y+2f'(x)y'+f(x)y''$$ we obtain that $$f(x)=\cos x$$.
b) you can before find the soluction for the associate homogeneous equaction: $$(\cos x)y''-2(\sin x)y'-(\cos x)y=0$$ Using what we have seen in the point a) we have $$0=\frac{d^2}{dx^2}(\cos (x)\cdot y)$$ so $$\cos (x) \cdot y$$ or it's a costant or a polinomial with $$deg=1$$. So a base of the associate homogeneous equaction it's $$c_1\cdot sec(x)+c_2\cdot xsec(x)$$ ($$sec(x)=\frac{1}{\cos x}$$). Now from $$e^x=\frac{d^2}{dx^2}(f(x)y)$$ we can easily obtain a particular soluction like $$sec(x)e^x$$. Summing the particular solution with the general soluction of the associate homogeneous equaction you find what you want.
The differential equation is $$y''-2(\tan x )y'-y=e^x\sec x$$.Calculate the invariant $$I=Q-(1/4)P^2-(1/2)dP/dx$$ where $$P,Q,R$$ have usual meaning and $$I=0$$ by calculation.So the substitution $$y=ve^{-1/2\int Pdx}=v\sec x$$ transforms the differential equation into $$v''+Iv=Re^{1/2\int P dx}$$,i.e. $$v''=e^x$$,integrating $$v=e^x+Ax+B$$ and $$y=v\sec x$$,which is the solution of the second order linear differential equation and here $$f(x)=\cos x$$ as per your question as $$y=v\sec x$$ implies $$y\cos x=v$$ so that $$D^2(y\cos x)=e^x$$.