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} $
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.