Presentation on theme: "CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari"— Presentation transcript:
CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari firstname.lastname@example.org
Introduction Numeric differentiation is the computation of values of the derivative of a function f from given values of f In mathematics, finite-difference methods (FDM) are numerical methods for approximating the solutions to differential equations using finite difference equations to approximate derivatives
Assuming the function whose derivatives are to be approximated is properly-behaved, by Taylor's theorem, we can create a Taylor Series expansion: where n! denotes the factorial of n, and R n (x) is a remainder term, denoting the difference between the Taylor polynomial of degree n and the original function.
Finite Difference Schemes Consider the diagram below of a typical function f(x). It is desired to evaluate the derivative at point A where x=x 0 i.e. to find the gradient of the tangent at this point.
Finite Difference Schemes For a function f(x) and at a point x=x 0, We will derive an approximation for the first derivative of the function by first truncating the Taylor polynomial as following which is forward difference scheme, first-order-accurate: While, central difference scheme, second-order-accurate
Example 1 Using a step-size of h = 0.01, estimate the derivative of ln(x) at x = 3. Find the value of x where the derivative is really equal to this value. Work to eight decimal places. Set f(x)=ln(x). Now, use the formula with x 0 =3 and h=0.01. So The actual derivative of ln(x) is 1/x which equals 0.3333333 rather than 0.3333345 at x=3. It is at x=2.9999895 that the actual derivative is 0.3333345.
Finite Difference Schemes Second-order accurate finite-difference approximations to higher derivatives (which can also be derived from Taylor's theorem) are
Finite Difference Schemes Non-centered (forward or backward) finite-difference approximations can be derived which are useful for estimating a derivative at the edge of a function's range. For example, a second-order accurate forward finite- difference approximation for the first derivative is
Richardson Extrapolation Richardson’s extrapolation can be viewed as a general procedure for improving the accuracy of approximations when the structure of the error is known. In numerical analysis, Richardson extrapolation is a sequence acceleration method, used to improve the rate of convergence of a sequence.
Interpolation Interpolation means finding (approximate) values of a function f(x) for an x between different x-values x 0, x 1, …, x n at which the values of f(x) are given. Lagrange Interpolation Given (x 0, f 0 ), (x 1, f 1 ), …, (x n, f n ) with arbitrarily spaced x j, Lagrange had the idea of multiplying each f j by a polynomial that is 1 at x j and 0 at the other n nodes and then taking the sum of these n + 1 polynomials. Clearly, this gives the unique interpolation polynomial of degree n or less.
Linear Interpolation is interpolation by the straight line through (x 0, f 0 ), (x 1, f 1 ); Thus the linear Lagrange polynomial p 1 is a sum p 1 = L 0 f 0 + L 1 f 1 with L 0 the linear polynomial that is 1 at x 0 and 0 at x 1 ; similarly, L 1 is 0 at x 0 and 1 at x 1. Linear Interpolation
General Lagrange Interpolation For general n we obtain
Given data (x 0, f 0 ), (x 1, f 1 ), …, (x n, f n ) can be interpolated by a polynomial P n (x) passes through these n+1 points (x j, f j ); Now if n is large, there may be trouble: P n (x) may tend to oscillate for x between the nodes x 0, x 1, …, x n. Hence we must be prepared for numeric instability. Cubic Spline Interpolation