Sum with an iterative process

I feel this is the right answer... It generated the expected output for
the chapter examples in section 1.3.1 and for the Simpson's rule
exercise (ex. 1.29). But how to *prove* it's correctness? That is the
question.