𝑓 𝑎 +𝑓 𝑏
≈ 𝑏−𝑎
2
≈ 𝑏 − 𝑎 𝑥 𝑎𝑣𝑒𝑟𝑎𝑔𝑒 𝑒𝑖𝑔𝑡
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 1(21.1)*
continued
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
The Composite Trapezoidal Rule
The integration domain is divided into a number of segments and
the trapezoidal rule is applied to each segment.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 2(21.2)*
continued
n h I Et%
2 0.4 1.0688 34.9
3 0.2667 1.3695 16.5
4 0.2 1.4848 9.5
5 0.16 1.5399 6.1
6 0.1333 1.5703 4.3
7 0.1143 1.5887 3.2
8 0.1 1.6008 2.4
9 0.0889 1.6091 1.9
10 0.08 1.6150 1.6
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
The Simpson’s Rules
Higher order polynomials may be employed to obtain higher
accuracy. The formulas that result from taking the integrals under
these polynomials are called “Simpson’s Rules.”
a h h b
a x0 b x2
( x x1 )( x x2 ) ( x x0 )( x x2 ) ( x x0 )( x x1 )
x2
I f ( x0 ) f ( x1 ) f ( x2 )dx
x0
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
ba
I f ( x0 ) 4 f ( x1 ) f ( x2 )
h
h
3 2
Single segment application of Simpson’s 1/3 rule has a
truncation error of:
(b a)5 ( 4)
Et f ( ) a b
2880
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
The Composite Simpson’s Rule
𝑏−𝑎
= , 𝑤𝑒𝑟𝑒 𝑛 𝑖𝑠 𝑎𝑛 𝑒𝑣𝑒𝑛 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑠𝑒𝑔𝑚𝑒𝑛𝑡𝑠
𝑛
a x0 b xn
xn x2 x4 xn
(𝑏 − 𝑎)5 (4)
𝐸𝑎 = − 4
𝑓
180𝑛
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Simpson’s 3/8 Rule
Fitting a 3rd order Lagrange polynomial to 4 points yields
(b a)
h
3
b b
f ( x)dx f ( x)dx
a a
3
3h
I f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
8
I (b a)
f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
8
Simpson’s 3/8 rule has a truncation error of:
(b a)5 (4)
Et f ( ) a b h h h
6480 a b
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 6(21.6b)*
Use Simpson’s 3/8 rule in conjunction with Simpson 1/3 rule to
numerically integrate the following function for 5 segments from
a = 0 to b = 0.8:
𝑓 𝑥 = 0.2 + 25𝑥 − 200 𝑥 2 + 675𝑥 3 − 900𝑥 4 + 400𝑥 5
The exact solution is 1.64053334.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 6(21.6b)*
continued
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Integration with unequal segments
This often occurs when integrating experimentally derived data.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 8(21.8)*
Recompute the integral for the data below, but use Simpson’s
rules for those segments where they are appropriate.
Recall, The exact solution is 1.64053334.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 8(21.8)*
continued
Interval 1 2 3
x 0 0.12 0.22 0.32
Interval 0.12 0.1 0.1
Width
Trapezoidal
Simpson’s 1/3
Interval 4 5 6
x 0.32 0.36 0.40 0.44
Interval 0.04 0.04 0.04
Width
Simpson’s 3/8
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 8(21.8)*
continued
Interval 7 8 9 10
x 0.44 0.54 0.64 0.70 0.8
Interval 0.1 0.1 0.06 0.1
Width
Simpson’s 1/3
Trapezoidal
Trapezoidal
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 8(21.8)*
continued
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Multiple Integrals
They are widely used in engineering. A simple example would be
to take the double integral of a function over a rectangular area.
b d
I f ( x, y )dydx
a c
Thus, the integral in one of the dimensions is evaluated first. The result
integration is integrated in the second dimension.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Example 9(21.9)*
continued
2544
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Integration of Equations
When given an analytic function to integrate, we can generate values at
any point we desire. This can be exploited to yield higher accuracy.
Gauss Quadrature
It can be used to integrate numerically
analytic functions only.
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Higher-Point Formulas
I c0 f ( x0 ) c1 f ( x1 ) ..... cn1 f ( xn1 ) , n= number of points
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Numerical Differentiation
We can employ Taylor series expansions to derive finite-divided
difference approximations of derivatives.
Equations (2) and (4) are the forward finite divided difference
formulas for f ’(xi) and f”(xi) of O(h)
ENGR 3202 Dr. Mohamed Badran Spring 2014
Forward Finite-Divided Difference
*Chapra, Steven C., and Canale, Raymond P. “Numerical Methods for Engineers”, 5th edition, McGraw Hill. Inc., 2006.
ENGR 3202 Dr. Mohamed Badran Spring 2014
Improving Derivative estimates
1. Decrease h
2. Use a higher-order formula that employs more points
3. C.D. formulas are preferred to F.D. or B.D. Formulas with
the same number of points.