310 likes | 524 Views
Numerical Differentiation. Let us compute dy /dx or df/dx at node i Denote the difference operators:. Numerical Differentiation: Finite Difference. Approximate the function between as: Forward Difference: Approximate the function between as: Backward Difference:.
E N D
Numerical Differentiation Let us compute dy/dx or df/dx at node i Denote the difference operators:
Numerical Differentiation: Finite Difference Approximate the function between as: Forward Difference: Approximate the function between as: Backward Difference:
Numerical Differentiation: Finite Difference Approximate the function between three points: Now, evaluate df/dx at x = xi:
Numerical Differentiation: Finite Difference Central Difference: For regular or uniform grid: Let us assume regular grid with a mesh size of h
Numerical Differentiation: Finite Difference • Accuracy: How accurate is the numerical differentiation scheme with respect to the TRUE differentiation? • Truncation Error analysis • Modified Wave Number, Amplitude Error and Phase Error analysis for periodic functions • Recall: True Value (a) = Approximate Value + Error (ε) • Consistency: A numerical expression for differentiation or a numerical differentiation scheme is consistent if it converges to the TRUE differentiation as h → 0.
Truncation Error Analysis: First Derivative Truncation error for forward difference scheme for the 1st Derivative is: O(h) Truncation error for backward difference scheme for the 1st Derivative is: O(h)
Truncation Error Analysis: First Derivative Truncation error for the central difference scheme for the 1st Derivative is: O(h2)
Truncation Error Analysis: Second Derivative Truncation error for this central difference scheme for the 2nd Derivative is: O(h2)
Truncation Error Analysis: Non-Uniform Grid For regular or uniform grid: Truncation error for this central difference scheme for the 1st Derivative is O(h) for non-uniform grid and O(h2) uniform grid
Numerical Differentiation: Finite Difference Consistency: A numerical expression for the derivative is consistent if the leading order term in the Truncation Error (TE) satisfies the following: If the leading order term in the truncation error is: TE = Khp or O(hp) where, the numerical differentiation scheme is consistent if , p ≥ 1
General Technique for Construction of Finite Difference Scheme of Arbitrary Order Method of Undetermined Coefficients General finite difference scheme for uniform grid size h: or or Let us take an example with q = 1, m = 2 and n = 0
General Technique for Construction of Finite Difference Scheme of Arbitrary Order: Example General finite difference scheme for uniform grid size h: Expand all the function values evaluated at nodes other than i using Taylor’s series:
General Technique for Construction of Finite Difference Scheme of Arbitrary Order: Example
General Technique for Construction of Finite Difference Scheme of Arbitrary Order: Example Consider Take q = 2, m = 2 and n = 0 (for example)
General Technique for Construction of Finite Difference Scheme of Arbitrary Order: Example General finite difference scheme for uniform grid size h: LHS RHS RHS RHS
Richardson’s Extrapolation Combine terms to result in derivative estimates of TE O(h2)
Richardson’s Extrapolation Combine terms to result in derivative estimates of TE O(h3)
Richardson’s Extrapolation In order to cancel the term of order hp from the truncation errors of two successive interval halving or doubling, the general formula is given by: Order of the resulting approximation may be (p + 1) or (p + 2) depending on the sequence of terms in the truncation error of the original approximation!
Partial Derivatives • Same expressions can be used for partial derivatives as well. • Example: a function of two variables f(x, y), use indices i and j, grid sizes hx and hy for x and y: • 1st order accurate forward difference at (xi, yj): • 2nd order accurate forward difference at (xi, yj):
Partial Derivatives • 2nd order accurate central difference at (xi, yj): • 2nd order accurate central difference at (xi, yj): • 2nd order accurate backward difference at (xi, yj):