You are on page 1of 103

http://numericalmethods.eng.usf.

edu 1
Integration
Topic: Trapezoidal Rule
Major: General Engineering
Author: Autar Kaw, Charlie Barker
http://
numericalmethods.eng.usf.edu 2
What is Integration
Integration:
The process of measuring
the area under a function
plotted on a graph.
Where:
f(x) is the integrand
a= lower limit of integration
b= upper limit of integration
http://
numericalmethods.eng.usf.edu 3
Basis of Trapezoidal Rule
Trapezoidal Rule is based on the Newton-Cotes
Formula that states if one can approximate the
integrand as an n
th
order polynomial
where
and
http://
numericalmethods.eng.usf.edu 4
Basis of Trapezoidal Rule
Then the integral of that function is approximated
by the integral of that n
th
order polynomial.
Trapezoidal Rule assumes n=1, that is, the area
under the linear polynomial,
http://
numericalmethods.eng.usf.edu 5
Derivation of the Trapezoidal Rule
http://
numericalmethods.eng.usf.edu 6
Method Derived From Geometry
The area under the
curve is a trapezoid.
The integral






http://
numericalmethods.eng.usf.edu 7
Example 1
The vertical distance covered by a rocket from t=8 to
t=30 seconds is given by:

a) Use single segment Trapezoidal rule to find the distance covered.
b) Find the true error, for part (a).
c) Find the absolute relative true error, for part (a).
http://
numericalmethods.eng.usf.edu 8
Solution

a)












http://
numericalmethods.eng.usf.edu 9
Solution (cont)
a)
b) The exact value of the above integral is

http://
numericalmethods.eng.usf.edu 10
Solution (cont)
b)


c) The absolute relative true error, , would be


http://
numericalmethods.eng.usf.edu 11
Multiple Segment Trapezoidal Rule
In Example 1, the true error using single segment trapezoidal rule was
large. We can divide the interval [8,30] into [8,19] and [19,30] intervals
and apply Trapezoidal rule over each segment.



http://
numericalmethods.eng.usf.edu 12
Multiple Segment Trapezoidal Rule
With




Hence:
http://
numericalmethods.eng.usf.edu 13
Multiple Segment Trapezoidal Rule


The true error is:
The true error now is reduced from -807 m to -205 m.
Extending this procedure to divide the interval into equal
segments to apply the Trapezoidal rule; the sum of the
results obtained for each segment is the approximate
value of the integral.

http://
numericalmethods.eng.usf.edu 14
Multiple Segment Trapezoidal Rule
Figure 4: Multiple (n=4) Segment Trapezoidal Rule
Divide into equal segments
as shown in Figure 4. Then
the width of each segment is:


The integral I is:

http://
numericalmethods.eng.usf.edu 15
Multiple Segment Trapezoidal Rule
The integral I can be broken into h integrals as:
Applying Trapezoidal rule on each segment gives:

http://
numericalmethods.eng.usf.edu 16
Example 2
The vertical distance covered by a rocket from to seconds is
given by:
a) Use two-segment Trapezoidal rule to find the distance covered.
b) Find the true error, for part (a).
c) Find the absolute relative true error, for part (a).
http://
numericalmethods.eng.usf.edu 17
Solution
a) The solution using 2-segment Trapezoidal rule is









http://
numericalmethods.eng.usf.edu 18
Solution (cont)



Then:
http://
numericalmethods.eng.usf.edu 19
Solution (cont)


b) The exact value of the above integral is
so the true error is

http://
numericalmethods.eng.usf.edu 20
Solution (cont)


c)
The absolute relative true error, , would be










http://
numericalmethods.eng.usf.edu 21
Solution (cont)
Table 1 gives the values
obtained using multiple
segment Trapezoidal rule
for:

n Value E
t
1 11868 -807 7.296 ---
2 11266 -205 1.853 5.343
3 11153 -91.4 0.8265 1.019
4 11113 -51.5 0.4655 0.3594
5 11094 -33.0 0.2981 0.1669
6 11084 -22.9 0.2070 0.09082
7 11078 -16.8 0.1521 0.05482
8 11074 -12.9 0.1165 0.03560

Table 1: Multiple Segment Trapezoidal Rule Values
http://
numericalmethods.eng.usf.edu 22
Example 3
Use Multiple Segment Trapezoidal Rule to find
the area under the curve


from
to
.
Using two segments, we get
and
http://
numericalmethods.eng.usf.edu 23
Solution








Then:
http://
numericalmethods.eng.usf.edu 24
Solution (cont)
So what is the true value of this integral?
Making the absolute relative true error:

http://
numericalmethods.eng.usf.edu 25
Solution (cont)
n Approximate
Value
1 0.681 245.91 99.724%
2 50.535 196.05 79.505%
4 170.61 75.978 30.812%
8 227.04 19.546 7.927%
16 241.70 4.887 1.982%
32 245.37 1.222 0.495%
64 246.28 0.305 0.124%
Table 2: Values obtained using Multiple Segment
Trapezoidal Rule for:
http://
numericalmethods.eng.usf.edu 26
Error in Multiple Segment
Trapezoidal Rule
The true error for a single segment Trapezoidal rule is given by:
where
is some point in
What is the error, then in the multiple segment Trapezoidal rule? It will
be simply the sum of the errors from each segment, where the error in
each segment is that of the single segment Trapezoidal rule.
The error in each segment is

http://
numericalmethods.eng.usf.edu 27
Error in Multiple Segment
Trapezoidal Rule
Similarly:

It then follows that:

http://
numericalmethods.eng.usf.edu 28
Error in Multiple Segment
Trapezoidal Rule
Hence the total error in multiple segment Trapezoidal rule is



The term
is an approximate average value of the
.
Hence:
http://
numericalmethods.eng.usf.edu 29
Error in Multiple Segment
Trapezoidal Rule
Below is the table for the integral


as a function of the number of segments. You can visualize that as the number
of segments are doubled, the true error gets approximately quartered.
n Value
2 11266 -205 1.854 5.343
4 11113 -51.5 0.4655 0.3594
8 11074 -12.9 0.1165 0.03560
16 11065 -3.22 0.02913 0.00401
http://numericalmethods.eng.usf.edu 30
Integration
Topic: Simpsons 1/3
rd
Rule
Major: General Engineering
http://
numericalmethods.eng.usf.edu 31
Basis of Simpsons 1/3
rd
Rule
Trapezoidal rule was based on approximating the integrand by a first
order polynomial, and then integrating the polynomial in the interval of
integration. Simpsons 1/3rd rule is an extension of Trapezoidal rule
where the integrand is approximated by a second order polynomial.
Hence
Where is a second order polynomial.
http://
numericalmethods.eng.usf.edu 32
Basis of Simpsons 1/3
rd
Rule
Choose


and
as the three points of the function to evaluate a
0
, a
1
and a
2
.

http://
numericalmethods.eng.usf.edu 33
Basis of Simpsons 1/3
rd
Rule

Solving the previous equations for a
0
, a
1
and a
2
give

http://
numericalmethods.eng.usf.edu 34
Basis of Simpsons 1/3
rd
Rule









Then



http://
numericalmethods.eng.usf.edu 35
Basis of Simpsons 1/3
rd
Rule




Substituting values of a
0
, a
1
, a
2
give
Since for Simpsons 1/3rd Rule, the interval [a, b] is broken
into 2 segments, the segment width
http://
numericalmethods.eng.usf.edu 36
Basis of Simpsons 1/3
rd
Rule
















Hence
Because the above form has 1/3 in its formula, it is called Simpsons 1/3rd Rule.
http://
numericalmethods.eng.usf.edu 37
Example 1

a) Use Simpsons 1/3rd Rule to find the approximate value of x
The distance covered by a rocket from t=8 to t=30 is given by
b) Find the true error,
c) Find the absolute relative true error,
http://
numericalmethods.eng.usf.edu 38
Solution













a)



http://
numericalmethods.eng.usf.edu 39
Solution (cont)


b) The exact value of the above integral is
True Error

http://
numericalmethods.eng.usf.edu 40
Solution (cont)



a)c) Absolute relative true error,

http://
numericalmethods.eng.usf.edu 41
Multiple Segment Simpsons
1/3rd Rule
http://
numericalmethods.eng.usf.edu 42
Multiple Segment Simpsons 1/3
rd

Rule



Just like in multiple segment Trapezoidal Rule, one can subdivide the interval
[a, b] into n segments and apply Simpsons 1/3rd Rule repeatedly over
every two segments. Note that n needs to be even. Divide interval
[a, b] into equal segments, hence the segment width
where

http://
numericalmethods.eng.usf.edu 43
Multiple Segment Simpsons 1/3
rd

Rule

.
.
Apply Simpsons 1/3rd Rule over each interval,
f(x)
. . .
x
0
x
2
x
n-2
x
n
x
http://
numericalmethods.eng.usf.edu 44
Multiple Segment Simpsons 1/3
rd

Rule









Since

http://
numericalmethods.eng.usf.edu 45
Multiple Segment Simpsons 1/3
rd

Rule

Then



http://
numericalmethods.eng.usf.edu 46
Multiple Segment Simpsons 1/3
rd

Rule

http://
numericalmethods.eng.usf.edu 47
Example 2
Use 4-segment Simpsons 1/3rd Rule to approximate the distance
covered by a rocket from t= 8 to t=30 as given by
a) Use four segment Simpsons 1/3rd Rule to find the approximate
value of x.
b) Find the true error, for part (a).
c) Find the absolute relative true error, for part (a).
http://
numericalmethods.eng.usf.edu 48
Solution
Using n segment Simpsons 1/3rd Rule,

So


a)





http://
numericalmethods.eng.usf.edu 49
Solution (cont.)





http://
numericalmethods.eng.usf.edu 50
Solution (cont.)


cont.
http://
numericalmethods.eng.usf.edu 51
Solution (cont.)
In this case, the true error is b)
The absolute relative true error c)
http://
numericalmethods.eng.usf.edu 52
Solution (cont.)
Table 1: Values of Simpsons 1/3rd Rule for Example 2 with multiple segments
n Approximate Value E
t
|!
t
|
2
4
6
8
10
11065.72
11061.64
11061.40
11061.35
11061.34
4.38
0.30
0.06
0.01
0.00
0.0396%
0.0027%
0.0005%
0.0001%
0.0000%
http://
numericalmethods.eng.usf.edu 53
Error in the Multiple Segment
Simpsons 1/3
rd
Rule
The true error in a single application of Simpsons 1/3rd Rule is given as
In Multiple Segment Simpsons 1/3rd Rule, the error is the sum of the errors
in each application of Simpsons 1/3rd Rule. The error in n segment Simpsons
1/3rd Rule is given by



http://
numericalmethods.eng.usf.edu 54
Error in the Multiple Segment
Simpsons 1/3
rd
Rule




.
.
.
http://
numericalmethods.eng.usf.edu 55
Error in the Multiple Segment
Simpsons 1/3
rd
Rule
Hence, the total error in Multiple Segment Simpsons 1/3rd Rule is



http://
numericalmethods.eng.usf.edu 56
Error in the Multiple Segment
Simpsons 1/3
rd
Rule
The term is an approximate average value of
Hence
where
http://numericalmethods.eng.usf.edu 57
Integration
Topic: Romberg Rule
Major: General Engineering
http://
numericalmethods.eng.usf.edu 58
What is The Romberg Rule?
Romberg Integration is an extrapolation formula of
the Trapezoidal Rule for integration. It provides a
better approximation of the integral by reducing the
True Error.
http://
numericalmethods.eng.usf.edu 59
Error in Multiple Segment
Trapezoidal Rule
The true error in a multiple segment Trapezoidal
Rule with n segments for an integral
Is given by

where for each i, is a point somewhere in the
domain , .
http://
numericalmethods.eng.usf.edu 60
Error in Multiple Segment
Trapezoidal Rule


The term can be viewed as an
approximate average value of in .
This leads us to say that the true error, E
t

previously defined can be approximated as
http://
numericalmethods.eng.usf.edu 61
Error in Multiple Segment
Trapezoidal Rule
Table 1 shows the results
obtained for the integral
using multiple segment
Trapezoidal rule for
n Value E
t
1 11868 807 7.296 ---
2 11266 205 1.854 5.343
3 11153 91.4 0.8265 1.019
4 11113 51.5 0.4655 0.3594
5 11094 33.0 0.2981 0.1669
6 11084 22.9 0.2070 0.09082
7 11078 16.8 0.1521 0.05482
8 11074 12.9 0.1165 0.03560
Table 1: Multiple Segment Trapezoidal Rule Values
http://
numericalmethods.eng.usf.edu 62
Error in Multiple Segment
Trapezoidal Rule
The true error gets approximately quartered as
the number of segments is doubled. This
information is used to get a better approximation
of the integral, and is the basis of Richardsons
extrapolation.
http://
numericalmethods.eng.usf.edu 63
Richardsons Extrapolation for
Trapezoidal Rule

The true error, in the n-segment Trapezoidal rule
is estimated as
where C is an approximate constant of
proportionality. Since
Where TV = true value and = approx. value
http://
numericalmethods.eng.usf.edu 64
Richardsons Extrapolation for
Trapezoidal Rule
From the previous development, it can be shown
that
when the segment size is doubled and that
which is Richardsons Extrapolation.
http://
numericalmethods.eng.usf.edu 65
Example 1





The vertical distance covered by a rocket from 8 to 30
seconds is given by
a) Use Richardsons rule to find the distance covered.
Use the 2-segment and 4-segment Trapezoidal
rule results given in Table 1.
b) Find the true error, E
t
for part (a).
c) Find the absolute relative true error, for part (a).
http://
numericalmethods.eng.usf.edu 66







Solution
a)
Using Richardsons extrapolation formula
for Trapezoidal rule
and choosing n=2,
http://
numericalmethods.eng.usf.edu 67
Solution (cont.)

b) The exact value of the above integral is
Hence
http://
numericalmethods.eng.usf.edu 68
Solution (cont.)




.


c) The absolute relative true error would then be
Table 2 shows the Richardsons extrapolation
results using 1, 2, 4, 8 segments. Results are
compared with those of Trapezoidal rule.
http://
numericalmethods.eng.usf.edu 69


.
Solution (cont.)
Table 2: The values obtained using Richardsons
extrapolation formula for Trapezoidal rule for
n Trapezoidal
Rule
for Trapezoidal
Rule
Richardsons
Extrapolation
for Richardsons
Extrapolation
1
2
4
8
11868
11266
11113
11074
7.296
1.854
0.4655
0.1165
--
11065
11062
11061
--
0.03616
0.009041
0.0000
Table 2: Richardsons Extrapolation Values
http://
numericalmethods.eng.usf.edu 70
Romberg Integration

Romberg integration is same as Richardsons
extrapolation formula as given previously. However,
Romberg used a recursive algorithm for the
extrapolation. Recall
This can alternately be written as
http://
numericalmethods.eng.usf.edu 71
Note that the variable TV is replaced by as the
value obtained using Richardsons extrapolation formula.
Note also that the sign is replaced by = sign.
Romberg Integration













Hence the estimate of the true value now is
Where Ch
4
is an approximation of the true error.
http://
numericalmethods.eng.usf.edu 72
Romberg Integration

Determine another integral value with further halving
the step size (doubling the number of segments),
It follows from the two previous expressions
that the true value TV can be written as
http://
numericalmethods.eng.usf.edu 73
Romberg Integration



The index k represents the order of extrapolation.
k=1 represents the values obtained from the regular
Trapezoidal rule, k=2 represents values obtained using the
true estimate as O(h
2
). The index j represents the more and
less accurate estimate of the integral.
A general expression for Romberg integration can be
written as
http://
numericalmethods.eng.usf.edu 74
Example 2


The vertical distance covered by a rocket from
to seconds is given by
Use Rombergs rule to find the distance covered. Use
the 1, 2, 4, and 8-segment Trapezoidal rule results as
given in the Table 1.
http://
numericalmethods.eng.usf.edu 75
Solution



From Table 1, the needed values from original
Trapezoidal rule are




where the above four values correspond to using 1, 2,
4 and 8 segment Trapezoidal rule, respectively.
http://
numericalmethods.eng.usf.edu 76
Solution (cont.)


To get the first order extrapolation values,



Similarly,





http://
numericalmethods.eng.usf.edu 77
Solution (cont.)


For the second order extrapolation values,


Similarly,


http://
numericalmethods.eng.usf.edu 78
Solution (cont.)

For the third order extrapolation values,


Table 3 shows these increased correct values in a tree
graph.
http://
numericalmethods.eng.usf.edu 79
Solution (cont.)
11868
1126
11113
11074
11065
11062
11061
11062
11061
11061
1-segment
2-segment
4-segment
8-segment
First Order Second Order Third Order
Table 3: Improved estimates of the integral value using Romberg Integration
http://numericalmethods.eng.usf.edu 80
Integration
Topic: Gauss Quadrature Rule of
Integration
Major: General Engineering
http://numericalmethods.eng.usf.edu 81
Two-Point Gaussian
Quadrature Rule
http://
numericalmethods.eng.usf.edu 82
Basis of the Gaussian
Quadrature Rule
Previously, the Trapezoidal Rule was developed by the method
of undetermined coefficients. The result of that development is
summarized below.
http://
numericalmethods.eng.usf.edu 83
Basis of the Gaussian
Quadrature Rule
The two-point Gauss Quadrature Rule is an extension of the
Trapezoidal Rule approximation where the arguments of the
function are not predetermined as a and b but as unknowns
x
1
and x
2
. In the two-point Gauss Quadrature Rule, the
integral is approximated as
http://
numericalmethods.eng.usf.edu 84
Basis of the Gaussian
Quadrature Rule
The four unknowns x
1
, x
2
, c
1
and c
2
are found by assuming that
the formula gives exact results for integrating a general third
order polynomial,
Hence

http://
numericalmethods.eng.usf.edu 85
Basis of the Gaussian
Quadrature Rule






It follows that
Equating Equations the two previous two expressions yield



http://
numericalmethods.eng.usf.edu 86
Basis of the Gaussian
Quadrature Rule

Since the constants a
0
, a
1
, a
2
, a
3
are arbitrary



http://
numericalmethods.eng.usf.edu 87
Basis of Gauss Quadrature













The previous four simultaneous nonlinear Equations have
only one acceptable solution,



http://
numericalmethods.eng.usf.edu 88
Basis of Gauss Quadrature




Hence Two-Point Gaussian Quadrature Rule
http://numericalmethods.eng.usf.edu 89
Higher Point Gaussian
Quadrature Formulas
http://
numericalmethods.eng.usf.edu 90




Higher Point Gaussian Quadrature
Formulas
is called the three-point Gauss Quadrature Rule.
The coefficients c
1
, c
2
, and c
3
, and the functional arguments x
1
, x
2
, and x
3

are calculated by assuming the formula gives exact expressions for
General n-point rules would approximate the integral
integrating a fifth order polynomial
http://
numericalmethods.eng.usf.edu 91
Arguments and Weighing Factors
for n-point Gauss Quadrature
Formulas




In handbooks, coefficients and
Gauss Quadrature Rule are
as shown in Table 1.
Points Weighting
Factors
Function
Arguments
2 c
1
= 1.000000000
c
2
= 1.000000000
x
1
= -0.577350269
x
2
= 0.577350269
3 c
1
= 0.555555556
c
2
= 0.888888889
c
3
= 0.555555556
x
1
= -0.774596669
x
2
= 0.000000000
x
3
= 0.774596669
4 c
1
= 0.347854845
c
2
= 0.652145155
c
3
= 0.652145155
c
4
= 0.347854845
x
1
= -0.861136312
x
2
= -0.339981044
x
3
= 0.339981044
x
4
= 0.861136312
arguments given for n-point
given for integrals
Table 1: Weighting factors c and function
arguments x used in Gauss Quadrature
Formulas.
http://
numericalmethods.eng.usf.edu 92


Arguments and Weighing Factors
for n-point Gauss Quadrature
Formulas
Points Weighting
Factors
Function
Arguments
5 c
1
= 0.236926885
c
2
= 0.478628670
c
3
= 0.568888889
c
4
= 0.478628670
c
5
= 0.236926885
x
1
= -0.906179846
x
2
= -0.538469310
x
3
= 0.000000000
x
4
= 0.538469310
x
5
= 0.906179846
6 c
1
= 0.171324492
c
2
= 0.360761573
c
3
= 0.467913935
c
4
= 0.467913935
c
5
= 0.360761573
c
6
= 0.171324492
x
1
= -0.932469514
x
2
= -0.661209386
x
3
= -0.2386191860
x
4
= 0.2386191860
x
5
= 0.661209386
x
6
= 0.932469514
Table 1 (cont.) : Weighting factors c and function arguments x used in
Gauss Quadrature Formulas.
http://
numericalmethods.eng.usf.edu 93
Arguments and Weighing Factors
for n-point Gauss Quadrature
Formulas


So if the table is given for integrals, how does one solve
? The answer lies in that any integral with limits of
can be converted into an integral with limits Let
If then
If then
Such that:
http://
numericalmethods.eng.usf.edu 94
Arguments and Weighing Factors
for n-point Gauss Quadrature
Formulas
Then Hence

Substituting our values of x, and dx into the integral gives us
http://
numericalmethods.eng.usf.edu 95
Example 1
For an integral derive the one-point Gaussian Quadrature
Rule.



Solution
The one-point Gaussian Quadrature Rule is
http://
numericalmethods.eng.usf.edu 96
Solution









Assuming the formula gives exact values for integrals



and
Since the other equation becomes
http://
numericalmethods.eng.usf.edu 97
Solution (cont.)


Therefore, one-point Gauss Quadrature Rule can be expressed as
http://
numericalmethods.eng.usf.edu 98
Example 2



Use two-point Gauss Quadrature Rule to approximate the distance
covered by a rocket from t=8 to t=30 as given by
Find the true error, for part (a).
Also, find the absolute relative true error, for part (a).
a)
b)
c)
http://
numericalmethods.eng.usf.edu 99
Solution


First, change the limits of integration from [8,30] to [-1,1]
by previous relations as follows

http://
numericalmethods.eng.usf.edu 100
Solution (cont)

.
Next, get weighting factors and function argument values from Table 1
for the two point rule,
.
http://
numericalmethods.eng.usf.edu 101
Solution (cont.)








Now we can use the Gauss Quadrature formula




http://
numericalmethods.eng.usf.edu 102
Solution (cont)

since



http://
numericalmethods.eng.usf.edu 103
Solution (cont)

The absolute relative true error, , is (Exact value = 11061.34m)
c)
The true error, , is b)

You might also like