Cross posted in Mathematica.SE, I'll try to rephrase it in a more general way here.
A friend of mine showed me this initial value problem (IVP) for a linear ordinary differential equation (ODE) with variable coefficient:
$$y''(x)=\left(x^2-1\right) y(x)$$$$y(0)=1$$$$y'(0)=0$$
Seems to be a simple one, right? Actually it can be solved analytically and the solution is:
$$y(x)=e^{-\frac{x^2}{2}}$$
But when I tried to solve it with the classical Runge–Kutta method, the numerical solution blows up:
The step size used here is 0.001.
Why did this happen? If I've chosen an improper method, what's a suitable one?
NDSolve
, it's impossible to give an explanation, much less a solution. Is there some diagnostic information you can obtain (e.g., which integrator is used, how are the time steps chosen, are any error estimators used)? Otherwise I would say the question is off-topic here, since it requires in-depth Mathematica knowledge to answer. $\endgroup$NDSolve
isn't really the issue here. I've clarified a little, have a look. $\endgroup$