Find a power series solution to $$y''(x) + (1+x)y'(x) + x^2 y =0.$$
I have attached my attempt , but I don't understand how to arrive at the complete solution by simplification each term in terms of 2 arbitrary constants. Kindly help me out with this .


Let the solution to the differential equation be $$f(x)= \sum_{n=0}^{\infty}a_nx^n$$ $$\therefore f'(x)=\sum_{n=1}^{\infty}na_nx^{n-1} ;f''(x)=\sum_{n=2}^{\infty}n(n-1)a_nx^{n-2}$$ $$\therefore \sum_{n=2}^{\infty}n(n-1)a_nx^{n-2}+(1+x)\sum_{n=1}^{\infty}na_nx^{n-1}+x^2\sum_{n=0}^{\infty}a_nx^n=0$$ $$\therefore \sum_{n=2}^{\infty}n(n-1)a_nx^{n-2}+\sum_{n=1}^{\infty}na_nx^{n-1}+\sum_{n=1}^{\infty}na_nx^{n}+\sum_{n=0}^{\infty}a_nx^{n+2}=0$$ Reindexing the summations, $$\therefore \sum_{n=0}^{\infty}(n+2)(n+1)a_{n+2}x^{n}+\sum_{n=0}^{\infty}(n+1)a_{n+1}x^{n}+\sum_{n=0}^{\infty}(n+1)a_{n+1}x^{n+1}+\sum_{n=0}^{\infty}a_nx^{n+2}=0$$ Equating coefficients, we get $$2a_2+a_1=0$$ $$6a_3+2a_2+a_1=0 \implies a_3=0$$ $$(n+4)(n+3)a_{n+4}+(n+3)a_{n+3}+(n+2)a_{n+2}+a_n=0$$ $$\therefore n(n-1)a_n+(n-1)a_{n-1}+(n-2)a_{n-2}+a_{n-4}=0$$ Can you take it from here?