Post Reply 
New Trapedoizal Tail integration method
05-12-2021, 06:05 PM (This post was last modified: 05-13-2021 02:28 AM by Namir.)
Post: #1
New Trapedoizal Tail integration method
Hi All,

I am sharing a new "trapezoidal tail" method. The method samples two function values in each interval at f(x+h/2-h/3) and fx(x+h/2+h/3) where h is the size of the integration interval. If you remove the h/2 part, the algorthm degrades in the results it return.

Given function fx to integrate from x=A to x=B in N even steps.

Code:
h = (B - A) / N
h3 = h / 3
X = A + h / 2
Sum = 0
Do While X < B
  Sum = Sum + fx(X - h3) + fx(X + h3)
  X = X + h
Loop
Integral = h * Sum / 2

The above algorithm performs better than similar trapezoidal integration methods, like the mid-point method or regular trapezoidal method.

How does the new algorithm compare with Simpson's rule? In general the latter methods performs better. I noticed that the absolute ratios of % errors of the new algorithm to Simpson's rule rises quadratically with the number of interval divisions. This relation seems to hold for the few different functions I tested and the curve fitted (using 5 points for each case) were perfect quadratic fits!

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


Messages In This Thread
New Trapedoizal Tail integration method - Namir - 05-12-2021 06:05 PM



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