Cartwright 2017 - No 12
Cartwright 2017 - No 12
Cartwright 2017 - No 12
Abstract
Introduction
rule. Assume that the abscissa values x1 , x2 ,...xN are not equally spaced. Note
Background
f x3 f x2 f x2 f x1
A ,
x3 x2 x3 x1 x2 x1 x3 x1
f x3 f x2
B A x2 x3 , (4)
x3 x2
C f x1 Ax12 Bx1 .
f x dx Ax
A 3 B 2
I3 2
Bx C dx x3 x13 x3 x12 C x3 x1 .
3 2
x1 x1
(5)
As shown by Cartwright [6], Eq. (5) can also be written as
I3
x3 x1 x3 x2 x3 x1 2 x x
2 f x1 f x2 2 2 1 f x3 .
6 x2 x1 x3 x2 x2 x1 x3 x2
(6)
Also,
x2 x2
f x dx Ax
A 3 B 2
I2 2
Bx C dx x2 x13 x2 x12 C x2 x1 .
3 2
x1 x1
(7)
x x x2 x1 2 x x
3 2 1 f x1 3 2 1 f x2
x x x3 x1 x3 x2 x3 x1 x3 x1
I2 2 1 .
6 x2 x1 2
f x3
x3 x2 x3 x1
(8)
Note that the correctness of Eq. (8) will be demonstrated in the examples below.
If the distances between points are equal, i.e., d x3 x2 x2 x1 , Eq. (5) and
Eq. (6) become the well-known Simpson’s Rule
I 3 f ( x)dx f x1 4 f x2 f x3 .
x3 d
(9)
x1 3
However, what about I 2 ? Blake [4] has shown that this is equal to
d 5 1
I2 f x1 2 f x2 f x3 . (10)
34 4
It is rewarding to note that Eq. (8) becomes Eq. (10) for equally-spaced data, as
it should.
xk 2 , f xk 2 , xk 1 , f xk 1 , xk , f xk .
Hence, the following must be true:
f xk f xk 1 f xk 1 f xk 2
A ,
xk xk 1 xk xk 2 xk 1 xk 2 xk xk 2
f xk f xk 1
B A xk 1 xk , (16)
xk xk 1
C f xk 2 Axk2 2 Bxk 2 .
Sk
xk 2
f x dx
xk
(17)
A 3 B 2
Ax 2 Bx C dx xk xk3 2 xk xk2 2 C xk xk 2 .
3 2
xk 2
Note that Eq. (17) and Eq. (18) are valid for 3 k N .
Implementation in MS Excel
Example 1
For this first example, let the points be taken from f ( x) x 2 . Hence, the
x
x3
theoretical cumulative integral is given by I x 2 dx . Using Eq. (7), Eq.
0
3
(12), Eq. (16) and Eq. (17) (which will be called Method I), Simpson’s Rule
cumulative numerical integration was performed and the results are seen in
Column I of Table I. The theoretical results are given in Column J. Clearly, the
theoretical and numerical results are the same as they must be for Simpson’s
Rule for f ( x) x 2 . Furthermore, the cumulative numerical integration using the
trapezium rule results are given in Column K. Clearly, these latter results are
poorer, as expected.
Example 2
For this second example, let the points be taken from f ( x) sin x. Hence, the
x
theoretical cumulative integral is given by I sin dx 1 cos x. Using Eq. (7),
0
Eq. (12), Eq. (16) and Eq. (17) (Method I), Simpson’s Rule cumulative
numerical integration was performed and the results are seen in Column I of
Table II. The theoretical results are given in Column J. Furthermore, the
cumulative numerical integration using the trapezium rule results are given in
Column K. Clearly, Simpson’s Rule cumulative integration gives answers closer
to the theoretical values.
Table II. Implementation of Example 2 using Eq. (7), Eq. (12), Eq. (16) and
Eq. (17) (Method I) in MS Excel.
Example 3
For this third example, Example 2 will be repeated; however, Eq. (8) will be
used in place of Eq. (7) and Eq. (18) will replace Eq. (17). Indeed, cumulative
numerical integration was performed using Eq. (8), Eq. (12) and Eq. (18) (which
will be called Method II). The results are shown in Column I of Table III. Note
that these are identical to those in Table II, as they should be, thereby verifying
the correctness of Eq. (8) and Eq. (18).
Table III. Implementation of Example 3 using Eq. (8), Eq. (11) with Eq.
(18) (Method II) in MS Excel.
Conclusion
Two different methods have been presented that allow the numerical cumulative
integration of irregularly-spaced data, using Simpson’s Rule. These methods are
Appendix
In this appendix, the MATLAB code for the determination of Eq. (8) will be
given.
The program requires that Eq. (7) be rewritten as a product given by Eq. (A1).
I2
A 3
3
x2 x13
B 2
2
x2 x12 C x2 x1
(A1)
x2 x1
6
2 2
2 A x2 x2 x1 x1 3B x2 x1 6C .
Let a x2 x1 , b x3 x2 and c x3 x1 . Then, Eq. (A1) becomes
x2 x1
I2
6
2 A x a x a x x 3B 2x a 6C
1
2
1 1
2
1 1
(A2)
x2 x1
D,
6
where D 2 A x1 a x1 a x1 x12 3B 2 x1 a 6C.
2
Furthermore, from Eq. (4),
f x3 f x2 f x2 f x1
A ,
bc ac
f x3 f x2
B A 2 x1 a c , (A3)
b
C f x1 Ax12 Bx1 .
Substituting Eq. (A3) into Eq. (A2) and simplifying produces the desired
expression of Eq. (8).
However, the tedium of these final two steps is eased by the MATLAB symbolic
math program given below:
References
[2] Fresen, J. L., & Juritz, J. M. (1986). A note on Foss's method of obtaining
initial estimates for exponential curve fitting by numerical integration.
Biometrics, 42(4):821-827.
[4] Blake, L.V. (1971). A Simpson’s Rule and Fortran Subroutine for
Cumulative Numerical Integration Defined by Data Points. NRL Memorandum
Report 2231, Naval Research Laboratory. Available:
http://www.dtic.mil/dtic/tr/fulltext/u2/723583.pdf .
[5] El-Hajj, A., & Kabalan, K. Y. (1995). Time domain analysis of linear
systems using spreadsheets. IEEE Transactions on Education, 38(4): 317-320.