def compute_next_trapstep(momentum, proposal, stepsize, findE, gradE):
    """
    Computes next trapezoidal step. 
        1. Half step in momentum
        2. Step in spatial variable
        3. Find new gradient
        4. Half step in momentum

    Args:
        momentum:   shape (ndim,)
        proposal:   MCMCState object, current proposal
        stepsize:   stepsize used for trapezoidal rule
        gradE:      callable, evaluate gradient of potential
                    (negative log likelihood)
    Returns:
        momentum:   momentum after trapezoidal step
        proposal:   updated proposal
    """
    momentum = momentum - stepsize * proposal.gradeval / 2
    proposal.state = proposal.state + stepsize * momentum
    findE(proposal.state)
    proposal.gradeval = gradE(proposal.state)
    momentum = momentum - stepsize * proposal.gradeval / 2
    return momentum, proposal