TITLE: Robust Numerical ODE Solver?
QUESTION [5 upvotes]: I made a little explicit Runge-Kutta 4th order solver a few days ago, but when testing it against various 1st and 2nd order ODEs chosen at random (for example $d^{2}y/dt^{2} = -y \sin(y)$, $d^{2}y/dt^{2} = -yt$ or $d^{2}y/dt^{2} = -y + t^{2}$) it seemed like most were stiff ODEs (unless the algorithm I'm using is incorrect), by comparing my output to that of Mathematica's NDSolve, and hence rendered my RK4 solver to be fairly useless. As such, I've decided to try and find a numerical solver that I can create, that is robust and can solve stiff and non-stiff ODEs. Does such an algorithm exist, or is it a case of the more robust a solver the more abstruse its algorithm becomes. Even better, is there such a thing as a universal solver that is able to solve any ODE you throw at it?
EDIT: Here's an example of my RK4 solver output for $d^{2}y/dt^{2} = -y \sin(y)$ using a step size of $h=0.005$:

And here's what I get from NDSolve:

REPLY [2 votes]: Yes, such algorithms exist.
Implicit multistep methods have been developed deliberately to solve stiff ODE problems. They might require an explicit method to initialize, but this is not an issue because you can scale your step size of your explicit solver in the stiff region rather unobtrusively.
In the non-stiff scales of a problem, the implicit multistep methods are computationally somewhat more expensive but ultimately will yield as an accurate a solution as something like an RK4 method.
Alternatively, you could just use an adaptive solver such as Runge-Kutta-Fehlberg or a Dormand-Prince 4(5) pair.