Solve this differential equation via power series

ordinary differential equationspower series

Studying Quantum Mechanics, I encountered the following differential equation:

how to solve $$y''-x^2y=0$$
Griffiths, the author of the book, just said that its solutions are
$$y=Ae^{x^2/2}+Be^{-x^2/2}$$
I can immediatelly see that this is true, but I do not know how to get to this solution, and I cannot find it solved anywhere else.
I tried to use the power series method:
$$y=\sum_{n=0}^{\infty}c_n x^n$$
So the equation becomes:
$$\sum_{n=0}^{\infty}c_{n+2}x^n(n+1)(n+2)-\sum_{n=0}^{\infty}c_n x^{n+2}=0$$
Here I need to get both sums to the same power of n, so I removed the first two terms from the first sum, so that I can later change the index:
$$2c_2+6c_3x+\sum_{n=2}^{\infty}c_{n+2}x^n(n+1)(n+2)-\sum_{n=0}^{\infty}c_n x^{n+2}=0$$
now I change the index in the fist sum:
$$2c_2+6c_3x+\sum_{n=2}^{\infty}c_{n+4}x^{n+2}(n+4)n(n+3)-\sum_{n=0}^{\infty}c_n x^{n+2}=0$$
Now I factor out the sum:
$$2c_2+6c_3x+\sum_{n=2}^{\infty}x^{n+2}(c_{n+4}(n+4)(n+3)-c_n)=0$$
Now all three terms must be zero at the same time, so $c_2=c_3=0$, and:
$$c_{n+4}(n+4)(n+3)-c_n=0$$
$$c_{n+4}=\frac{c_n}{(n+4)(n+3)}$$
The first terms of the series are:
$c_4=\frac{c_0}{4\times 3}$, $c_8=\frac{c_4}{8\times 7}=\frac{c_0}{8\times 7\times 4\times 3}$
However, I don't really know how to proceed from here. I tried putting the coefficients into the sum for $y$, but I can't really come close to the answer. Could you please guide me as how to advance from here?

Best Answer

Check that

$y(x)=A e^{-x^2/2}$ is solution of $$\frac{y''(x)}{y(x)}=x^2-1$$ and $y(x)=B e^{x^2/2}$ is solution of $$\frac{y''(x)}{y(x)}=x^2+1$$ It is in this sense Griffith has claimed that $$\psi(x)=A e^{-x^2/2}+ B e^{x^2/2}~~~~(1)$$ is only APPROXIMATE solution of $$\psi''(x)-x^2\psi(x)=0~~~~~~~(2)$$

So please note that (1) is not the exact solution of (2) instead it is an APPROXIMATE solution of (2).