1 | Recall that when you repeatedly apply Simpson's rule, halving the interval each time, you can use old values of the function. Furthermore, there is a convenient pattern to the Simpson coefficients. |
2 | In our program, we start with an initial set of Xi's for which we calculate f values and save them in an array oldf. Then for each iteration of Simpson's rule, we collect the new values in an array newf. The result uses 2 * oldf and 4*newf (with exceptions for the endpoints). |