Chap. 11 Numerical Differentiation and Integration Computer Theory and Formal Methods LAB HWANG Dae-Yon (dyhwang@formal.korea.ac.kr) SIM Jae-Hwan (jhsim@formal.korea.ac.kr) YANG Jin-Seok (jsyang@formal.korea.ac.kr) May. 18, 2005
Contents 11.1 DIFFERENTIATION 11.2 BASIC NUMERICAL INTEGRATION 11.1.1 First Derivatives 11.1.2 Higher Derivatives 11.1.3 Richardson Extrapolation 11.2 BASIC NUMERICAL INTEGRATION 11.2.1 Trapezoid Rule 11.2.2 Simpson Rule 11.2.3 Midpoint Rule 11.2.4 Other Newton-Cotes Open Formulas
11.1 DIFFERENTIATION 11.1.1 First Derivatives Forward difference formula Backward difference formula Central difference formula
Example 11.1 Forward, Backward and Central Differences Data Points (x0, y0) = (1,2) (x1, y1) = (2,4) (x2, y2) = (3,8) (x3, y3) = (4,16) (x4, y4) = (5,32) Forward Backward Central
Three-point difference formula Three-point forward difference formula Three-point backward difference formula
Discussion Taylor polynomial Forward : h = xi+1 – xi Backward : h = xi-1 – xi
Discussion (cont’) Central : h = xi+1 – xi = xi – xi-1
General Three-Point Formula Based on Lagrange interpolation polynomial (x1 , y1) , (x2 , y2) , (x3 , y3)
General Three-Point Formula(2)
General Three-Point Formula(3) If h = xi+1 – xi = xi – xi-1
General Three-Point Formula(4) If h = xi+1 – xi = xi – xi-1
with truncation error O(h2) 11.1.2 Higher Derivative Formula for higher derivative can be founded by Differentiating the interpolating polynomial repeatedly. Using Taylor expansions. For example, Three equally spaced abscissas xi-1,xi, xi+1 Formula for the second derivative is with truncation error O(h2)
11.1.2 Higher Derivative - Derivation of Second-Derivative Formula If we assume that fourth derivative is continuous on [x-h, x+h], we can write the error term as for some point From the Taylor polynomial where and . adding gives or with truncation error O(h4)
11.1.2 Higher Derivative - Derivation of Second-Derivative Formula Table 11.1 Centered difference formulas, all O(h2) Example 11.3 Second Derivative Estimate the second derivative at x2 = 3, using point (x1, y1) = (2, 4), (x2, y2) = (3, 8), and (x3, y3) = (4, 6); for this example, h=1
11.1.2 Higher Derivative - Partial Derivatives Partial derivative of a function of two variables General point as (xi, yj ) The value of the function u(x, y) at that point as ui, j The spacing in the x and y directions is the same, h Using subscripts to indicate partial differentiation -1 1 i-1 i i+1 j 1 -2 i-1 i i+1 j
11.1.2 Higher Derivative - Partial Derivatives For the mixed second partial derivative and higher derivatives, the schematic form is especially convenient. The Laplacian operator The bi-harmonic operator -1 1 -4 i-1 i i+1 j-1 j j+1 -8 20 2
11.1.3 Richardson Extrapolation Method of improving the accuracy of a low order approximation formula A(h) whose error can be expressed as To apply Richardson extrapolation, we form approximations to A separately using the step size h and h/2 To continue the extrapolation process, consider Where B(h) is simply the extrapolated approximation to A, using step sizes h/2 and h/4, this would correspond to B(h/2). we get which has error O(h6)
11.1.3 Richardson Extrapolation The central difference formula can be written as We can also find f’(x) using one-half the previous value of h Since the coefficient of the h2 term does not change , the two estimates can be combined to give
11.1.3 Richardson Extrapolation - Example 11.4 Improved Estimate of the Derivative From Example 11.1 h=2 The approximation to f’(x2) is based on D(h)=7.5 and D(h/2) The data in the example are points on the curve f(x)=2x. The actual value of f’(x) is (ln2)2x, which gives
11.1.3 Richardson Extrapolation - Discussion Forms a linear combination of approximation A(h) and A(h/2) Dominant error term, which depends on h2, cancels (11.2) or (11.3) Subtracting eq. (11.2) from eq. (11.3) gives or O(h2) O(h4)
11.1.3 Richardson Extrapolation - Discussion To continue the extrapolation, we write where B(h) is simply the extrapolated approximation to A, using step size h, h/2. using step size h/2 and h/4, this would corresponding to B(h/2). Therefore, Define the second level extrapolated approximation to A as
Contents Trapezoid Rule Simpson Rule Midpoint Rule Example 11.5 Discussion about Trapezoid Rule Simpson Rule Example 11.6 Example 11.7 Discussion about Simpson Rule Midpoint Rule Example 11.8 Other Newton-Cotes Open Formulas
Overview (1/2) Numerical integration rules are very important. Functions may not have exact formulas for their antiderivatives (indefinite integrals). An exact formula for the antiderivative dose exist, it may be difficult to find. A numerical integration rule has the form
Overview (2/2) Two basic types of Newton-Cotes formulas. “Closed” formulas : the endpoints values are used. Trapezoid Rule Simpson Rule “Open” formulas : the endpoints are not used. Midpoint Rule Each of these formulas can be derived by approximating the function to be integrated by its Lagrange interpolating polynomial.
Trapezoid Rule This rule approximates the curve by the straight line that passes through the points (a,f(a)) and (b, f(b)).
Trapezoid Rule – Example 11.5 Integral of Using the Trapezoid Rule
Trapezoid Rule – Discussion (1/2) It derived from the Lagrange form of linear interpolation of f(x) using the endpoints of the interval of integration.
Trapezoid Rule – Discussion (2/2)
Simpson Rule Approximating the function to be integrated by a quadratic polynomial leads to the basic Simpon Rule: The approximate integral is given by
Simpson Rule – Example 11.6
Simpson Rule – Example 11.7
Simpson Rule – Discussion (1/2) Simpson’s rule is found by integrating the Lagrange interpolating polynomial for f(x).
Simpson Rule – Discussion (2/2)
Midpoint Rule If we use only function evaluations at points within the interval, the simplest formula is the midpoint rule. This formula uses only one function evaluation (so n = 1),at the midpoint of the interval, xm=(a+b)/2. Interpolating the function by the constant value f(xm) :
Midpoint Rule – Example 11.8
Other Newton-Cotes Open Formulas (1/2) Using two function evaluations Trapezoid Rule
Other Newton-Cotes Open Formulas (2/2) Using three function evaluations Simpson Rule