Solving $y'' - xy'+(3x-2)y=0$ using power series

I am trying to solve this equation using the series $$\sum_0^\infty a_nx^n$$

$$y'' - xy'+(3x-2)y=0$$

How to do that? I mean that I can replace the variables using the series but then I cannot add this thing cause the limits of the sums are not the same. Maybe I am doing something wrong here. I tried to make all sums start from $0$ with $x^{n+1}%$. This will leave $2a_2 - 2a_0 + \sum\dots = 0$ and I don't know what to do. I can't just say that $2a_2 = 2a_0 = 0$ cause it may be $2a_2 - 2a_0 = 0$. Well I am really confused.

-
For example $y''=\sum\limits_{n=2}^\infty n(n-1)a_n x^{n-2}=\sum\limits_{k=0}^\infty (k+2)(k+1)a_{k+2} x^k$ Here I used change of indexes $n=k+2$ –  Norbert Jan 26 '12 at 9:11
Yes, I did these transformations. Then I changed it to $2a_2 + \sum\limits_{k=0}^\infty (k+3)(k+2)a_{k+3} x^{k+1}$ in order to add all the sums. –  tamakisnen Jan 26 '12 at 9:16
Ok, I'll try to write an answer. –  Norbert Jan 26 '12 at 9:23
You need extra information, such as knowing $y(0)$ and $y'(0)$. For example $a_0=y(0)$ and you have deduced that $a_2=a_0$. –  Henry Jan 26 '12 at 9:37

Let $$y=\sum\limits_{n=0}^\infty a_n x^n$$ then by a straightforward computation we get $$y''-xy'+(3x-2)y=\sum\limits_{n=2}^\infty n(n-1)a_n x^{n-2}-x\sum\limits_{n=1}^\infty n a_n x^{n-1}+3x\sum\limits_{n=0}^\infty a_n x^n-2\sum\limits_{n=0}^\infty a_n x^n=$$ $$\sum\limits_{n=0}^\infty (n+2)(n+1)a_{n+2} x^n-\sum\limits_{n=0}^\infty n a_n x^n+\sum\limits_{n=0}^\infty 3a_n x^{n+1}-2\sum\limits_{n=0}^\infty a_n x^n$$ Now note that if we take by definition $a_{-1}=0$ we get $$\sum\limits_{n=0}^\infty 3a_n x^{n+1}=\sum\limits_{n=0}^\infty 3a_{n-1} x^n$$ So $$y''-xy'+(3x-2)y= \sum\limits_{n=0}^\infty (n+2)(n+1)a_{n+2} x^n-\sum\limits_{n=0}^\infty n a_n x^n+\sum\limits_{n=0}^\infty 3a_{n-1} x^n-2\sum\limits_{n=0}^\infty a_n x^n=$$ $$\sum\limits_{n=0}^\infty\left((n+2)(n+1)a_{n+2}-(n+2)a_n+3a_{n-1}\right)x^n$$ And we get a recurrence equation equation for determining $a_n$: $$(n+2)(n+1)a_{n+2}-(n+2) a_n+3a_{n-1}=0$$ where $a_{-1}=0$ and $a_0=y(0)$, $a_1=y'(0)$. Now taking $n=0$ you can determine $a_2$, taking $n=1$ you can determine $a_3$ et cetera...

Honestly, I don't think that this recurrence equations have an explicit solution. Even Mathematica doesn't have any idea

On the other hand, Mathematica gives an explicit solution for the original differential equation: $$y(x)=\frac{e^{3 x}}{96 \sqrt{(x-6)^2}}$$ $$\begin{multline}\Biggl(\sqrt{2 \pi } c_2 \left(x^6-36 x^5+519 x^4-3816 x^3+15009 x^2-29772 x+23115\right)(x-6)^2 \text{erfi}\left(\frac{\sqrt{(x-6)^2}}{\sqrt{2}}\right)\\ +2 \sqrt{(x-6)^2} \left(384 \sqrt{2} c_1 \left(x^7-42 x^6+735 x^5-6930 x^4+37905 x^3-119826 x^2+201747 x-138690\right)-c_2 e^{\frac{1}{2} (x-6)^2} \left(x^6-36 x^5+520 x^4-3840 x^3+15207 x^2-30420 x+23820\right)\right)\Biggr) \end{multline}$$ After looking at this monster I think one can not get an explicit solution for that recurrence equation.

-
$n = 0 -> a_2 = a_0$ $n = 1 -> a_3 = \frac{a_1- a_2}{2}$ $n = 2 -> a_4 = \frac{4a_0- 3a_1}{12}$ $n = 3 -> a_5 = \frac{5a_1- 11a_0}{40}$ I haven't faced this situation before. So how to form the solution from this? –  tamakisnen Jan 26 '12 at 13:45

One thing that the Mathematica solution seems to be telling you is that the best point to expand around may be $x=6$ rather than $x=0$. In fact, under the change of variables $x=t+6$, $y(x) = e^{3t} u(t)$ the DE becomes $$u'' - t u' + 7 u = 0$$ A fundamental set of solutions of this consists of $t - t^3 + t^5/5 - t^7/105$ and $$\sum _{k=0}^{\infty }{\frac {{2}^{-k}}{ \left( 2\,k-1 \right) \left( 2\,k-3 \right) \left( 2\,k-5 \right) \left( 2\,k-7 \right) k!}} t^{2k}$$

EDIT: This begs for a generalization. The change of variables $x = t + a$, $y(x) = e^{bt} u(t)$ takes the DE $y'' + (c x + d) y' + (e x + f) y = 0$ to $u'' + (c t + 2b + d + a c) u' + ((cb+e)t + b^2+ea+bd+abc+f) u = 0$. Solving $2b+d+ac = 0$ and $cb+e=0$ for $a$ and $b$, we find that if $c \ne 0$, for $a = \frac{2e}{c^2} - \frac{d}{c}$, $b = -\frac{e}{c}$ the equation is transformed to $u'' + c t u' + A u = 0$ where $A = \frac{e^2}{c^2} - \frac{de}{c} + f$.

-