1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

77
1 Chapter 6 Numerical Methods for Ordinary Differential Equations

Transcript of 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

Page 1: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

1

Chapter 6Numerical Methods for Ordinary

Differential Equations

Page 2: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

2

6.1 The Initial Value Problem: Background

Page 3: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

3

Example 6.1

Page 4: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

4

Example 6.2

Page 5: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

5

Example 6.3

Page 6: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

6

Example 6.4

Page 7: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

7

Methods

To solve differential equation problem:– If f is “smooth enough”, then

a solution will exist and be unique we will be able to approximate it accurately with a wide varie

ty of method

– Two ways of expressing “smooth enough” Lipschitz continuity Smooth and uniformly monotone decreasing

Page 8: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

8

Definitions 6.1 and 6.2

Page 9: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

9

Example 6.5

Page 10: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

10

Example 6.5 (con.)

Page 11: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

11

Theorem 6.1

Proof: See Goldstine’s book

Page 12: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

12

6.2 Euler’s Method

We have treated Euler’s method in Chapter 2. There are two main derivations about Euler’s

method– Geometric derivation– Analytic derivation

Page 13: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

13

Geometric Derivation

Page 14: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

14

Page 15: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

15

Analytic Derivation

Page 16: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

16

Error Estimation for Euler’s Method

By the analytic derivation, we have

The residual for Euler’s method:

The truncation error:

Page 17: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

17

Example 6.6

Page 18: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

18

Page 19: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

19

6.3 Analysis of Euler’s Method

Proof: pp. 323-324 (You can study it by yourselves.)

O(h)

Page 20: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

20

Theorem 6.4

Proof: pp. 324-325 (You can study it by yourselves.)

mC

kCC

yChytyCyty

h

tTTtCy

yf

VersionIIMethodsEulerforEstimateError

TtkkTtk

2

1

and , as 01, where

")()(max

small,ly sufficient for Then

. somefor ]),([ solution that theassume

and , in decreasing monotoneuniformly and smooth be Let

) , ' ( 6.4 Theorem

00

],[,000

002

0

O(h)

Page 21: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

21

Discussion

Both error theorems show that Euler’s method is only first-order accurate (O(h)).– If f is only Lipschitz continuous, then the constants m

ultiplying the initial error and the mash parameter can be quite large, rapidly growing.

– If f is smooth and uniformly monotone decreasing in y, then the constants in the error estimate are bounded for all n.

Page 22: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

22

Discussion

How is the initial error affected by f ?– If f is monotone decreasing in y, then the effect of the

initial error decreases rapidly as the computation progresses.

– If f is only Lipschitz continuous, then any initial error that is made could be amplified to something exponentially large.

Page 23: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

23

6.4 Variants of Euler’s Method

Euler’s method is not the only or even the best scheme for approximating solutions to initial value problems.

Several ideas can be considered based on some simple extensions of one derivation of Euler’s method.

Page 24: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

24

Variants of Euler’s Method

We start with the differential equation

And replace the derivative with the simple difference quotient derived in (2.1)

What happens if we use other approximations to the derivative?

Page 25: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

25

Variants of Euler’s Method

If we use

then we get the backward Euler method

If we use

then we get the midpoint method

O(h)

O(h2)

Method 1

Method 2

Page 26: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

26

Variants of Euler’s Method

If we use the methods based on interpolation (Section 4.5)

then we get two numerical methods

O(h2)

O(h2)

Method 4

Method 3

Page 27: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

27

Variants of Euler’s Method

By integrating the differential equation:

(6.23)

and apply the trapezoid rule to (6.23) to get

Thus

(6.25)Method 5

O(h3)

Page 28: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

28

Variants of Euler’s Method

We can use a midpoint rule approximation to integrating (6.23)

and get

O(h3)

Method 6

Page 29: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

29

Discussion

What about these method? Are any of them any good?

Observations– Methods 2, 3, and 4 are all based on derivative appro

ximations that are O(h2), thus they are more accurate than Euler method and method 1 (O(h)).

– Similarly, methods 5 and 6 are also more accurate.– Methods 2, 3, and 4 are not single-step methods, but

multistep methods. They depend on information form more than one previous approximate value of the unknown function.

Page 30: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

30

Discussion

Observations (con.)– Concerning methods 1, 4, and 5, all of these

formulas involve we cannot explicitly solve for the new approximate values Thus these methods are called implicit methods.

– Methods 2 and 3 are called explicit methods.

Page 31: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

31

6.4.1 The Residual and Truncation Error

Page 32: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

32

Definition 6.3

Page 33: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

33

Example 6.7

Page 34: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

34

Example 6.8

Page 35: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

35

Definition 6.4

Page 36: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

36

6.4.2 Implicit Methods and Predictor-Corrector Schemes

How to get the value of yn+1? Using Newton’s method or the secant method or a fixed point iteration.

Let y = yn+1

Page 37: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

37

F(y)

F’(y)

F(y)

h

F(y+h)-F(y)

Page 38: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

38

Predictor-corrector idea

Can we use a much cruder (coarse) means of estimating yn+1?

Page 39: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

39

Example 6.11

Page 40: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

40

Example 6.12

Page 41: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

41

Page 42: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

42

Discussion

Generally speaking, unless the differential equation is very sensitive to changes in the data, a simple predictor-corrector method will be just as good as the more time-consuming process of solving for the exact values of yn+1 that satisfies the implicit recursion.

Page 43: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

43

Discussion

If the differential equation is linear, we can entirely avoid the problem of implicitness.

Write the general linear ODE as

Page 44: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

44

6.4.3 Starting Values and Multistep Method

How to find the starting values?

Page 45: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

45

Example 6.15 (con.)

Page 46: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

46

Example 6.15 (con.)

Page 47: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

47

Page 48: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

48

6.4.4 The Midpoint Method and Weak Stability

Page 49: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

49

Page 50: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

50

Page 51: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

51

Discussion

What is going on here?– It is the weakly stability problem.– The problem is not caused by rounding error. – The problem is inherent in the midpoint method and

would occur in exact arithmetic.– Why? (pp. 340-342)

Page 52: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

52

6.5 Single-step Method: Runge-Kutta

The Runge-Kutta family of methods is one of the most popular families of accurate solvers for initial value problems.

Page 53: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

53

Consider the more general method:

Residual

Page 54: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

54

Page 55: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

55

Rewrite the formula of R, we get

Page 56: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

56

Solution 1

Solution 2

Page 57: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

57

Solution 3

Page 58: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

58

Runge-Kutta Method

Page 59: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

59

Example 6.16

Page 60: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

60

Example 6.16 (con.)

Page 61: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

61

One major drawback of the Runge-Kutta methods is that they require more evaluations of the function f than other methods.

Page 62: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

62

6.6 Multistep Methods

6.6.1 The Adams families Adams families include the following most popular

ones:– Explicit methods: Adams-Bashforth families– Implicit methods: Adams-Moulton families

Page 63: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

63

Adams-Bashforth Methods

Page 64: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

64

Page 65: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

65

Discussion

If we assume a uniform grid with mash spacing h, then the formulas for the and simplify substantially, and they are routinely tabulated:

Page 66: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

66

Example 6.17

Table 6.6

Page 67: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

67

Example 6.17 (con.)

Table 6.6

Page 68: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

68

Adams-Moulton Methods

If k = -1 then tn-k= tn+1

If k = -1 then tn-k= tn+1

Page 69: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

69

Example 6.18

Page 70: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

70

Page 71: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

71

6.6.2 The BDF Family

BDF: backward difference formula

Page 72: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

72

The BDF Method (con.)

K = -1

Page 73: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

73

The BDF Method (con.)

Page 74: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

74

6.7 Stability Issues

Page 75: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

75

Definition 6.6

Page 76: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

76

Discussion

Page 77: 1 Chapter 6 Numerical Methods for Ordinary Differential Equations.

77

Example 6.19