Subject : The following demonstrates the multiple segment Simpson's 1/3rd rule of integration.
Authors : Nathan Collier, Autar Kaw, Loubna Guennoun
Date : 25 October 2005

Introduction

Simpson's rule is based on the Newton-Cotes formula that if one approximates the integrand of the integral by an nth order polynomial, then the integral of the function is approximated by the integral of that nth order polynomial. Integration of polynomials is simple and is based on the calculus.  Simpson's 1/3rd rule is the area under the curve where the function is approximated by a second order polynomial. [click here for textbook notes] [click here for power point presentation].

Inputs

The following simulation illustrates the Simpson's 1/3rd rule of integration. This section is the only section where the user interacts with the program. The user enters any function f(x), the lower and upper limit of the integration. By entering this data, the program will calculate the exact value of the integral, followed by the results using the Simpson's 1/3rd rule with n = 2, 4, 6, 8 segments.

Integrand f[x] = 0

f[x_] := 300.0*x/(1.0 + Exp[x]);

Lower and upper limit of the integral, a and b respectively.

a = 0.0;
b = 10.0;

curve = 
        Plot[f[x], {x, a, b}, 
          PlotLabel -> "Entered function on given interval", 
          TextStyle -> {FontSize -> 
                11}];
General::spelll  Off

2 Segment Simpson 1/3 Rule

n = 2;
h2 = (b - a)/n

The integral of the function f(x) from a to b using Simpson's rule with two segments will be equal to:

s2 = h2*(f[a] + 4*f[a + h2] + f[b])/3

The approximate error and absolute relative approximate error for the first iteration are undefined.

4 Segment Simpson 1/3 Rule

n = 4;
h4 = (b - a)/n

The integral of the function f(x) from a to b using Simpson's rule with four segments will be equal to:

s4 = 
      h4*(f[a] + 4*(f[a + h4] + f[a + 3*h4]) + 2*f[a + 2*h4] + f[b])/
          3

The approximate error is:

Ea4 = s4 - s2

The absolute relative approximate error is

ea4 = Abs[Ea4/s4]*100

6 Segment Simpson 1/3 Rule

n = 6;
h6 = (b - a)/n

The integral of the function f(x) from a to b using Simpson's rule with six segments will be equal to:

sum1 = 
        f[a + h6] + f[a + 3*h6] + f[a + 5*h6];
sum2 = f[a + 2*h6] + f[a + 4*h6];
s6 = h6*(f[a] + 4*sum1 + 2*sum2 + f[b])/3

The approximate error is:

Ea6 = s6 - s4

The absolute relative approximate error is

ea6 = Abs[Ea6/s6]*100

8 Segment Simpson 1/3 Rule

n = 8;
h8 = (b - a)/n

The integral of the function f(x) from a to b using Simpson's rule with eight segments will be equal to:

sum1 = 
        f[a + h8] + f[a + 3*h8] + f[a + 5*h8] + 
          f[a + 7*h8];
sum2 = 
        f[a + 2*h8] + f[a + 4*h8] + f[a + 6*h8];
s8 = h8*(f[a] + 4*sum1 + 2*sum2 + f[b])/3

The approximate error is:

Ea8 = s8 - s6

The absolute relative approximate error is

ea8 = Abs[Ea8/s8]*100