Showing a series is a solution to a differential equation I am attempting to show that the series $y(x)\sum_{n=0}^{\infty} a_{n}x^n$ is a solution to the differential equation $(1-x)^2y''-2y=0$ provided that $(n+2)a_{n+2}-2na_{n+1}+(n-2)a_n=0$
So i have:
$$y=\sum_{n=0}^{\infty} a_{n}x^n$$
$$y'=\sum_{n=0}^{\infty}na_{n}x^{n-1}$$
$$y''=\sum_{n=0}^{\infty}a_{n}n(n-1)x^{n-2}$$
then substituting these into the differential equation I get:
$$(1-2x+x^2)\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n-2}-2\sum_{n=0}^{\infty} a_{n}x^n=0$$
$$\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n-2}-2\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n-1}+\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n}-2\sum_{n=0}^{\infty} a_{n}x^n=0$$
relabeling the indexes: 
$$\sum_{n=-2}^{\infty}(n+2)(n+1)a_{n+2}x^{n}-2\sum_{n=-1}^{\infty}n(n+1)a_{n+1}x^{n}+\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n}-2\sum_{n=0}^{\infty} a_{n}x^n=0$$
and then cancelling the $n=-2$ and $n=-1$ terms:
$$\sum_{n=0}^{\infty}(n+2)(n+1)a_{n+2}x^{n}-2\sum_{n=0}^{\infty}n(n+1)a_{n+1}x^{n}+\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n}-2\sum_{n=0}^{\infty} a_{n}x^n=0$$
but this doesn't give me what I want (I don't think) as I have $n^2$ terms as I would need
$(n^2+3n+2)a_{n+2}-(2n^2+n)a_{n+1}+(n^2-n-2)a_{n}=0$
I'm not sure where I have gone wrong?
Thanks very much for any help
 A: Everything seems correct. Before you expand out powers of $n$, notice that equating like powers of $x^n$ in your last sum gives:
$(n+2)(n+1)a_{n+2}-2n(n+1)a_{n+1}+[n(n-1)-2]a_n=0$
Notice that $[n(n-1)-2]=n^2-n-2=(n+1)(n-2)$, so since $n\geq 0$, you can divide the recurrence equation by $(n+1)$ to get the desired result.
A: You are correct.
Only you need to go on and observe that the lhs of your last equation factorizes as: $$(n+1)[(n+2)a_{n+2}-2n a_{n+1}+(n-2)a_n]$$
A: You are right till the last step.
You have $$\sum_{n=0}^{\infty}(n+2)(n+1)a_{n+2}x^{n}-2\sum_{n=0}^{\infty}n(n+1)a_{n+1}x^{n}+\sum_{n=0}^{\infty}n(n-1)a_{n}x^{n}-2\sum_{n=0}^{\infty} a_{n}x^n=0$$
which gives us
$$\sum_{n=0}^{\infty} \left((n+2)(n+1) a_{n+2} - 2 n (n+1) a_{n+1} + (n^2-n-2)a_n \right)x^n = 0$$
and not 
$$\sum_{n=0}^{\infty} \left((n+2)(n+1) a_{n+2} - (2n^2+n) a_{n+1} + (n^2-n-2)a_n \right)x^n = 0$$
as you have written.
Hence, setting the coefficients of $x^n$ to zero, we get that 
$$\left((n+2)(n+1) a_{n+2} - 2 n (n+1) a_{n+1} + (n^2-n-2)a_n \right)=0$$
Factorizing $n+1$ out, we get what you need i.e.
$$\left((n+2)(n+1) a_{n+2} - 2 n (n+1) a_{n+1} + (n^2-n-2)a_n \right)= (n+1) \left((n+2) a_{n+2} - 2 n a_{n+1} + (n-2)a_n \right)$$
Hence, we get that $$(n+2) a_{n+2} - 2 n a_{n+1} + (n-2)a_n = 0$$
