Math-305, Numerical Methods & Matrices
Simpson's-3/8 Rule to Approximate a Proper Integral

Dr. K. G. TeBeest

      
      
      *****************************************************************

      SIMPSON's - 3/8 RULE ALGORITHM (pseudocode)

      To approximate the integral of a function f(x) on interval [a,b]
      using n subintervals.

      INPUT:

         f(x)  –  the function to be integrated
          a    –  lower limit of interval of integration
          b    –  upper limit of interval of integration
          n    –  the number of subintervals to divide interval [a,b]
                  NOTE:  n must be divisible by 3

      *****************************************************************

      1.  enter:  f(x), a, b, n

      2.  set  SECTIONS = n/3
          set  h = (b-a) / n
          set  APPROX = 0.0
          
      3.  Repeat steps (a–e) for i from 1 to SECTIONS:

          a.  set  x0 = a + 3 * (i–1) * h
          b.  set  x1 = x0 + h
          c.  set  x2 = x1 + h
          d.  set  x3 = x2 + h
          e.  set  APPROX = APPROX + f(x0) + 3*f(x1) + 3*f(x2) + f(x3)

      4.  set  INTEGRAL = 3 * h/8 * APPROX

      5.  print INTEGRAL



      COMMENT:  Make sure you print the result in floating point (decimal) form;
                you may need to use the Maple "evalf" command.



Return