Chapter 3 Interpolation and Polynomial Approximation 3.3 Finite Difference Approximation Consider a function f(x) over an interval [x0, x1] as shown in Figure 3.3-1. The first degree Lagrange polynomial approximating f(x) is given by P1(x) = ( x x0 ) ( x x1 ) f(x0) + f(x1) ( x 0 x1 ) ( x1 x 0 ) Let h = (x1 x0), then P1(x) = 1 [(x1 x) f(x0) + (x x0) f(x1)] h f(x1) E1(x) f(x) P1(x) f(x0) x0 x1 x Figure 3.3-1 Approximating by first-degree polynomial with error E1(x). The function f(x) can be expressed in terms of its approximating polynomial with an error as f(x) = P1(x) + E1(x) The slope of the function at x0 is then dE1 dE1 df 1 dP (x0) = 1 (x0) + (x0) = [ f(x1) f(x0)] + (x0) dx dx h dx dx Forward difference approximation is obtained when the slope of the interpolating polynomial estimates the derivative of the function at x0 as shown in Figure 3.3-2. In term of the forward difference operator f ( x0 ) dE1 df (x0) = + (x0) dx h dx 3-11 where f(xi) = f(xi+1) f(xi). f(x1) f(x) df (x ) 1 dx P1(x) f(x0) df (x ) 0 dx x0 x1 x Figure 3.3-2 Derivatives of the function at x0 and at x1. The error for the derivative can be estimated by taking derivative of the error W1 ( x ) d 2 f E1(x) = () 2! dx 2 dE1 d 1 d2 f (x0) = [ (x x0)(x x1) 2 () ] x 0 dx dx 2 dx dE1 1 d2 f d (x0) = () [(x x0)(x x1) ] x 2 0 dx 2 dx dx dE1 1 d2 f 1 d2 f ] (x0) = ( ) [(x x ) + (x x ) = h () = O(h) 1 0 x0 dx 2 dx 2 2 dx 2 Backward difference approximation is obtained when the slope of the interpolating polynomial estimates the derivative of the function at x1 as shown in Figure 3.3-2. dE1 dE1 df 1 dP (x1) = 1 (x1) + (x1) = [ f(x1) f(x0)] + (x1) dx dx h dx dx The error term has the form dE1 1 d2 f 1 d2 f ] (x1) = ( ) [(x x ) + (x x ) = h () = O(h) 1 0 x1 dx 2 dx 2 2 dx 2 The error in the backward difference approximation, while having the same form as that in the forward difference approximation, has a different sign. In term of the backward difference operator 3-12 f ( x i ) df (xi) = + O(h) dx h where f(xi) = f(xi) f(xi-1) Central difference approximation is obtained when the slope of the interpolating polynomial estimates the derivative of the function at the midpoint x1 as shown in Figure 3.3-3. f(x1) f(x) P2(x) f(x0) x0 x1 x Figure 3.3-3 Derivative of the function at x1 is estimated by a second-degree polynomial. Let h = x1 x0 = x2 x1, the three points interpolating polynomial over this interval is P2(x) = L2,0(x) f(x0) + L2,1(x)f(x1) + L2,2(x)f(x2) P2(x) = ( x x0 )( x x1 ) ( x x0 )( x x 2 ) ( x x1 )( x x 2 ) f(x0) + f(x1) + f(x2) ( x0 x1 )( x0 x 2 ) ( x 2 x0 )( x 2 x1 ) ( x1 x0 )( x1 x 2 ) P2(x) = 1 [(x x1)(x x2)f(x0) 2(x x0)(x x2)f(x1) + (x x0)(x x1) f(x2)] 2h 2 The function f(x) can be expressed in terms of its approximating polynomial with an error as f(x) = P2(x) + E2(x) The slope of the function at x1 is then dP dE 2 dE 2 df 1 (x1) = 2 (x1) + (x1) = [ f(x2) f(x0)] + (x1) dx dx 2h dx dx The error term in this difference approximation is dE 2 d 1 d3 f (x1) = [ (x x0)(x x1)(x x2) 3 () ] x 1 dx dx 3! dx 3-13 dE 2 1 d3 f (x1) = h2 () = O(h2) dx 3! dx 3 The three points approximation is accurate to O(h2). In term of the central difference operator df 1 h h (x1) = [f(x1 + ) + f(x1 )] + O(h2) dx 2h 2 2 where the central difference operator is defined as f(xi) = f(xi + f(x1 + h h ) (xi ) 2 2 h h ) + f(x1 ) = f(x1 + h) f(x1) + f(x1) f(x1 h) = f(x2) f(x0) 2 2 Finite difference approximation of higher order derivatives can also be obtained f(x) = P2(x) + E2(x) The second derivative of the function at x1 is then d 2 P2 d 2 E2 d2 f (x ) = (x ) + (x1) 1 1 dx 2 dx 2 dx 2 After some algebra d 2 E2 1 d2 f (x1) = 2 [f(x0) 2f(x1) + f(x2)] + (x1) h dx 2 dx 2 The error term can be evaluated to yield d 2 E2 2 2 d4 f (x ) = h () = O(h2) 1 4 2 3! dx dx The central difference can also be written in terms of the central difference operator 2 f ( x1 ) d2 f (x ) = + O(h2) 1 dx 2 h2 where 2f(x1) = [f(x1)] = [ f(x1 + h h ) f(x1 )] = f(x2) f(x1) [f(x1) f(x0)] 2 2 3-14