I was learning to solve differetial equations, using power series. There was a problem given as:
Solve the following differential equation using power series :$$(x-1)y''+xy'+\frac yx=0.$$
I tried solving the problem in the following way:
Assuming, $y=\Sigma_{n=0}^\infty c_nx^n$ to be a solution of $(x-1)y"+xy'+\frac yx=0.$ Now, $y'=\Sigma_{n=1}^\infty n c_nx^{n-1}$ and $y''=\Sigma_{n=2}^\infty n(n-1) c_nx^{n-2}.$ Substituting these in the given equation, we get, $$(x-1)\Sigma_{n=2}^\infty n(n-1) c_nx^{n-2}+x\Sigma_{n=1}^\infty n c_nx^{n-1}+\frac 1x\Sigma_{n=0}^\infty c_nx^n=0\implies x\Sigma_{n=2}^\infty n(n-1) c_nx^{n-2}-\Sigma_{n=2}^\infty n(n-1) c_nx^{n-2}+x\Sigma_{n=1}^\infty n c_nx^{n-1}+\frac 1x\Sigma_{n=0}^\infty c_nx^n=0\implies \Sigma_{n=2}^\infty n(n-1) c_nx^{n-1}-\Sigma_{n=2}^\infty n(n-1) c_nx^{n-2}+\Sigma_{n=1}^\infty n c_nx^{n}+ \Sigma_{n=0}^\infty c_nx^{n-1}=0.$$ Reindexing the summations we get, $$\Sigma_{n=0}^\infty (n+2)(n+1) c_{n+2}x^{n+1}-\Sigma_{n=0}^\infty (n+2)(n+1) c_{n+2}x^{n}+\Sigma_{n=0}^\infty (n+1) c_{n+1}x^{n+1}+ \Sigma_{n=0}^\infty c_nx^{n-1}=0.$$ Again, $$\Sigma_{n=0}^\infty (n+2)(n+1) c_{n+2}x^{n+1}-\Sigma_{n=0}^\infty (n+2)(n+1) c_{n+2}x^{n}+\Sigma_{n=0}^\infty (n+1) c_{n+1}x^{n+1}+ \Sigma_{n=0}^\infty c_nx^{n-1}=0\implies \Sigma_{n=1}^\infty (n+1)(n) c_{n+1}x^{n}-\Sigma_{n=0}^\infty (n+2)(n+1) c_{n+2}x^{n}+\Sigma_{n=1}^\infty (n) c_{n}x^{n}+ \Sigma_{n=-1}^\infty c_{n+1}x^{n}=0\implies \Sigma_{n=1}^\infty [(n+1)(n) c_{n+1}x^{n}- (n+2)(n+1) c_{n+2}x^{n}+(n) c_{n}x^{n}+ c_{n+1}x^{n}]+2c_2+\frac {c_0}{x}+c_1=0.$$ Now, the right-hand side of the equation is free of $x^{-1}$ term due to which, $c_0=0.$ So, $ \Sigma_{n=1}^\infty [(n+1)(n) c_{n+1}x^{n}- (n+2)(n+1) c_{n+2}x^{n}+(n) c_{n}x^{n}+ c_{n+1}x^{n}]+2c_2+\frac {c_0}{x}+c_1=0\implies \Sigma_{n=1}^\infty [(n+1)(n) c_{n+1}- (n+2)(n+1) c_{n+2}+(n) c_{n}+ c_{n+1}]x^n+2c_2+c_1=0.$ Now, comparing LHS and RHS of the equation, we can say that $2c_2+c_1=0$ and $ (n+1)(n) c_{n+1}- (n+2)(n+1) c_{n+2}+(n) c_{n}+ c_{n+1}=0.$ Thus, $c_2=-\frac{c_1}{2}.$ For $n\geq 1,$ we have, $ (n+1)(n) c_{n+1}- (n+2)(n+1) c_{n+2}+(n) c_{n}+ c_{n+1}=0\implies (n^2+n+1) c_{n+1}- (n+2)(n+1) c_{n+2}+n c_{n}=0\implies -(n^2+n+1) c_{n+1}+(n+2)(n+1) c_{n+2}-n c_{n}=0\implies (n+2)(n+1) c_{n+2}-(n^2+n+1) c_{n+1}-n c_{n}=0.$
I don't know how to proceed further since, the equation $ (n+1)(n) c_{n+1}- (n+2)(n+1) c_{n+2}+(n) c_{n}+ c_{n+1}=0,$ is a recurrence relation though, but how to find the coefficient $c_n$ here ? I am not getting, how to solve this recurrence relation in order to find $c_n$? (I am just a beginner and I need an elementary level explanation of this.) I am skeptical , whether at all a power series solution exists or not. (I found this problem in a handout, so I don't know about the source. If anyone does know about it, please do let me know.)
There might be several posts, concerning the same topic, but I can't seem to find it either.
My attempt is modified after Elliot Yu's beautiful suggestion
You have gotten quite far with the method actually, by plugging in the ansatz $\sum_{n=0}^\infty c_n x^n$ and simplifying, and seem to be aware of what to do next, namely deriving a recurrence relation for $c_n$ and ultimately solving it for the series coefficients. Where you are stuck seems to be at the step of "collecting like powers of $x$ and equating the coefficients to zero", as indicated by your observation "the powers of $x$ aren't alike". Thus I would like to address this step specifically.
With a sum like $\sum_{n=0}^\infty c_n x^{n-1}$ (the last term), we can actually rearrange it into a sum where the general term is expressed in terms of $x^n$ rather than $x^{n-1}$ by shifting the indices. Substitute $n - 1$ by $n$, i.e. make the transformation $n\mapsto n + 1$, the general term $c_n x^{n-1}$ becomes $c_{n + 1} x^n$, and the lower bound becomes $n = - 1$ while the upper bound is still $n\to \infty$. This gives us the sum $\sum_{n=-1}^\infty c_{n+1} x^{n}$. (If this manipulation is confusing, think of it as a two-step process, first a substitution $n = m + 1$, and then relabeling the new dummy variable $m$ as $n$ again. You can also check the first few terms of each sum to see that they are indeed the same.) The same can be done for the first and third terms, namely shifting the power of $x$ down by $1$, by shifting the index $n\mapsto n-1$.
The only thing you need to watch out for are the $x^{-1}$ and $x^0$ terms in the sum, because now the sums don't have the same lower bounds, so the initial cases of the recurrence relation will be different. However, this is precisely what you will need to solve for $c_0$ and $c_1$, the initial conditions needed to solve the second order recurrence relations for all the coefficients.