Thanks, that’s probably the case. However, I’m still somewhat puzzled as to how I should think about it since both methods (sum and trapz) are numerical approximations to what theoretically is a continuous integral. I’m guessing this wouldn’t be a problem if I had used periodic boundary conditions and an auto-differentiable implementation of trapz that handled the boundaries correctly?