In this sum we observe that the right endpoint of one subinterval becomes the
left endpoint of the following subinterval to the right. Therefore, if this is implemented
directly, the function values at the points with an even subscript will
be evaluated twice, except for the extreme endpoints a and b which only occur
once in the sum. We can therefore rewrite the sum in a way that avoids these
redundant evaluations