# Tutorial: Simpson's Rule

Simpson's rule approximates the integral of some function f over an interval. It is very similar to the trapezoidal rule. Recall that the formula for Simpson's rule is the following:

(h/3)[f(x0) + 4f(x1) + 2f(x2) + ... +4f(xn-1) + f(xn)]

where h is the width of the subinterval (that is, the width divided by the number of subintervals n), and the x0, x1, etc., are the points at the beginning and end of each subinterval. The constant multiples on the function values follow the pattern 1, 4, 2, 4, ..., 4, 2, 4, 1.

## Step 1: Choose n and calculate the width

Pick an even number of subintervals, and compute the width of each subinterval. (Simpson's rule only works if you use an even number of subintervals.) To approximate the integral of f from a to b with n subintervals, your width is h = (b-a)/n, just like for other techniques. Then enter a column with x values and a column with y values for your function. The x values should be in increments of h (see Filling Down in the Excel Tutorial for help with filling these in.)

For our example, we will approximate the integral of f(x) = x2 on the interval from 2 to 8, with n = 8. Thus h = (8-2)/8 = 0.75 is our step size, and we will next set up an x column in increments of 0.75.