The Derivation of Second and Fourth Order Differentiation Matrices - - PowerPoint PPT Presentation

the derivation of second and fourth order differentiation
SMART_READER_LITE
LIVE PREVIEW

The Derivation of Second and Fourth Order Differentiation Matrices - - PowerPoint PPT Presentation

1/26 The Derivation of Second and Fourth Order Differentiation Matrices Chris Moody and Boden Hegdal Back Close Introduction Differentiation matrices are a class of band matrices that use meth- ods of linear


slide-1
SLIDE 1

1/26

◭◭ ◮◮ ◭ ◮

Back Close

The Derivation of Second and Fourth Order Differentiation Matrices

Chris Moody and Boden Hegdal

slide-2
SLIDE 2

2/26

◭◭ ◮◮ ◭ ◮

Back Close

Introduction

Differentiation matrices are a class of band matrices that use meth-

  • ds of linear algebra to approximate derivatives. These matrices can

be derived a number of different ways. We will derive a second order differentiation matrix from the Taylor polynomial and a fourth order differentiation matrix from the Lagrange interpolating polynomial.

slide-3
SLIDE 3

3/26

◭◭ ◮◮ ◭ ◮

Back Close

The Problem

In many real life situations we don’t have a simple function to differ-

  • entiate. We may have a set of discrete points and we need to plot their
  • derivative. Differentiation matrices are the perfect tool for this job.

They take that set of discrete points and approximate the derivative as another set of discrete points.

h x1 xi−1 xi xi+1 xn u1 ui−1 ui ui+1 un

slide-4
SLIDE 4

4/26

◭◭ ◮◮ ◭ ◮

Back Close

Taylor’s Theorem

The standard Taylor series has the following form. u(x) = u(a) + u′(a)(x − a) + u′′(a) 2! (x − a)2 + · · · For convenience we will substitute a + h for x and then substitute x for a. u(x + h) = u(x) + u′(x)(h) + u′′(x) 2! h2 + · · ·

slide-5
SLIDE 5

5/26

◭◭ ◮◮ ◭ ◮

Back Close

The Second Order Difference Equation from Taylor’s Theorem

The standard second-order finite difference approximation can be derived by considering the Taylor expansions of u(xi+1) and u(xi−1).

xi−1 xi xi+1 h h

Note: xi+1 = xi + h and xi−1 = xi − h Using the Taylor series: u(xi + h) = u(xi) + u′(xi)h + u′′(xi) 2i h2 + · · · u(xi − h) = u(xi) − u′(xi)h + u′′(xi) 2i h2 + · · ·

slide-6
SLIDE 6

6/26

◭◭ ◮◮ ◭ ◮

Back Close

Difference Equation

Subtracting one equation from the other, and eliminating higher or- der terms, we get: u(xi + h) − u(xi − h) = 2u

′(xi)h

u′(xi) = u(xi + h) − u(xi − h) 2h . However, xi+1 = xi + h and xi−1 = xi − h. u′(xi) = u(xi+1) − u(xi−1) 2h

slide-7
SLIDE 7

7/26

◭◭ ◮◮ ◭ ◮

Back Close

How the Difference Equation Works

The difference equation approximates the derivative at a point (xi, u(xi)) using the slope of the line that passes through the point before it (xi−1, u(xi−1)) and the point after it (xi+1, u(xi+1)). u′(xi) = u(xi+1) − u(xi−1) 2h

xi−1 xi xi+1 u 2h

slide-8
SLIDE 8

8/26

◭◭ ◮◮ ◭ ◮

Back Close

Assuming Periodicity

Before we can go any further we must assume that the function we are evaluating is periodic. We know that in most cassis it is not but it is going to be necessary so that we can set up our system of equations. u0 = un u1 = un+1

h x0 x1 xi−1 xi xi+1 xn xn+1 un u1 ui−1 ui ui+1 un u1

slide-9
SLIDE 9

9/26

◭◭ ◮◮ ◭ ◮

Back Close

System of Equations

Our previous result: u′(xi) = u(xi+1) − u(xi−1) 2h Replacing u′(xi) with wi, u(xi+1) with ui+1, and u(xi−1) with ui−1 gives us the standard second order difference equation. wi = ui+1 − ui−1 2h We will now use this difference equation to set up a system of equa- tions that represent the derivative of the function. To set up the system of equations we will set i = 1, 2, 3, . . . , n

slide-10
SLIDE 10

10/26

◭◭ ◮◮ ◭ ◮

Back Close

System of Equations

w1 = u2 − un 2h w2 = u3 − u1 2h w3 = u4 − u2 2h . . . wN−1 = uN − uN−2 2h wN = u1 − uN−1 2h

slide-11
SLIDE 11

11/26

◭◭ ◮◮ ◭ ◮

Back Close

Matrix Form

The system takes the form w = Du, where D =          1/2 . . . −1/2 −1/2 1/2 . . . −1/2 1/2 . . . . . . . . . . . . . . . ... . . . . . . . . . ... 1/2 . . . −1/2 1/2 1/2 . . . −1/2          .

slide-12
SLIDE 12

12/26

◭◭ ◮◮ ◭ ◮

Back Close

Example

Lets look at an example using the following set of 8 discrete points (2,5),(4,15),(6,35),(8,65),(10,100),(12,145),(14,195), and (16,255).            w1 w2 w3 w4 w5 w6 w7 w8            = 1 2        1/2 . . . −1/2 −1/2 1/2 . . . −1/2 . . . . . . . . . . . . ... . . . . . . . . . 1/2 1/2 . . . −1/2                   5 15 35 65 100 145 195 255           

slide-13
SLIDE 13

13/26

◭◭ ◮◮ ◭ ◮

Back Close

Answer

The vector w contains the y values of the derivative approximation. The x values are the same as the x values of the points we wanted to take a derivative of.            w1 w2 w3 w4 w5 w6 w7 w8            =            −60 7.5 12.5 16 20 23.75 27.5 −47.5           

slide-14
SLIDE 14

14/26

◭◭ ◮◮ ◭ ◮

Back Close

Graph

5 10 15 −100 −50 50 100 150 200 250 300 x (x,y) y=2x (x,w)

slide-15
SLIDE 15

15/26

◭◭ ◮◮ ◭ ◮

Back Close

Fourth Order Differentiation Matrix

0.5 1 1.5 2 2.5 3 0.2 0.4 0.6 0.8 1 x

h x1 xi−2 xi−1 xi xi+1 xi+2 xn u1 ui−2 ui−1 ui ui+1 ui+2 un

slide-16
SLIDE 16

16/26

◭◭ ◮◮ ◭ ◮

Back Close

Lagrange Interpolating Polynomial

P(x) =

5

  • k=1

  

5

  • l=1

l=k

x − xl xk − xl    yk P(x) =   

5

  • l=1

l=1

x − xl x1 − xl    y1 +   

5

  • l=1

l=2

x − xl x2 − xl    y2 +   

5

  • l=1

l=3

x − xl x3 − xl    y3 +   

5

  • l=1

l=4

x − xl x4 − xl    y4 +   

5

  • l=1

l=5

x − xl x5 − xl    y5

slide-17
SLIDE 17

17/26

◭◭ ◮◮ ◭ ◮

Back Close

Fitting the Curve

1 2 3 4 5 6 −1 −0.5 0.5 1 x

h x1 xi−2 xi−1 xi xi+1 xi+2 xn u1 ui−2 ui−1 ui ui+1 ui+2 un

slide-18
SLIDE 18

18/26

◭◭ ◮◮ ◭ ◮

Back Close

Fourth Order Polynomial

Pj(x) = (x − xj−1)(x − xj)(x − xj+1)(x − xj+2) (xj−2 − xj−1)(xj−2 − xj)(xj−2 − xj+1)(xj−2 − xj+2)uj−2 + (x − xj−2)(x − xj)(x − xj+1)(x − xj+2) (xj−1 − xj−2)(xj−1 − xj)(xj−1 − xj+1)(xj−1 − xj+2)uj−1 + (x − xj−2)(x − xj−1)(x − xj+1)(x − xj+2) (xj − xj−2)(xj − xj−1)(xj − xj+1)(xj − xj+2)uj + (x − xj−2)(x − xj−1)(x − xj)(x − xj+2) (xj+1 − xj−2)(xj+1 − xj−1)(xj+1 − xj)(xj+1 − xj+2)uj+1 + (x − xj−2)(x − xj−1)(x − xj)(x − xj+1) (xj+2 − xj−2)(xj+2 − xj−1)(xj+2 − xj)(xj+2 − xj+1)uj+2

slide-19
SLIDE 19

19/26

◭◭ ◮◮ ◭ ◮

Back Close

Fourth Order Differentiation Equation

P ′

j(xj) = 1

h 1 12uj−2 − 2 3uj−1 + 2 3uj+1 − 1 12uj+2

slide-20
SLIDE 20

20/26

◭◭ ◮◮ ◭ ◮

Back Close

System of Equations

w1 = 1 h 1 12uN−1 − 2 3uN + 2 3u2 − 1 12u3

  • w2 = 1

h 1 12uN − 2 3u1 + 2 3u3 − 1 12u4

  • w3 = 1

h 1 12u1 − 2 3u2 + 2 3u4 − 1 12u5

  • .

. . wN−1 = 1 h 1 12uN−3 − 2 3uN−2 + 2 3uN − 1 12u1

  • wN = 1

h 1 12uN−2 − 2 3uN−1 + 2 3u1 − 1 12u2

slide-21
SLIDE 21

21/26

◭◭ ◮◮ ◭ ◮

Back Close

Fourth Order Differentiation Matrix

         w1 w2 w3 . . . . . . wN−1 wN          = 1 h           ... 1/12 −2/3 ... −1/12 1/12 ... 2/3 ... ... ... ... −2/3 ... −1/12 1/12 ... 2/3 −1/12 ...                    u1 u2 u3 . . . . . . uN−1 uN         

slide-22
SLIDE 22

22/26

◭◭ ◮◮ ◭ ◮

Back Close

Differentiation Using the Fourth Order Matrix

(2, 2.5), (4, .5), (6, .75), (8, 2.7), (10, .6), (12, .6), (14, 2.7), (16, .75)            w1 w2 w3 w4 w5 w6 w7 w8            = 1 2           ... 1/12 −2/3 ... −1/12 1/12 ... 2/3 ... ... ... ... −2/3 ... −1/12 1/12 ... 2/3 −1/12 ...                      2.5 .5 .75 2.7 .6 .6 2.7 .75           

slide-23
SLIDE 23

23/26

◭◭ ◮◮ ◭ ◮

Back Close

Plotting Data Points

5 10 15 −3 −2 −1 1 2 3 x

y = esin x and y′ = (cos x)esin x

slide-24
SLIDE 24

24/26

◭◭ ◮◮ ◭ ◮

Back Close

Accuracy Increases with an Increase of Points

5 10 15 −2 −1 1 2 3 x

slide-25
SLIDE 25

25/26

◭◭ ◮◮ ◭ ◮

Back Close

Conclusion

20 40 60 80 100 −6000 −4000 −2000 2000 4000 6000 8000

slide-26
SLIDE 26

26/26

◭◭ ◮◮ ◭ ◮

Back Close

References

[1] Loyd N. Trefethen 2000 Spectral Methods in MATLAB.