Post Reply 
Compact Simpson's 3/8 Rule(??)
12-13-2015, 02:26 PM (This post was last modified: 12-13-2015 03:07 PM by Namir.)
Post: #1
Compact Simpson's 3/8 Rule(??)
Here is the pseudo-code for a compact version of Simpson's 3/8 Rule. This rule divides the integral range [A, B] into N (=3m where m>1) divisions. The area is calculated using:

area = 3*h/8*(f(A) + 3*f(x(1)) + 3*f(x(2)) + 2*f(x(3)) + ... + f(B))

The following pseudo-code is able to apply the sequence of coefficient values of 3,3, and 2 for every three points, starting with x=A+h and until X=B-h.

Code:
Give f(x), interval [A, B] and N divisions where N=3m for any m>1.

h=(B-A)/N
Sum=f(A)+f(B)
I=1
Do
  A=A+h
  C= 2 + (3-I)*I/2
  Sum=Sum + C*f(A)
  I=I MOD 3 + 1
  N=N-1
Loop Until N=1
Area = 3*h/8*Sum

The variable I cycles between 1, 2, and 3. The coefficient C is calculated using a special (and simple) quadratic equation to yield 3, 3, and 2 for I=1, 2, and 3.

Here is an alternate form that uses memory registers (suitable for calculators)

Code:
Give f(x), interval [A, B] and N divisions where N=3m for any m>1.

Mem(1)=3
Mem(2)=3
Mem(3)=2

h=(B-A)/N
Sum=f(A)+f(B)
I=1
Do
  A=A+h
  Sum=Sum + Mem(I)*f(A)
  I=I MOD 3 + 1
  N=N-1
Loop Until N=1
Area = 3*h/8*Sum

The main point in this thread and the one about a compact (basic) Simpson's Rule is to perform one summation of f(x) per loop iteration.

Enjoy!

Namir
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015 02:26 PM
RE: Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015, 05:05 PM



User(s) browsing this thread: 2 Guest(s)