TITLE: Solving a 2nd order DE (non-constant coefficients)
QUESTION [5 upvotes]: I am having trouble solving the following differential equation: 
$$y''+(x^2-1)y'+2xy=0$$
To start off I employed the power-series method, so let 
$$y=\sum_{n=0}^{\infty}a_nx^n$$
$$y'=\sum_{n=1}^{\infty}na_nx^{n-1}$$
$$y''=\sum_{n=2}^{\infty}n(n-1)a_nx^{n-2}$$
Next I plugged my power-series into my original DE:
$$\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-1}+\sum_{n=0}^{\infty}2a_nx^{n+1}=0$$
When I matched the powers of $x$ I ended up with the following equation:
$$\sum_{n=0}^{\infty}(n+2)(n+1)a_{n+2}x^n+\sum_{n=2}^{\infty}(n-1)a_{n-1}x^n-\sum_{n=0}^{\infty}(n+1)a_{n+1}x^n+\sum_{n=1}^{\infty}2a_{n-1}x^n=0$$
Next I tried to match the indeces, so naturally I took out the first 2 terms from $\sum_{n=0}^{\infty}(n+2)(n+1)a_{n+2}x^n$, the first 2 terms from $\sum_{n=0}^{\infty}(n+1)a_{n+1}x^n$, and the first term from $\sum_{n=1}^{\infty}2a_{n-1}x^n$.
At this point I end up with 2 recurrence relations:
$$2a_2+6a_3x-a_0-2a_2x+2a_0x=0$$
$$(n+2)(n+1)a_{n+2}+(n-1)a_{n-1}-(n+1)a_{n+1}+2a_{n-1}=0$$
And here I am completely lost, normally what I would do is solve for one of the first $a_n$ terms but since I've got $x$'s in the first recurrence I can't really see how that would work. Perhaps there is a much simpler method that I can use? This is just practice for my ODE final exam.

REPLY [3 votes]: Hint:
Notice that $(x^2-1)'=2x$, hence
$$y''+(x^2-1)y'+2xy=(y'+(x^2-1)y)'=0.$$

 Par résolution of the first-order linear equation, $$y=e^{x-x^3/3}\left(C_2+C_1\int e^{x^3/3-x}dx\right).$$