130 likes | 660 Views
Chapter 8. Numerical Integration Lecture (II) 1. 1 Ref.: “Applied Numerical Methods with MATLAB for Engineers and Scientists”, Steven Chapra, 2 nd ed., Ch. 17 , McGraw Hill, 2008. Outline. Newton-cotes formulas (2) Simpson’s 1/3 rule
E N D
Chapter 8 Numerical Integration Lecture (II)1 1 Ref.: “Applied Numerical Methods with MATLAB for Engineers and Scientists”, Steven Chapra, 2nd ed., Ch. 17, McGraw Hill, 2008. Dr. Jie Zou PHY3320
Outline • Newton-cotes formulas • (2) Simpson’s 1/3 rule • The single and composite applications of Simpson’s 1/3 rule • Integration with unequal segments • Example: By hand and Implementation in MATLAB Dr. Jie Zou PHY3320
Simpson’s rules: in general • General Simpson’s rules: To use higher-order polynomials to connect the points; the formulas that result from taking the integrals under these polynomials are called Simpson’s rules. • Trapezoidal rule • Simpson’s rules Dr. Jie Zou PHY3320
Translate the y axis y’ x’ -h O’ h Simpson’s 1/3 rule • Simpson’ 1/3 rule: It corresponds to using second-order polynomials. • Derivation of the formula: • Translate the y axis • Using the Lagrange form for a quadratic fit of three points, (-h, f(x0)), (0, f(x1)), (h, f(x2)): • Integration over the interval [-h, h]: h h = (b – a)/2 Ref. Fig. 17.11 (a) Simpson’s 1/3 rule consists of taking the area under a parabola connecting three points.
Error of the Simpson’s 1/3 rule • For a single application of the Simpson’s 1/3 rule: • lies somewhere in the interval from a to b. • The error is proportional to h5(rather than h3 for the trapezoidal rule); Simpson’s 1/3 rule is more accurate than the trapezoidal rule. • The error is proportional to the fourth-derivative of the actual function; if f(x) is a cubic polynomial, Et = 0. Dr. Jie Zou PHY3320
Example: Single application of Simpson’s 1/3 rule • Ref. Example 17.3: Use Simpson’s 1/3 rule to integrate f(x) = 0.2 + 25x – 200x2 + 675x3 – 900x4 + 400x5 from a = 0 to b = 0.8. Also, find the error Et and t. Compare the result with that found using the Trapezoidal rule (Itrue = 1.640533). • By hand. • Results: t = 16.6% for the Simpson’s 1/3 rule; t = 89.5% for the Trapezoidal rule. The Simpson’s 1/3 rule (single) Dr. Jie Zou PHY3320 The Trapezoidal rule (single)
The composite Simpson’s 1/3 rule • Simpson’s rule can be improved by dividing the integration interval into a number of segments of equal width. • Note: The number of segments has to be even. • h = step size = (b-a)/n; n = the number of segments. Ref. Fig. 17.12 Composite Simpson’s 1/3 rule
Error of the composite Simpson’s 1/3 rule • For a composite application of the Simpson’s 1/3 rule: • The error is proportional to 1/n4 (rather than 1/n2 for the composite trapezoidal rule). • The average f(4)(x) for the interval:
Example: Composite application of the Simpson’s 1/3 rule • Example 17.4 (Ref.): Use the Composite Simpson’s 1/3 rule with n = 4 to estimate the integral of f(x) = 0.2 + 25x – 200x2 + 675x3 – 900x4 + 400x5 from a = 0 to b = 0.8. Also, find the error Et and t (Itrue = 1.640533). • By hand. • Results: t = 1.04% for the Composite Simpson’s 1/3 rule. n = 4; h = 0.2 Dr. Jie Zou PHY3320
Integration with unequal segments • In practice, the data points may be unequally spaced. For example, experimentally obtained data. • Numerical integration: One method is to apply the trapezoidal rule to each segment and sum the results: • hi = the width (step size) of segment i. Dr. Jie Zou PHY3320
Example: Integration with unequal segments • Example 17.6 (Ref.): Determine the integral for the data given in the Table below. Write an M-file, Int_Unequal_Segments.m. (Itrue = 1.640533). Dr. Jie Zou PHY3320