Anda di halaman 1dari 59

# Finite Difference Methods

## Read Chapters 2, 5 from the NOTES

The Big Picture

2
Outline - Finite Difference Methods
Key Concepts

## Explicit Finite-Difference Methods

Taylor Series
Lagrange Polynomials
Difference Calculus
Differentiation Matrices

## Finite-Difference Methods in Multiple Dimensions

3
The Finite-Difference Method (FDM)

4
Truncation Error

5
Truncation Error

6
Grid Notation

7
Non-Uniqueness

8
Graphical Interpretation: Forward Difference

9
Graphical Interpretation: Backward Difference

10
Graphical Interpretation: Central Difference

11
An Important Point

12
Stencils

13
Outline

## Explicit Finite-Difference Methods

14
Explicit Finite-Difference Methods (EFDMs)

15
Outline

Taylor Series

16
' 3 fi 4
Example: second-order one-sided difference for fi =

## Taylor series at (i+2) and (i+1) about (i)

fi+2 = fi + fi'2h + fi" (2h) + fi"' (2h) + ...
1 2 1 3
(1)
2! 3!

## fi+1 = fi + fi' h + 1 " 2 1 "' 3

fi h + fi h + ... (2)
2! 6

## (2)x4 (1) to eliminate O(fi"h2) terms:

' 4 "' 3
4 fi+1 fi+2 = 3 fi + 2 fi h fi h + ...
6

f ' 3 fi 4 fi 1 fi 2 1 "' 2
fi = fi h + ...
x i 2h 3

3 fi 4 fi 1 fi 2 2
= + O(h )
2h

17
Taylor Series: General Derivation of EFDMs

18
Example: continued general derivation

19
Example (continued)

20
Example review

21
Outline

Lagrange Polynomials

22
Lagrange Polynomials brief review
If we wish to describe all of the ups and downs in a data set, and hit every point
Suppose the data set consists of N data points:
(x1, 1), (x2, 2), (x3, 3), ..., (xN, N)
The interpolation polynomial will have degree N 1. It is given by:
P(x) = L1(x). 1 + L2(x). 2 + L3(x). 3 + ... + LN(x). N
where the functions Li(x) (i = 1, 2, 3, ..., n) are given by:
N x x
Li ( x)
x x1 x x2 x x3 ....... x xi 1 x xi 1 ..... x xN

j

## xi x1 xi x2 xi x3 ....... xi xi1 xi xi1 ..... xi xN j1 xi x j

j i

Notice that the numerator of Li(x) contains the entire sequence of factors (x
x1), (xx2), (xx3), ... (xxN), with the exception of the single factor (xxi).
Likewise, the denominator contains the entire sequence of factors (xi x1), (xi
x2), (xi x3), ... (xi xN), with the exception of the single factor (xi xi).
Now notice: Li(xi) = 1 (numerator = denominator), but Li(xj) = 0 (numerator =
0, since it contains the factor (xj xj) ) for any j not equal to i. This means that
P(xi) = i , which is exactly what we want!

23
Lagrange Polynomials an example
Fit the following data with Lagrange polynomial:

L1 ( x)
x (x)
0 250 L2 ( x)
10 0
20 50 L3 ( x)
30 100
L4 ( x)

## Multiplying each of these by the appropriate i (i = 1, 2, 3, 4) and adding

together the terms of like power then gives:

24
Derivation of EFDMs: Lagrange Polynomials

## Note: j=0 is the i point.

So l and r are relative
to the i point

Note : p ( xi ) ( xi ) 25
Derivation of EFDMs: Lagrange Polynomials

26
Example

27
Example: continued
First term :
x x1 x x2 x 2 x1 x x2 x x1 x2
0
(h)(2h)
0
2h 2

## Derivative of term in bracket :

2 x x1 x2
2 x x0 x1 x0 x2 x0
2 x x0 h 2h
2 x x0 3h

28
Example (continued)

29
Example review

30
Graphical Interpretation
n: order of derivative
r: rightmost point of stencil
l: leftmost point of stencil
h: grid spacing

( x) : actual function
p( x) : Lagrange polynomial

31
Graphical Interpretation

32
Graphical Interpretation

33
Graphical Interpretation

34
Graphical Interpretation

35
Graphical Interpretation

36
Outline

Difference Calculus

37
Difference Calculus
Displacement operator:

## Centered difference operators:

Averaging operator:

38
Difference Calculus (contd.)
Relationships:

## Inverse of displacement operator:

So:
Relation between centered difference and averaging ops:

39
Difference Calculus (contd.)
Differential operator:
Raising operator to power: implies repeated applications

## Taylor series: yields relationships between displacement

and derivative operators

40
Difference Calculus (contd.)
So:

## Example: second-order retain the first 2 terms:

to obtain

Collecting terms:

41
Outline

## Explicit Finite-Difference Methods

Differentiation Matrices

42
Differentiation Matrices

43
Differentiation Matrices: Example

44
Differentiation Matrices: Example

45
Differentiation Matrices

46
Outline

## Implicit Finite-Difference Methods

47
Implicit Finite-Difference Methods (IFDMs)

48
Implicit Finite-Difference Methods (IFDMs)

d i1 i1
Recall: Explicit finite difference (EFD) would be written as: dx
i 2x

49
Implicit Finite-Difference Methods (IFDMs)

50
IFD Approximations

51
Derivation of IFD Approximations

52
IFD Using Truncation Error Cancellation
Example: centered difference approx. to first derivative:
(*)

## Want to raise accuracy from 2nd to 4th order (same stencil)

Expand first-order derivatives at i1 using Taylor series:

## and substitute back into (*)

53
54
IFD Using Truncation Error Cancellation

## Finally, compute derivatives from

55
Implicit Finite-Difference Methods (IFDMs)

56
Outline

## Finite-Difference Methods in Multiple Dimensions

57
Finite Differences in Multiple Dimensions

58