I am going through old exam questions for my upcoming exam, but got stuck on a question since I don't really understand the solution.
The question I have a problem with (in boldface):
(b) Let the sequence $a_n$ be given by the recurrence relation $$a_{n+2} =2a_{n+1} +a_n, \qquad a_1=1, a_2=3.$$ (i) Calculate $a_3$, $a_4$ and $a_5$.
(ii) Prove that the generating function for the sequence is $$\boldsymbol{ A(x) =\sum_{n=1}^\infty a_n x^n = \dfrac{x+x^2}{1-2x-x^2}.}$$
and the solution:
(ii) Multiply each side of the recurrence by $x^{n+2}$ and sum over $n$ to get $$\sum_{n=1}^\infty a_{n+2} x^{n+2} =2 \sum_{n=1}^\infty a_{n+1} x^{n+2} +\sum_{n=1}^\infty a_n x^{n+2}.$$ Change summation index $$\sum_{n=2}^\infty a_{n} x^{n} =2x \sum_{n=1}^\infty a_{n} x^{n} +x^2 \sum_{n=0}^\infty a_n x^{n}.$$ Add/subtract missing terms $$A(x) -a_1 x -a_2 x^2 =2x(A(x)-a_1 x) +x^2 A(x)\\ \implies \quad A(x)-x-3x^2 =2x(A(x)-x) +x^2A(x)\\ \implies \quad A(x) (1-2x-x^2) =x +3x^2 -2x^2 =x +x^2\\ \implies \quad A(x) =\dfrac{x+x^2}{1-2x-x^2}.$$
My problem is that I can't wrap my head around how the index-shifting works. I think the first summation (after the index-shifting) should start from $n=3$, since it seems like they set $k = n+2$. I'd be really thankful if someone could explain how it works. I understand everything else. Thank you!
Yes, you are right, after the "change summation index", we shoud have $$\sum_{n=3}^\infty a_{n} x^{n} =2x \sum_{n=2}^\infty a_{n} x^{n} +x^2 \sum_{n=1}^\infty a_n x^{n}.$$ that is $$A(x)−a_1x−a_2x^2=2x(A(x)−a_1x)+x^2A(x)$$ where $A(x)=\sum_{n=1}^\infty a_n x^{n}$. The rest of the proof is correct.