MATH 3Q03: Differentiation With Finite Differences: Bartosz Protas
MATH 3Q03: Differentiation With Finite Differences: Bartosz Protas
Interpolation-Based Approach
Complex Step Derivative
Bartosz Protas
Agenda
Interpolation-Based Approach
I Assumptions :
I f : Ω → R is a smooth function, i.e. is continuously
differentiable sufficiently many times,
I the domain Ω = [a, b] is discretized with a uniform grid
{x1 = a, . . . , xN = b}, such that xj+1 − xj = hj = h (extensions
to nonuniform grids are straightforward)
δf
I The symbol δx j
will denote the approximation of the
0
derivative f (x) at x = xj
B. Protas MATH3Q03, Winter 2017
Approach Based on Taylor Series
Interpolation-Based Approach
Complex Step Derivative
2
I The leading–order error is h6 fj000 , thus the method is
second–order accurate
h 2 (iv )
I The leading–order error is 12 fj , thus the method is
second–order accurate
B. Protas MATH3Q03, Winter 2017
Approach Based on Taylor Series
Interpolation-Based Approach
Complex Step Derivative
Taylor Table
I A general method for choosing the coefficients of a finite
difference formula to ensure the highest possible order of
accuracy
I Example:
P2 consider a one–sided finite difference formula
p=0 ap fj+p , where the coefficients ap , p = 0, 1, 2 are to be
determined.
I Example:
I for j = 2, . . . , N − 1, let the interpolant have the form of a quadratic
polynomial pj (x) on [xj−1 , xj+1 ] (Lagrange interpolating polynomial)
(x − xj )(x − xj+1 ) −(x − xj−1 )(x − xj+1 ) (x − xj−1 )(x − xj )
pj (x) = fj−1 + fj + fj+1
2h2 h2 2h2
(2x − xj − xj+1 ) −(2x − xj−1 − xj+1 ) (2x − xj−1 − xj )
pj0 (x) = fj−1 + fj + fj+1
2h2 h2 2h2
f −f
I Evaluating at x = xj we obtain f 0 (xj ) ≈ pj0 (xj ) = j+12h j−1
(i.e., second–order accurate center–difference formula)
B. Protas MATH3Q03, Winter 2017
Approach Based on Taylor Series
Interpolation-Based Approach
Complex Step Derivative
I Example:
I for j = 3, . . . , N − 2, one can use a fourth–order polynomial as
interpolant pj (x) on [xj−2 , xj+2 ]
I Differentiating with respect to x and evaluating at x = xj we
arrive at the fourth–order accurate finite–difference formula
h4 (v )
δf −fj+2 + 8fj+1 − 8fj−1 + fj−2
= , Err = f
δx j 12h 30