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.
 A: HINT
You can rearrange the LHS in order to get:
\begin{align*}
x^{2}y'' + 4xy' + 2y & = (x^{2}y'' + 2xy') + (2xy' + 2y)\\\\
& = (x^{2}y')' + (2xy)'
\end{align*}
A: $$x^2y''+4xy'+2y=f(x)$$
Rewrite the DE as:
$$(x^2y)''=f(x)$$
A: 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*}
$$
A: Treat it as if it's a quadratic and you're searching for roots (this is not true, it's a second order ODE, but you'll notice that the following method feels familiar to you:)
Rewrite it like this:
$$ x^2y^{(2)}+4xy^{(1)}+2y-f(x)=0. $$
Notice how this is similar to $ax^2+bx+c=0$?
This has what is called a characteristic equation. The other user, Kevin Dietrich, has supplied the gist of the bruteforce to solving it.
I am answering this because I want you to know the origin of the terminology, notation, and the fact this is freely taught at Paul's Online Differential Equation notes---found elsewhere online.
SOLUTION:
Using the HINT given above, this can be solved with observation of the product rule $\alpha \beta)'=\alpha' \beta+\alpha \beta'$ for $$\alpha=y \implies \alpha'=y'$$ and $$\beta=x^2\implies \beta'=2x$$ which results in $$(\alpha \beta)'=f(x)$$ giving immediately $$\alpha \beta=\int f(x)dx$$ which should imply $\alpha=\frac{1}{\beta}\int f(x)dx$. Basically, $y=\alpha$.
I think this is correct, but I may be wrong. This is completely different from the usual brute force I initially suggested thanks to the HINT given by the other answer.
Update:
The original work is incomplete.
$$(x^2y')'+(2xy)'=f(x)$$ is a transformed differential equation of form $(g(x)y')'+(g'(x)y)'=f(x)$. This via letting $g(x)=x^2$ and consequently $\frac{d}{dx}g=2x$. However, the whole equation still has outer derivatives, so we must integrate the sum: $g(x)y'+g'(x)y=\int f(x)dx.$ So, the original part was off by a bit (a single integral). The solution is therefore:
$$g(x)y'+g'(x)y=\int f(x)dx\implies (gy)'=\int f(x)dx \implies gy=\int \int f dxdx$$
$$y=\frac{1}{g}\int\int fdxdx$$
