corrected off-by-one bug in integral