Solutions of the ODE $y'' + a(x) y' - xa(x) y = 0$ I am reading an article and at some point we reach a differential equation of the form
$$y'' + \left(\frac{1}{x} + \frac{x}{2}\right) y' - \left(\frac{1}{x^2} + \frac{1}{2}\right) y = \frac{1}{x}.$$
Then the author claims that the first solution of the homogenous equation (equation with right hand side set to zero) is given by $y_1(x) = x$ (this one is quite obvious) and the other one is given by
$$y_2(x) = y_1(x) \int y_1(x)^{-2} e^{-\int a(x)}dx,$$
for
$$a = \frac{1}{x} + \frac{x}{2}.$$
Basically, our ODE can be written as
$$y'' + a(x) y' - xa(x) y = \frac{1}{x}.$$
Moreover, he also claims that the solution to the non-homogeneous equation should be
$$y(x) = -y_1(x) \int y_1(x)^{-2}e^{-\int a(x)} \int \frac{1}{z} e^{-\int a(x)} y_1(z) dzdx.$$
Does one of you have any idea how he gets these solutions for the homogenous and non-homogenous equations ? The particular solution for the non-homogenous solution looks a bit like the one we should get by using the variation of parameters method but I wasn't able to find the right result, I'm not really good at solving ODEs.
 A: I will write an outline. We have the ode give by
$$y''+\left(\frac{1}{x}+\frac{x}{2}\right)y'-\left(\frac{1}{x^2}+\frac{1}{2}\right)y=\frac{1}{x}$$
for $y=y(x)$ and $x\not=0$. We can try with the homogeneous substitution $v=y/x$ then the ode can be written as
$$xv''+\frac{1}{2}(x^2+6)v'=\frac{1}{x}$$
The configuration of the ode suggests reduction of order, so we try $v'=\phi$ then rewriting we have
$$\phi'+\frac{x^2+6}{2x}\phi=\frac{1}{x^2}$$
That is a linear ode and can be solved using integration factor as standard method: integration factor is $\mu(x)=e^{\int\frac{x^2+6}{2x} dx}=x^3 e^{x^2/4}$, then multiply both sides and integrating we have
$$\mu(x)\phi(x)=2e^{x^2/4}+c_1\implies \phi(x)=\frac{2}{x^3}+c_{1}\frac{e^{-x^2/4}}{{x^3}}$$
Substitution back give
$$v'=\int \left(\frac{2}{x^3}+c_1\int \frac{e^{-x^2/4}}{x^3} \right)dx$$
Finally, substitution back again give the general solution in terms of integral representation as in the document (slightly more punctual)
$$y(x)=Ax+B\left[-\frac{4}{x}e^{-x^2/4} -x\left(\mathcal{P}\int_{-\infty}^{-x^2/4} \frac{e^{t}}{t}dt\right)\right]-\frac{1}{x}.$$
A: Let $y_1, y_2$ be two LINEARLY INDEPENDENT solutions of the given ODE $y''+a(x)y'+xa(x)y=0$. Then, $$y_1''+a(x)y_1'+xa(x)y_1=0\tag{1}$$$$y_2''+a(x)y_2'+xa(x)y_2=0\tag{2}$$
Doing $(1)\times y_2-(2)\times y_1$, we get $$(y_1''y_2-y_2''y_1)+a(x)(y_1'y_2-y_2'y_1)+xa(x)(y_1y_2-y_2y_1)=0,$$ or $$(y_1''y_2-y_2''y_1)+a(x)(y_1'y_2-y_2'y_1)=0.$$ Now define the Wronskian of $y_1$ and $y_2$ as the determinant, $W=\displaystyle\left|\begin{matrix}y_1&y_2\\y_1'&y_2'\end{matrix}\right|=y_1y_2'-y_1'y_2$. Then, we will have $W'=y_1y_2''-y_2y_1''$. Substituting, we get $W'+a(x)W=0$ so that $\displaystyle W=Ce^{-\int a(x)dx}$.
Thus, $$y_1y_2'-y_1'y_2=Ce^{-\int a(x)dx}$$$$\implies\dfrac{ y_1y_2'-y_1'y_2}{y_1^2}=\dfrac{Ce^{-\int a(x)dx}}{y_1^2}.$$$$\implies\dfrac{d}{dx} \dfrac{y_2}{y_1}=\dfrac{Ce^{-\int a(x)dx}}{y_1^2}.$$ or $$\dfrac{y_2}{y_1}=\int\dfrac{Ce^{-\int a(x)dx}}{y_1^2}dx+K.$$$$\implies y_2=y_1\left(\int\dfrac{Ce^{-\int a(x)dx}}{y_1^2}dx+K\right)$$ For one particular solution, let $C=1, K=0$. Then $$\implies y_2=y_1\left(\int\dfrac{e^{-\int a(x)dx}}{y_1^2}dx\right).$$ This is one method that you can use to get the other linearly independent solution.
