1. The Simpson Rule

Regarding Simpson's Rule :-
If we have an even number of strips i.e. on odd number of ordinates then
Integral = strip_width/3 * (
                                     ( first_ordinate_value +
last_ordinate_value ) +
                               4.0*( sum of even_ordinate_values )
+
                               2.0*( sum of odd_ordinate_values(except first
and last ) ) )

Therefore the factors 4.0 and 2.0 can be taken outside loops

e.g. suppose we have 'n' points ( n = odd )

Integral = f(x_1) + f(x_n)

sumeven = 0
for index = 2 to n-1 by 2 do
   sumeven = sumeven + f(x_index)
end for

sumodd = 0
for index = 3 to n-2 by 2 do
   sumodd = sumodd + f(x_index)
end for

integral = integral + 4.0 * sumeven + 2.0*sumodd

integral = integral*strip_width/3

Simple code is usually fast code which makes Simpson's method attractive.
If the cost of evaluating the function is high then there are other better
methods such as Gaussian Quadrature that can give high accuracy with much
fewer function evaluations.

Lastly, Simpson's rule is based on representing the function over two
intervals
by a quadratic polynomial. Therefore Simpson's Rule should not be used on
functions where this is not reasonable ( at least in the range of x of
interest ) .

For example Simpson's Rule should not be used to evaluate the integral of 1/x
anywhere near x=0. Rational polynomials such as ( A + Px ) / ( B + Qx ) need
careful consideration.

I hope this is useful.

-- Neil Rigby

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu