# Procedure for adaptive step size for Runge Kutta 4?

I am writing a Runga Kutta 4 algorithm in MATLAB. I would like to add adaptive step sizing to this algorithm.

From what I've read it seems you calculate the value of the function for two step sizes on each iteration and then from the size of the error terms you deduce which one to use as $y_{i+1}$. But I can't see any advantage in efficiency if you are calculating two potential $y_{i+1}$'s on each iteration.

Obviously I am missing/misinterpreted something as I have read that adaptive step sizing can lead to huge performance increases. So how does adaptive step sizing work for RK methods and can someone tell me the steps I need to implement?

-
Here is a related url on the complete treatment of RK methods for N-body problems (artcompsci.org/kali/vol/two_body_problem_2/title.html#TOC) – ja72 Nov 11 '12 at 16:55