def rk5_stepper(x, h, y, deriv, errors=False):
    """ Compute y(x+h) from y and dy/dx=deriv(x,y).

    Uses a one-step 5th-order Runge-Kutta algorithm.

    Returns x+h, y(x+h) if errors is False; otherwise
    returns x+h, y(x+h), yerr where yerr is an error
    estimate.

    Adapted from Numerical Recipes.
    """
    k1 = h * deriv(x, y)
    k2 = h * deriv(x + 0.2 * h, y + 0.2 * k1)
    k3 = h * deriv(x + 0.3 * h, y + 0.075 * k1 + 0.225 * k2)
    k4 = h * deriv(x + 0.6 * h, y + 0.3 * k1 - 0.9 * k2 + 1.2 * k3)
    k5 = h * deriv(x + h, y - 0.2037037037037037 * k1 + 2.5 * k2 - 
        2.5925925925925926 * k3 + 1.2962962962962963 * k4)
    k6 = h * deriv(x + 0.875 * h, y + 0.029495804398148147 * k1 + 
        0.341796875 * k2 + 0.041594328703703706 * k3 + 0.40034541377314814 *
        k4 + 0.061767578125 * k5)
    yn = y + (0.09788359788359788 * k1 + 0.4025764895330113 * k3 + 
        0.21043771043771045 * k4 + 0.2891022021456804 * k6)
    xn = x + h
    if errors:
        yerr = (-0.004293774801587302 * k1 + 0.018668586093857832 * k3 - 
            0.03415502683080808 * k4 - 0.019321986607142856 * k5 + 
            0.03910220214568041 * k6)
        return xn, yn, yerr
    else:
        return xn, yn
