def runge_kutta4(current_y, y_deriv_func, step):
    """
    Fourth order Runge Kutta
    http://lpsa.swarthmore.edu/NumInt/NumIntFourth.html
    for example
    y' = -2*y
    then y_deriv_func = y' that accepts y
    and y is current_y
    """

    k1 = y_deriv_func(current_y)
    y1 = current_y + k1 * step / 2

    k2 = y_deriv_func(y1)
    y2 = current_y + k2 * step / 2

    k3 = y_deriv_func(y2)
    y3 = current_y + k3 * step

    k4 = y_deriv_func(y3)

    next_y = current_y + (k1 + 2*k2 + 2*k3 + k4)*step/6

    return next_y