
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Ching, Robby Andre July 4 , 2020
Numerical Integration
Introduction and Overview
The most common numerical integration schemes used are the Newton-Cotes formulas , where
the real function to be integrated is approximated with a simpler and more readily-integrable polynomial
function. The integral could also be approximated better by using a piecewise function of different
polynomial functions. Closed forms are methods in which the upper and lower limits of the integral are
available, while Open forms have limits which extend beyond the given data [1].
Trapezoidal Rule
It is closed form in which a 1
st
order polynomial (linear) is used to replace or approximate the
function to be integrated [1].
1
𝑏
𝑎
1
𝑏
𝑎
1
1
𝑏
𝑎
2
𝑎
𝑏
2
2
The geometrical depiction of this formula is the area of a
trapezoid, equivalent to height multiplied to the average of
the width. In this case however, the height becomes the
width, and the width becomes the height [1].
𝒇(𝒂)+𝒇(𝒃)
𝟐
= 𝒂𝒗𝒈. 𝒉𝒆𝒊𝒈𝒉𝒕 of a trapezoid
under the original curve or function to be integrated [1].
Error Estimate for Single Application
The local truncation error (true absolute error) could be approximated by the following equation.
The 2
nd
derivative of the function [1].
𝑡
′′
3
𝑡
𝒂
′′
𝟑
where:
′′
′′
𝒃
𝒂
Multiple Application of Trapezoidal Rule
Better approximations of the integral could be made with a lower error value by dividing the
interval a to b into an n number of equal-width segments. Thus, the width of each segment is ℎ =
𝑏−𝑎
𝑛
Setting 𝑎 = 𝑥 0
and 𝑏 = 𝑥
𝑛
, we have the following [1]:
0
1
1
2
𝑛− 1
𝑛
0
1
1
2
𝑛− 1
𝑛
𝒊
𝒏−𝟏
𝒊=𝟏
Error estimate for Multiple Application
The absolute error could be approximated in the
same manner with that of the single application, but
the number of segments must be accounted for [1].
𝒂
𝟐
′′
𝟑
where:
′′
′′
𝒊
𝒊−𝟏
𝒊
𝒊−𝟏
𝒏
𝒊=𝟏
When the number of segments used is doubled,
the error would be quartered. This is a better way of
having smaller errors and more accurate results
compared to that of the single application of the
Trapezoidal rule [1].
Simpson’s 1/3 Rule
It is another closed form that uses a 2
nd
function to be integrated. It requires three points, unlike in the trapezoidal, in which it only 2 points. Let
the lower limit 𝑎 = 𝑥 0
, the upper limit 𝑏 = 𝑥
2
, and their midpoint 𝑥
1
, then we have the following [1]:
1
1
2
0
1
0
2
0
0
2
1
0
1
2
1
0
1
2
0
2
1
2
𝑏
𝑎
1
𝑥
2
𝑥
0
𝟎
𝟏
𝟐
𝟎
𝟏
𝟐
where ℎ =
(𝒃−𝒂)
2
, 𝑤𝑖𝑑𝑡ℎ = (𝑏 − 𝑎), and 𝑎𝑣𝑔. ℎ𝑒𝑖𝑔ℎ𝑡 =
𝒇(𝒙
𝟎
)+𝟒𝒇(𝒙
𝟏
)+𝒇(𝒙
𝟐
)
𝟔
Error estimate for Single application of Simpson’s 1/3 rule
The local truncation error or absolute error can be approximated by the following equation [1]:
𝒂
′′′′
𝟓
where:
′′′′
′′′′
𝒃
𝒂
Multiple application of Simpson’s 1/3 rule
In the same way with that of the Trapezoidal rule, the Simpson’s 1/3 rule could also be divided into n
segments of equal width of ℎ =
(𝒃−𝒂)
𝑛
. The following would only be applicable if the n segments is an
even number [1].
𝟎
𝟏
𝟐
𝟐
𝟑
𝟒
𝒏−𝟐
𝒏−𝟏
𝒏
𝟎
𝒊
𝒏−𝟏
𝒊=𝟏,𝟑,𝟓
𝒊
𝒏−𝟐
𝒊=𝟐,𝟒,𝟔
𝒏
Error Estimate for Composite Simpson’s 1/3 rule
𝒂
𝟒
′′′′
𝟓
where 𝑓
′′′′
(𝑥) is equal to that of the single application Simpson’s 1/3 rule.
Simpson’s 3/8 Rule
A third-order Lagrange polynomial function could be used to approximate the function using four
points. Let the lower limit 𝑎 = 𝑥 0
, the upper limit 𝑏 = 𝑥
3
, and the two points between them 𝑥
1
and 𝑥
2
then we have the following [1]:
𝟎
𝟏
𝟐
𝟑
𝟎
𝟏
𝟐
𝟑
where
(𝒃−𝒂)
3
, 𝑤𝑖𝑑𝑡ℎ = (𝑏 − 𝑎), and 𝑎𝑣𝑔. ℎ𝑒𝑖𝑔ℎ𝑡 =
𝒇(𝒙
𝟎
)+𝟑𝒇(𝒙
𝟏
)+𝟑𝒇(𝒙
𝟐
)+𝒇(𝒙
𝟑
)
𝟖
Error estimate of Simpson’s 3/8 rule
𝒂
′′′′
𝟓
where:
′′′′
′′′′
𝒃
𝒂
Multiple Application of Simpson’s 3/8 rule
For even number of segments, the composite Simpson’s 1/3 rule could
be used. But for odd number of segments, a combination of Simpson’s 1/
rule and Simpson’s 3/8 rule could be utilized. For the first n- 3 segments (a
segment means a portion between two points), Simpson’s 1/3 rule would
be applied, while for the last 3 segments, the Simpson’s 3/8 rule would be
applied. The final integral value and approximate absolute error would be
their sum [1].
For example, if n=5, then the first two segments would use the 1/3 rule
(with 3 points and thus only done once), while the remaining 3 segments
would use the 3/8 rule (with 4 points and thus would always be done only
′
− 2 𝑥
′′
− 2 𝑥
′′′
− 2 𝑥
′′′′
− 2 𝑥
′′′′
′′′′
𝑏
𝑎
′′′′
− 2 𝑥
4
0
𝑎
′′′′
5
𝑎
5
b. Composite Simpson’s 1/3 rule with n=
− 2 ( 0 )
− 2 ( 1 )
− 2 ( 2 )
− 2 ( 3 )
− 2 ( 4 )
𝑎
4
′′′′
5
𝑎
4
5
c. Single Application Simpson’s 3/8 rule
− 2
( 0
)
− 2
(
)
− 2
(
)
− 2
( 4
)
0
1
2
3
𝑎
′′′′
5
𝑎
5
d. Composite Simpson’s rule with n=
− 2
( 0
)
− 2
(
)
− 2
(
)
− 2
(
)
− 2 ( 3. 2 )
− 2 ( 4 )
1
1
′′′′
− 2 𝑥
0
𝑎, 1
5
− 2
(
)
− 2
(
)
− 2 ( 3. 2 )
− 2 ( 4 )
2
2
′′′′
− 2 𝑥
4
𝑎, 2
5
−𝟑
1
2
𝑎
𝑎, 1
𝑎, 2
− 3
Sample #2: Evaluate the integral of the given function in the interval 0 and
𝜋
2
using numerical methods
as listed below with their given respective conditions. Compute also for their approximate absolute
errors.
= 6 + 3 cos (𝑥)
a. Trapezoidal rule with one segment (n=1)
𝒂
𝒂
e. Simpson’s 3/8 rule with 3 segments (n=3)
𝒂
f. Simpson’s rule with 7 segments
Remarks: Generally, the higher the segment number, the lower the error and the more accurate the
solved integral is. Simpson’s rule is preferred over the trapezoidal rule because of its faster convergence
to the true integral value (smaller error value).
Sample#3: Determine the isothermal work done in kJ for the given data of pressure vs. Volume below.
Use a combination of Trapezoidal and Simpson’s rule in evaluating it.
Pressure
(kPa)
Volume
(m
3
𝑊 = ∫ 𝑃𝑑𝑉, and so we set P as our f(x) and V as our x, and we
numerically evaluate their integral. The figure [2] below shows
how it could be numerically integrated using a combination of
Trapezoidal and Simpson’s rule.
Variable: Volume: Width (h):
x 0
x 1 2
x 2
x 3
x 4
x 5
x 6
x 7
b. Simpson’s rule
Sample # 5 : The following data was collected for a cross-section of a river (y = distance from bank, H =
depth and U = velocity):
y (m) 0 1 3 5 7 8 9 10
H (m) 0 1 1.5 3 3.5 3.2 2 0
U (m/s) 0 0.1 0.12 0.2 0.25 0.3 0.15 0
Use numerical integration to compute the (a) cross-sectional area, (b) average depth, (c) the flow rate,
and (d) average velocity. Note that the cross-sectional area (A c
) and the flow rate (Q) can be computed
as:
𝑐
𝑦
0
𝑦
0
a. Cross sectional area
𝒄
𝟐
b. Average depth
𝑐
𝑛
0
2
c. Flow rate
y (m) 0 1 3 5 7 8 9 10
H (m) 0 1 1.5 3 3.5 3.2 2 0
U (m/s) 0 0.1 0.12 0.2 0.25 0.3 0.15 0
U*H (m
2
/s) 0 0.1 0.18 0.6 0.875 0.96 0.3 0
Romberg Integration
It is based on Richardson’s extrapolation , which is a method for combining two numerical integral
estimates to obtain an estimate with higher accuracy. It is more efficient compared to the previous
methods because it weighs out each estimate obtained from applications with different segment. It is an
extension of the Trapezoidal rule, where two estimates having different segment width are weighed and
combined to obtain a better integral estimate. The derivation is as follows, were 𝐼 is the true integral, 𝐼(ℎ)
is the approximation or estimate from an n-segment application of step size h of the Trapezoidal rule, and
is the truncation error [1].
𝑖
𝑖
2
′′
3
2
2
′′
3
2
′′
b − a
1
2
1
2
2
2
1
2
1
2
2
2
1
1
2
2
1
2
1
2
2
2
2
2
2
1
2
1
2
2
2
2
2
𝟐
𝟏
𝟐
𝟏
𝟐
𝟐
𝟐
For successive halving of the step-size: ℎ 2
ℎ
1
2
𝟐
𝟏
𝟐
𝟐
𝟐
𝟐
𝟐
𝟐
𝟏
𝟐
𝟐
𝟐
𝟏
𝟐
𝟏
2
1
The first integral estimates calculated from the application of the Trapezoidal rule has an error of 𝑂(ℎ
2
A combination of two estimates that has this error, as being solved with the above equation, results into
an error of 𝑂(ℎ
4
). A combination of two estimates with an error of 𝑂(ℎ
4
) yields an integral estimate with
an error of 𝑂(ℎ
6
). As the iterations proceed, the error diminishes, and higher accuracy is obtained. Notice
that the constants of the estimates equal to 1. That is, the improved integral estimates is obtained from
a weighted average of the previous estimates, where the “more accurate” one has the higher weight. For
successive halving of step-size, the generalized relation for the Romberg Integration is as follows, where
𝑘 represents the level of integration and 𝑗 the n-segment application f the Trapezoidal rule [1].
𝒋,𝒌
𝒌−𝟏
𝒋+𝟏,𝒌−𝟏
𝒋,𝒌−𝟏
𝒌−𝟏
𝟐𝒌
Termination criteria and Error estimate
Since it is an iterative approach, the percent relative error could be used as a termination criterion,
where the computed higher level of integration is compared to the latest lower level integration
estimate [1].
𝒂
𝟏,𝒌
𝟐,𝒌−𝟏
𝟏,𝒌
Gauss-Legendre Quadrature Formulas
In the Newton-Cotes formulas, the location of the base points,
which are the lower and upper limits, are fixed. There are some cases
in which large errors occur because of this. In this method, this
constraint is lifted. The base points would be any two points on the
curve, and the integral would eb the are under the straight line it forms.
A better approximate is obtained by doing this, as seen in the diagram
The derivation for the Gauss-Legendre formulas are based from
Method of Undetermined Coefficients , which will not be shown here. A
two-point Gauss-Legendre formula utilizes two points in the curve to
approximate its integral; a three-point uses 3 points, and so on. The
general formula is as follows [1].
𝟎
𝟎
𝟏
𝟏
𝒏−𝟏
𝒏−𝟏
The values for the weighing factor 𝒄
𝒊
and the function argument 𝒙
𝒊
are obtained by using - 1
and 1 as the lower and upper limits, respectively. And so the function to be evaluated at a specified lower
and upper limits must be adjusted. The values for each point Gauss-Legendre Formula are listed below
𝟎
𝟏
𝟎
𝟏
𝒊
𝟏
𝒊
After the function or integrand is adjusted, the integral estimate is then calculated with the
general formula, their respective constants function arguments. The function argument is evaluated with
the adjusted function [1].
2 , 1
n=4: 𝑒𝑟𝑟𝑜𝑟 𝑖𝑠 𝑂(ℎ
2
3 , 1
k=2: 𝑒𝑟𝑟𝑜𝑟 𝑖𝑠 𝑂(ℎ
4
𝑗,𝑘
𝑘− 1
𝑗+ 1 ,𝑘− 1
𝑗,𝑘− 1
𝑘− 1
2 , 2
1
3 , 1
2 , 1
1
6
𝑗,𝑘
𝑘− 1
𝑗+ 1 ,𝑘− 1
𝑗,𝑘− 1
𝑘− 1
1 , 3
2
2 , 2
1 , 2
2
𝑎
1 , 3
2 , 2
1 , 3
Summary:
Iteration/error: 𝑶(𝒉
𝟐
𝟒
𝟔
st
iteration
nd
iteration
b. 2 - point Gauss-Legendre formula
0
1
0
1
𝑖
𝑖
1
𝑖
𝑖
𝑥
3
0
𝑖
1
− 1
( 1. 5 + 1. 5 𝑥
𝑖
)
𝑖
𝑖
𝑖
( 1. 5 + 1. 5 𝑥
𝑖
)
with 𝑥
0
0
with 𝑥
1
1
0
0
1
1
c. 3 - point Gauss-Legendre formula
𝑖
𝑖
( 1. 5 + 1. 5 𝑥
𝑖
)
with 𝑥
0
0
1
1
with 𝑥
2
2
0
0
1
1
Sample #2: Evaluate numerically the given function from 0 to 8 by using the given methods. Find the
true relative error by comparing to the answer from part (a).
4
3
2
a. Analytically
8
0
5
4
3
2
b. Multiple Application of Trapezoidal rule up to 8 segments
𝑡
c. Multiple Application of Simpson’s rule up to 8 segments