<s>[INST] Solution the ode $x^2y''+4xy'+2y=f(x)$ I'm trying to find a solution for the second order ode $x^2y''+4xy'+2y=f(x)$, where $f\in\mathcal{C}^1(\mathbb{R})$.
I already found that the solution for the homogeneous part is equal to
$y_h(x)=\frac{C_1}{x^2}+\frac{C_2}{x}$. But now I'm stuck trying to get the nonhomogeneous solution for this equation. I tried substituting $y=f(x)$ but this leads me to nowhere.
Any help is greatly appriciated.
 [/INST] If you say that $y = f(x)$ you can solve it like this (homogeneous):
step 2: Assume a solution to this Euler-Cauchy equation will be proportional to for some constant $λ$. Substitute $y(x) := x^{λ}$ into the differentialequation.
$$
\begin{align*}
f(x) &= x^{2} \cdot y'' + 4 \cdot x \cdot y' + 2 \cdot y\\
y &= x^{2} \cdot y'' + 4 \cdot x \cdot y' + 2 \cdot y \quad\mid\quad \text{step 2}\\
0 &= x^{2} \cdot {x^{λ}}'' + 4 \cdot x \cdot {x^{λ}}' + x^{λ}\\
0 &= x^{2} \cdot \frac{\operatorname{d}^{2}}{\operatorname{d}x^{2}}x^{λ} + 4 \cdot x \cdot \frac{\operatorname{d}}{\operatorname{d}x}x^{λ} + x^{λ} \quad\mid\quad \frac{\operatorname{d}^{2}}{\operatorname{d}x^{2}}x^{λ} := λ \cdot (λ - 1) \cdot x^{λ - 2} \text{ and } \frac{\operatorname{d}}{\operatorname{d}x}x^{λ} = λ \cdot x^{λ - 1}\\
0 &= x^{2} \cdot λ \cdot (λ - 1) \cdot x^{λ - 2} + 4 \cdot x \cdot λ \cdot x^{λ - 1} + x^{λ}\\
0 &= λ^{2} \cdot x^{λ} + 3 \cdot λ \cdot x^{λ} + x^{λ}\\
0 &= (λ^{2} + 3 \cdot λ + 1) \cdot x^{λ} \quad\mid\quad\text{solve for } λ \text{ with assuming } x \ne 0 \\
0 &= (λ^{2} + 3 \cdot λ + 1) \cdot x^{λ} \quad\mid\quad\text{Zero product theorem}\\
0 &= (λ^{2} + 3 \cdot λ + 1) \cdot x^{λ} \quad\mid\quad\text{solve for } λ \\
0 &= λ^{2} + 3 \cdot λ + 1 \quad\mid\quad \text{use the pq formula}\\
λ &= - \frac{3}{2} \pm \sqrt{\frac{5}{4}}\\
λ &= - \frac{3}{2} \pm \frac{\sqrt{5}}{2}\\
\\
y_{1} &= \mathrm{c}_{1} \cdot x^{- \frac{3}{2} + \frac{\sqrt{5}}{2}}\\
y_{2} &= \mathrm{c}_{2} \cdot x^{- \frac{3}{2} - \frac{\sqrt{5}}{2}}\\
\\
y &= y_{1} + y_{2} = \mathrm{c}_{1} \cdot x^{- \frac{3}{2} + \frac{\sqrt{5}}{2}} + \mathrm{c}_{2} \cdot  x^{- \frac{3}{2} - \frac{\sqrt{5}}{2}}
\end{align*}
$$
If you want to to it with a nonhomogeneous function...
step 3: Try $t := \log(t) \Rightarrow x := e^{t}$:
$$
\begin{align*}
f(x) &= x^{2} \cdot y'' + 4 \cdot x \cdot y' + 2 \cdot y\\
y &= x^{2} \cdot y'' + 4 \cdot x \cdot y' + 2 \cdot y \quad\mid\quad \text{step 2}\\
y &= e^{2 \cdot t} \cdot y'' + 4 \cdot e^{t} \cdot y' + 2 \cdot y\\
y(t) &= \frac{\operatorname{d}^{2}}{\operatorname{d}t^{2}}y(t) + 3 \cdot \frac{\operatorname{d}}{\operatorname{d}t}y(t) + 2 \cdot y(t)\\
0 &= \frac{\operatorname{d}^{2}}{\operatorname{d}t^{2}}y(t) + 3 \cdot \frac{\operatorname{d}}{\operatorname{d}t}y(t) + y(t)\\
0 &= \frac{\operatorname{d}^{2}}{\operatorname{d}t^{2}}e^{λ \cdot t} + 3 \cdot \frac{\operatorname{d}}{\operatorname{d}t}e^{λ \cdot t} + e^{λ \cdot t}\\
0 &= λ^{2} \cdot e^{λ \cdot t} + 3 \cdot λ \cdot e^{λ \cdot t} + e^{λ \cdot t}\\
0 &= (λ^{2} + 3 \cdot λ + 1) \cdot e^{λ \cdot t} \quad\mid\quad \text{Zero product theorem}\\
0 &= λ^{2} + 3 \cdot λ + 1 \quad\mid\quad \text{use the pq formula}\\
λ &= - \frac{3}{2} \pm \sqrt{\frac{5}{4}}\\
λ &= - \frac{3}{2} \pm \frac{\sqrt{5}}{2}\\
\\
y_{1}(t) &= \mathrm{c}_{1} \cdot e^{(- \frac{3}{2} + \frac{\sqrt{5}}{2}) \cdot t}\\
y_{2(t)} &= \mathrm{c}_{2} \cdot e^{(- \frac{3}{2} - \frac{\sqrt{5}}{2}) \cdot t}\\
\\
y &= x^{- \frac{3}{2} - \frac{\sqrt{5}}{2}} \cdot (\mathrm{c}_{1} + \mathrm{c}_{2} \cdot x^{\sqrt{5}})
\end{align*}
$$
</s>