Solve boundary value problem $x^2y'' + 3xy' + y = x^2$ Problem
$x^2y'' + 3xy' + y = x^2$ 
BC: $y(1) = 0, y(e) = 0$
I tried to first solve for the homogenous solution, but I get a really weird equation to solve for values of r. How do you solve the above equation?
My Work
$y=e^{rx} \\
x^2r^2 + 3xr + 1 = x^2 \\
x^2r^2 + 3xr + 1-x^2 = 0 \\
r = \frac{-3x \pm \sqrt{9x^2-4(1-x^2)x^2}}{2x^2}
$
 A: $$x^2\frac{d^2y}{dx^2} +3x\frac{dy}{dx} + y = x^2$$
This is known as an Euler Equation - differential equations where the degree of $x$ matches the order of the derivative. They can be solved using  the change of variable $x= e^z$
So we get $$x\frac{dy}{dx} = \frac{dy}{dz}$$
and $$x^2\frac{d^2y}{dx^2}= \frac{d^2y}{dz^2} -\frac{dy}{dz}$$
Substituting this in, you should find that the coefficients of $x$ cancel out, and you get a more easily solved ODE. 
You should end up with this ODE:
$$\frac{d^2y}{dz^2} -\frac{dy}{dz} + 3\frac{dy}{dz} + y = e^{2z}$$
$$\frac{d^2y}{dz^2} + 2\frac{dy}{dz} + y = e^{2z}$$
Auxilliary equation:
$$\lambda ^2 +2\lambda + 1 = 0$$
$$\implies \lambda = -1$$
So $$y_{CF} = c_{1}e^{-z}+c_{2}ze^{-z}$$
Then we try $$y_{PI} = Ae^{2z}$$
Substituting into our ODE:
$$\implies (4A+4A+A)e^{2z} = e^{2z} \implies A=\frac{1}{9}$$
$$y_{GS} = c_{1}e^{-z}+c_{2}ze^{-z} + \frac{1}{9}e^{2z}$$
Changing back in terms of $x$, we have $z = \ln x$
$$y_{GS} = c_{1}e^{\ln(x^{-1})}+c_{2}\ln (x)e^{\ln (x^{-1})} + \frac{1}{9}e^{\ln (x^{2})}$$
$$y_{GS} = \frac{c_{1}}{x} + \frac{c_{2}\ln x}{x} + \frac{x^2}{9}$$
$$y(1) = 0 \implies  c_{1} + \frac{1}{9} = 0 \implies c_{1} = - \frac{1}{9}$$
$$y(e) = 0 \implies -\frac{1}{9e} +\frac{c_{2}}{e} +\frac{e^2}{9} = 0$$
$$c_{2} = \frac{1}{9}(1-e^3)$$
So $$y_{PS} = -\frac{1}{9x} + \frac{1}{9}(1-e^3)\cdot \frac{\ln x}{x} + \frac{x^2}{9}$$
$$y_{PS} = \frac{1}{9}(-\frac{1}{x} + \frac{(1-e^3)\ln x}{x} + x^2)$$
A: If you don't want to use a change of variables Cauchy-Euler equations can also be easily solved using $y = x^m$. Successive derivatives give $y' = m x^{m-1}$ and $y'' = m(m-1)x^{m-2}$. Plugging these into the homogeneous equation $x^2y'' + 3xy' + y = 0$ reduces to 
$$m(m-1) + 3m +1 = 0$$
which gives a repeated root of $m = -1$. The homogeneous solution is then
$$y_c = C_1 x^{-1} + C_2 x^{-1} \ln x$$
If you're not sure why the $\ln x$ term appears take the solution $y_1 = x^{-1}$ and find a second solution using $y_2 = u(x) x^{-1}$, where $u(x)$ is some unknown function. $u(x) = \ln x$ for Cauchy-Euler equations.
To find the particular solution I'd suggest using variation of parameters for this example. An equation of the form 
$$y'' + p(x) y' + q(x)y = g(x)$$
has a particular solution
$$y_p = u_1(x)y_1 + u_2(x) y_2$$
where $y_1$ and $y_2$ are the two linearly independent solutions to the homogeneous equation and $u_1(x)$ and $u_2(x)$ are given by
$$u_1(x) = \int \dfrac{-y_2 g(x)}{W(y_1,y_2)}dx$$
and
$$u_2(x) = \int \dfrac{y_1 g(x)}{W(y_1,y_2)}dx$$
where $W(y_1,y_2)$ is the Wronskian.
Convert 
$$x^2y'' + 3xy' + y = x^2$$ 
to 
$$y'' + p(x) y' + q(x)y = g(x)$$ 
by dividing by $x^2$, which gives
$$y'' + \dfrac{3}{x} y' + \dfrac{1}{x^2} = 1$$
Take $y_1 = x^{-1}$, $y_2 = x^{-1} \ln x$, and $g(x) = 1$, calculate the Wronskian, and you're basically done.
