def rk4_backward(f, x, h, **kwargs):
    """Implements a backwards classic Runge-Kutta integration RK4.

    Parameters
    ----------
    f : callable
        function to reverse integrate, must take x as the first argument and
        arbitrary kwargs after
    x : numpy array, or float
        state needed by function
    h : float
        step size

    Returns
    -------
    state : numpy array, or float
        Reverse integrated state
    """
    k1 = f(x, **kwargs)
    k2 = f(x - 0.5 * h * k1, **kwargs)
    k3 = f(x - 0.5 * h * k2, **kwargs)
    k4 = f(x - h * k3, **kwargs)
    return x - (h / 6) * (k1 + 2 * k2 + 2 * k3 + k4)