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

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

Dec 18, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

CE33500 – Computational Methods in Civil Engineering

DifferentiationProvided by : Shahab Afshari

[email protected]

Page 2: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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

Page 3: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

• 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.

Page 4: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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.

Page 5: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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

Page 6: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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.

Page 7: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Finite Difference Schemes

• Second-order accurate finite-difference approximations to higher derivatives (which can also be derived from Taylor's theorem) are

Page 8: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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

Page 9: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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.

Page 10: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Richardson Extrapolation

Page 11: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Richardson Extrapolation

Page 12: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Example 3

Page 13: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

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.

Page 14: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

• 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

Page 15: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Example 4

Page 16: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

General Lagrange Interpolation

For general n we obtain

Page 17: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

• 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

Page 18: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Cubic Spline Interpolation

Page 19: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Cubic Spline Interpolation

Page 20: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Cubic Spline Interpolation

Page 21: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Determination of Cubic Spline

Page 22: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Example 4

Page 23: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Example 4 - continued

Page 24: CE33500 – Computational Methods in Civil Engineering Differentiation Provided by : Shahab Afshari safshar00@citymail.cuny.edu.

Example 4 - continued