CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari...

24
CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari [email protected] du

Transcript of CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari...

CE33500 – Computational Methods in Civil Engineering

DifferentiationProvided by : Shahab Afshari

[email protected]

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 Rn(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=x0 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=x0, 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 x0=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.

Richardson Extrapolation

Richardson Extrapolation

Example 3

Interpolation

• Interpolation means finding (approximate) values of a function f(x) for an x between different x-values x0 , x1 , … , xn at which the values of f(x) are given.

Lagrange InterpolationGiven (x0, f0) , (x1, f1), … , (xn, fn) with arbitrarily spaced xj , Lagrange had the idea of multiplying each fj by a polynomial that is 1 at xj 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 (x0, f0) , (x1, f1); Thus the linear Lagrange polynomial p1 is a sum p1 = L0f0 + L1f1 with L0 the linear polynomial that is 1 at x0 and 0 at x1; similarly, L1 is 0 at x0 and 1 at x1 .

Linear Interpolation

Example 4

General Lagrange Interpolation

For general n we obtain

• Given data (x0, f0) , (x1, f1), … , (xn, fn) can be interpolated by a polynomial Pn(x) passes through these n+1 points (xj, fj);

• Now if n is large, there may be trouble: Pn(x) may tend to oscillate for x between the nodes x0 , x1 , … , xn. Hence we must be prepared for numeric instability.

Cubic Spline Interpolation

Cubic Spline Interpolation

Cubic Spline Interpolation

Cubic Spline Interpolation

Determination of Cubic Spline

Example 4

Example 4 - continued

Example 4 - continued