Simpson’s rule, as I’m sure all readers of this blog will know, is a simple rule for numerical integration (or *quadrature*). It can be obtained in two ways, either by determining the interpolating polynomial over three equally spaced points and integrating that polynomial, or by finding the values for which

(where ) is accurate for . Over the interval , Simpson’s rule is

and over a general interval

Simpson’s rule has the added advantage that it is also accurate for cubic polynomials.

On its own the rule is not hugely accurate, so one way of increasing the accuracy is to divide the interval into smaller, equally sized regions and apply Simpson’s rule to each of them. This provides the *composite Simpson’s rule*:

where is even and . Sometimes this rule is written

where there is no restriction on and . For a spirited criticism of this rule, both from practical and pedagogical perspectives, see here.

However, in a standard generic mathematics course, Simpson’s rule is as far as most students get with quadrature. The trouble is that the order of the weights (the coefficients of the function values):

is tricky to program. Either you have to run two loops, one for the 4’s and the other for the 2’s, or you have to do a little test at each stage to see whether you are at a 2 or 4 point, or you might invoke the modulus function. None of those ways are particularly straightforward, especially if, like many beginning students, you have little programming experience.

So here’s a super easy way. We start with end points and and an even integer . We first create a list of all the values at which the function is to be computed:

where , and then a list of the weights:

This last list is .

We then compute

However! note that our list of weights starts and finishes with 2’s instead of 1’s. We correct for this by simply subtracting and from the sum. Our “easy” Simpson’s rule is then:

This is almost trivial to compute. For example, on a TI-nspire CAS calculator, we might have:

The TI-nspire has the nice attribute that a function applied to a list will produce a list of all function values, and the product of two lists is a list containing all the products of corresponding elements. The Casio Classpad has the same functionality with lists, and the above commands can be used.

This approach of using to obtaining the weights for Simpson’s rule seems not widely used, but it seems to me to be absurdly simple. I’ve only come across it in one other place.

Some of your equations do not seem to be forming correctly: perhaps you should reconsider what your software formats them as.

Thanks – in fact the problem is that when I imported all my posts from wordpress.com to this wordpress.org blog, the LaTeX backslashes were all removed – which of course means that most mathematics is not properly typeset. So every now and again I fix up a blog post.