How can we guess one solution of the equation $y''+\frac{2}{x}y'+y=0$? I want to solve the equation $$\frac{1}{x^2} \, \frac{d}{dx}\left(x^2\frac{dy}{dx}\right)=-y.$$ I converted it to this equation $y''+\frac{2}{x}y'+y=0$. How can we guess one solution of the equation $y''+\frac{2}{x}y'+y=0$? Is there any way to solve it generally?
 A: An efficient method, based on guessing and practice, is to let $ y = f(x)/x $ which leads to
$$ y^{'} = \frac{x \, f^{'} - f}{x^2} \hspace{5mm} \text{and} \hspace{5mm}  y^{''} = \frac{x^2 f^{''} - 2 f^{'} + 2 f}{x^3} $$
and brings the differential equation
$$ x \, y^{''} + 2 \, y^{'} + x \, y = 0$$
into the form
$$ f^{''} + f = 0. $$
Solving this equation gives $ f(x) = A \, \cos(x) + B \, \sin(x) $ and
$$ y(x) = \frac{A \, \cos(x) + B \, \sin(x)}{x}. $$
A: One thing to try for non-constant coefficients second order linear ode's is the Liouville transformation. This involves no guessing and is one of the methods to try for such ode's if other methods fail.
Solve
\begin{align*} 
y''+\frac{2 y'}{x}+y&=0\\ \tag{1} 
A y''+ B y' + C y&=0
\end{align*}
Hence $A=1,B=\frac{1}{2},C=1$. Applying the Liouville transformation on the dependent variable gives
\begin{align*}
z(x) &= y e^{\int \frac{B}{2 A} \,dx}  \tag{2} 
\end{align*}
Then (1) becomes
\begin{align*}
z''(x) = r z(x)\tag{3}
\end{align*}
Where $r$ is given by
\begin{align*}
r &= \frac{2 A B' - 2 B A' + B^2 - 4 A C}{4 A^2} \\
  &= -1
\end{align*}
Hence (3) becomes
\begin{align*}
z''(x) + z(x) = 0
\end{align*}
This is constant coefficient ode now. Its solution is easily found to be $z=\cos x$. Applying (2) again in reverse to find the first basis solution for the $y$ ode gives
\begin{align*} 
y_1 &= z e^{-\int \frac{B}{2 A} \,dx}\\
  &= z e^{ -\int \frac{1}{2} \frac{\frac{2}{x}}{1} \,dx}\\
  &= z e^{-\ln \left(x \right)}\\
  &= z \left(\frac{1}{x}\right)\\
  &= \frac{\cos \left(x \right)}{x}
\end{align*}
The second basis solution $y_2$ to the original ode is found using reduction of order
\begin{align*} 
y_2 &= y_1 \int \frac{  e^{\int -\frac{B}{A} \,dx}}{y_1^2} \,dx \\
y_2 &= y_1 \int \frac{  e^{\int -\frac{\frac{2}{x}}{1} \,dx}}{\left(y_1\right)^2} \,dx\\
    & = y_1 \int \frac{ e^{-2 \ln \left(x \right)}}{\left(y_1\right)^2} \,dx\\
    &= y_1 \left(\tan \left(x \right)\right)
\end{align*}
Therefore the solution is
\begin{align*} 
y &= c_1 y_1 + c_2 y_2\\
  &= c_1 \frac{\cos \left(x \right)}{x} + c_2 \frac{\cos \left(x \right)}{x} \tan \left(x \right)\\
  &= c_1 \frac{\cos \left(x \right)}{x} + c_2 \frac{\sin \left(x \right)}{x} \\
\end{align*}

Another thing to also always try with non-constant coefficient is solving as Bessel ODE using Bowman method. This works if one is able to solve for the unknown using linear algebra solver
Start by writing the ode as
\begin{align*}
x^{2} y^{\prime \prime}\left(x \right)+2 x y^{\prime}\left(x \right)+x^{2} y \left(x \right) = 0\tag{1} 
\end{align*}
But Bessel ode has the form
\begin{align*}
x^{2} y^{\prime \prime}\left(x \right)+x y^{\prime}\left(x \right)+\left(-n^{2}+x^{2}\right) y \left(x \right) = 0\tag{2} 
\end{align*}
The generalized form of Bessel ode is given by Bowman (1958) is the following
\begin{align*}
x^{2} y^{\prime \prime}\left(x \right)+\left(1-2 \alpha \right) x y^{\prime}\left(x \right)+\left(\beta^{2} \gamma^{2} x^{2 \gamma}-n^{2} \gamma^{2}+\alpha^{2}\right) y \left(x \right) = 0\tag{3}
\end{align*}
With is standard solution being
\begin{align*}
y \left(x \right)&=x^{\alpha} \left(c_{1} \operatorname{BesselJ} \left(n , \beta  \,x^{\gamma}\right)+c_{2} \operatorname{BesselY} \left(n , \beta  \,x^{\gamma}\right)\right)\tag{4}
\end{align*}
Comparing (3) to (1) and solving for $\alpha,\beta,n,\gamma$ gives (little algebra)
\begin{align*}
     \alpha &= -{\frac{1}{2}}\\ 
     \beta &= 1\\ 
n &= {\frac{1}{2}}\\ 
\gamma&= 1
\end{align*}
Substituting all the above into (4) gives
\begin{align*}
\frac{1}{\sqrt x}\left(c_1 \operatorname{BesselJ}\left(\frac{1}{2},x\right)
+ \operatorname{BesselY}\left(\frac{1}{2},x\right)\right) \tag{5}
\end{align*}
But
\begin{align*}
\operatorname{BesselJ}\left(\frac{1}{2},x\right)&=\frac{\sqrt{2}\, \sin \left(x \right)}{\sqrt{\pi}\, \sqrt{x}}\\
\operatorname{BesselY}\left(\frac{1}{2},x\right) &= -\frac{\sqrt{2}\, \cos \left(x \right)}{\sqrt{\pi}\, \sqrt{x}}
\end{align*}
Hence (5) becomes
\begin{align*}
y \left(x \right) = \frac{c_{1} \sqrt{2}\, \sin \left(x \right)}{x \sqrt{\pi}}-\frac{c_{2} \sqrt{2}\, \cos \left(x \right)}{x \sqrt{\pi}}
\end{align*}
The constants can be rewritten and the above becomes
\begin{align*}
y \left(x \right) &= C_{1} \frac{\sin \left(x \right)}{x }+ C_{2} \frac{\cos \left(x \right)}{x}
\end{align*}
A: Assume a solution with power series and derivatives
$$y(x) = \sum_{n\ge0} a_n x^n \implies y'(x) = \sum_{n\ge0} (n+1) a_{n+1} x^n \implies y''(x) = \sum_{n\ge0} (n+1) (n+2) a_{n+2} x^n$$
Putting these into the ODE yields
$$\begin{align*}
0 &= y'' + \frac2x y' + y \\[1ex]
&= xy'' + 2y' + xy \\[1ex]
&= \sum_{n\ge0} (n+1)(n+2) a_{n+2} x^{n+1} + 2 \sum_{n\ge0} (n+1) a_{n+1} x^n + \sum_{n\ge0} a_n x^{n+1} \\[1ex]
&= \sum_{n\ge1} n(n+1) a_{n+1} x^n + 2 \sum_{n\ge0} (n+1)a_{n+1} x^n + \sum_{n\ge1} a_{n-1}x^n \\[1ex]
&= 2a_1 + \sum_{n\ge1} \bigg((n+2)(n+1) a_{n+1} + a_{n-1}\bigg) x^n \\[1ex]
\end{align*}$$
Let $a_0=A$. The coefficients are governed by the recurrence
$$\begin{cases}a_0 = A \\ 2a_1 = 0 \\ (n+2)(n+1)a_{n+1} + a_{n-1} = 0 & n\ge1\end{cases} \iff \begin{cases}a_0 = A \\ a_1 = 0 \\ a_n = -\frac{a_{n-2}}{n(n+1)} & n\ge2\end{cases}$$
and we have for $k\in\Bbb N$,
$$\begin{cases} a_{2k-1} = 0 \\ a_{2k} = \frac{(-1)^k}{(2k+1)!} A\end{cases}$$
so that a fundamental solution to the ODE is
$$y_1(x) = \sum_{k\ge0} \frac{(-1)^k}{(2k+1)!} x^{2k} = \boxed{\frac{\sin(x)}x}$$

Reduce the order to find another solution. Let $y_2(x)=z(x)y_1(x)$. Substitute into the ODE and solve the subsequent linear equation.
$$\begin{align*}
0 &= x \left(z'' y_1 + 2z'{y_1}' + z{y_1}''\right) + 2 \left(z' y_1 + z {y_1}'\right) + x z y_1 \\[1ex]
&= z'' \sin(x) + 2z' \cos(x)\\[1ex]
&= w' \sin(x) + 2w \cos(x) & w(x) = z'(x) \\[1ex]
&= w' \sin^2(x) + w \sin(2x) \\[1ex]
&= \left(w \sin^2(x)\right)' \\[2ex]
\implies w(x) &= C_1 \csc^2(x) \\[2ex]
\implies z(x) &= C_1 \cot(x) + C_2
\end{align*}$$
Then the other fundamental solution is
$$y_2(x) = \cot(x) \cdot \frac{\sin(x)}x = \boxed{\frac{\cos(x)}x}$$
A: $$y''+\frac{2}{x}y'+y=0$$
$$xy''+2y'+xy=0$$
$$xy''+y'+y'+xy=0$$
$$(xy')'+y'+xy=0$$
$$(xy'+y)'+xy=0$$
$$(xy)''+xy=0$$
This is a linear second order DE with constant coefficients that you can easily integrate.
$$r^2+1=0 \implies r=\pm i$$
$$xy(x)=C_1\cos x +C_2 \sin x$$
$$\boxed {y(x)=\dfrac 1 x (C_1\cos x +C_2 \sin x)}$$
