41
Numerical Methods for Differential Equations Chapter 1: Initial value problems Gustaf S¨ oderlind Numerical Analysis, Lund University

Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Numerical Methods for Differential EquationsChapter 1: Initial value problems

Gustaf SoderlindNumerical Analysis, Lund University

Page 2: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Contents V4.16

1. The initial value problem

2. The Explicit Euler method

3. Convergence

4. Order of consistency

5. The trapezoidal rule

6. Theta methods

7. Numerical tests

8. The linear test equation and numerical stability

9. Stiff equations

2 / 41

Page 3: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

1. Initial value problems

Standard formulation of a system of ODEs

y ′ = f (t, y) ; y(0) = y0

with f : R× Rm → Rm

Theorem If f (t, y) is continuous for t ∈ [0,T ] and satisfies theLipschitz condition

‖f (t, u)− f (t, v)‖ ≤ L[f ] · ‖u − v‖

for all u, v ∈ Rm with Lipschitz constant L[f ] <∞, then thereexists a unique solution to the initial value problem on [0,T ] forevery initial value y(0) = y0

3 / 41

Page 4: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Existence and uniqueness

Some problems always satisfy Lipschitz conditions on Rm

Example A linear constant coefficient differential equation

y = Ay ; y(0) = y0

has Lipschitz constant

L[f ] = maxu 6=v

‖Au − Av‖‖u − v‖

= maxy 6=0

‖Ay‖‖y‖

= ‖A‖

The matrix norm ‖A‖ is a Lipschitz constant for f (y) = Ay

4 / 41

Page 5: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Existence and uniqueness

Note Most nonlinear problems do not satisfy a Lipschitz conditionon all of Rm

Example The problem

y = y2; y(0) = y0 > 0

has solutiony(t) =

y01− y0t

The solution blows up at t = 1/y0 (“Finite escape time”)

5 / 41

Page 6: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Standard form x ′ = F (t, x)

Given y ′′ = f (t, y , y ′) with y(0) = y0, y ′(0) = y ′0

Standard substitution Introduce new variables

x1 = y

x2 = y ′

to obtain a system of first order equations

x ′1 = x2

x ′2 = f (t, x1, x2)

with x1(0) = y0 and x2(0) = y ′0

6 / 41

Page 7: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

2. The Explicit Euler method (1768)

Replace y ′ in y ′ = f (t, y) by finite difference approximation

y ′(tn) ≈ y(tn + h)− y(tn)

h

Let yn denote the numerical approximation to y(tn) in

yn+1 − ynh

= f (tn, yn), y0 = y(t0)

Explicit Euler method Compute {yn} recursively from

yn+1 = yn + hf (tn, yn)

tn+1 = tn + h

7 / 41

Page 8: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Explicit Euler Taylor series expansion

Taylor series expansion

y(t + h) = y(t) + hy ′(t) +h2

2!y ′′(ξ)

= y(t) + hf (t, y(t)) + O(h2) ⇒

y(t + h) ≈ y(t) + hf (t, y(t))

Explicit Euler method obtained by dropping higher order terms

yn+1 = yn + hf (tn, yn)

8 / 41

Page 9: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Explicit Euler Geometric interpretation

“Take a step of size h in the direction of the tangent”

0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.7

0.75

0.8

0.85

0.9

0.95

1

1.05

1.1

1.15

1.2

t

y

Ending up on a different solution trajectory (dashed curves), each stepintroduces a local error, eventually accumulating a large global error

9 / 41

Page 10: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Explicit Euler Example

y ′ = −y cos t; y(0) = 1; t ∈ [0, 2π]

Stepsize h = 2π/N with N = 24 gives h = π/12

0 1 2 3 4 5 6 70.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

0 1 2 3 4 5 6 70.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

The numerical solution is a sequence of points (tn, yn)

10 / 41

Page 11: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

3. Convergence

Analytical and numerical solutions at h = π/8 and h = π/128

0 5 10 15 20 250

0.5

1

1.5

2

2.5

3

N=64

0 5 10 15 20 250

0.5

1

1.5

2

2.5

3

N=64*16

The numerical solution approaches the exact solution as h→ 0

Definition A method is convergent if, for every ODE with aLipschitz vector field f , and every fixed T = N · h, it holds that

limN→∞

‖yN,h − y(T )‖ = 0

11 / 41

Page 12: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Local and global errors

1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.80.95

1

1.05

1.1

1.15

t

y

yn+1•

yn•

yn+1

y(t)y(tn)• •

y(tn+1)

Global error en = yn − y(tn) and en+1 = yn+1 − y(tn+1)

Local error ln+1 = yn+1 − y(tn+1)

12 / 41

Page 13: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

The local error Explicit Euler

Insert exact data y(tn) and y(tn+1)

y(tn+1) = y(tn) + hf (tn, y(tn))− ln+1

The residual is the local error

Taylor series y(tn+1) = y(tn) + hy ′(tn) + h2

2 y′′(tn) + . . . ⇒

Explicit Euler local error ln+1 ≈ − h2

2 y ′′(tn)

The local error is evaluated along exact solution (solid curve)

13 / 41

Page 14: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Error propagation From local to global error

Explicit Euler (numerical solution)

yn+1 = yn + hf (tn, yn)

Subtract Taylor series expansion of exact solution

y(tn+1) = y(tn) + hf (tn, y(tn)) +h2

2y ′′(tn) + . . .

Global error recursion

en+1 = en + hf (tn, y(tn) + en)− hf (tn, y(tn)) + ln+1

shows how local errors accumulate into global error

14 / 41

Page 15: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Error propagation . . .

en+1 = en + hf (tn, y(tn) + en)− hf (tn, y(tn)) + ln+1

Take norms and use Lipschitz condition

‖en+1‖ ≤ ‖en‖+ hL[f ] · ‖en‖+ ‖ln+1‖

Lemma Assume that a non-negative sequence {an} satisfies

an+1 ≤ (1 + h µ)an + ch2

with a0 = 0 and µ > 0. Then, for all n ≥ 0,

an ≤ch

µ[(1 + h µ)n − 1] ≤ ch

eµnh − 1

µ

15 / 41

Page 16: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Convergence of the Euler method

Theorem The explicit Euler method is convergent

Proof Suppose f is sufficiently differentiable. Given h > 0 and afixed T = Nh, let en,h = yn,h − y(tn)

Apply the lemma to global error recursion, to get

‖en,h‖ ≤c

L[f ]h [(1 + h L[f ])n − 1] ≤ ch

eTL[f ] − 1

L[f ]

withc = max

n‖ln‖/h2 ≈ max

t‖y ′′‖/2

16 / 41

Page 17: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Convergence of the Euler method . . .

‖en,h‖ ≤c

L[f ]h (eTL[f ] − 1) = C (T ) · h

implies the method is convergent, as limh→0 ‖en,h‖ = 0

Note

1) The global error can be made arbitrarily small

2) The error bound is way too large for practical purposes

3) Better error bounds can be obtained

17 / 41

Page 18: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Theoretical error bound . . . is hopeless!

Exampley ′ = −100y , y(0) = 1

Then L[f ] = 100 and the exact solution is y(t) = e−100t withy ′′(t) = 1002e−100t , so c = 1002/2, with bound

‖en,h‖ ≤1002

2 · 100h (e100T − 1)

Error estimate at T = 1 is ‖en,h‖ ≤ 50 h e100 ≈ 1.4 · 1045h !

Actual error As yn = (1− 100h)n, the error at T = 1 for h < 1/50is ‖en,h‖ = |(1− 100/N)N − e−100| ≤ 3.7 · 10−44h !

The error is overestimated by at least 89 orders of magnitude

18 / 41

Page 19: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Computational test y = λ(y − sin t) + cos t

λ = 0.2, with initial condition y(π/4) = 1/√

2

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

h = π/10 h = π/20

Note Local error O(h2), global error O(h)!

19 / 41

Page 20: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

4. Order of consistency

Always insert exact data and find the residual

If yn+1 = Φh(f , tn, yn, yn−1, . . . ), then the local error is

y(tn+1) = Φh(f , tn, y(tn), y(tn−1), . . . )− ln+1

Definition The order of consistency is p if

y(tn+1)− Φh(f , h, y(tn), y(tn−1), . . . ) = O(hp+1)

as h→ 0, for every analytic f . The local error is then O(hp+1)

Alternative The order of consistency is p if the formula is exactfor all polynomials y = P(t) of degree p or less

20 / 41

Page 21: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Order of consistency Explicit Euler

Example Expanding in Taylor series,

y(tn+1)− [y(tn) + h f (tn, y(tn))] = O(h2)

so the method’s consistency order is one

Alternatively, suppose y(t) = 1 with f = y ′ = 0. Theny(tn+1) = y(tn) + hf (tn, y(tn)) = 1 + h · 0 = 1, so exact

Next take 1st degree polynomial y(t) = t with f = y ′ = 1. Thenh = y(tn+1) = y(tn) + hf (tn, y(tn)) = 0 + h · 1 = h

For 2nd degree polynomial y(t) = t2 with f = y ′ = 2t we geth2 = y(tn+1) = y(tn) + hf (tn, y(tn)) = 0 + h · 0 = 0 6= h2

21 / 41

Page 22: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

5. The trapezoidal rule

Explicit Euler linearizes at tn with slope y ′(tn). Instead, takeaverage of y ′(tn) and y ′(tn+1) and approximate

y ′(tn) ≈ 1

2[f (tn, y(tn)) + f (tn+1, y(tn+1))]

This gives the trapezoidal rule

yn+1 = yn +h

2[f (tn, yn) + f (tn+1, yn+1)]

The method is implicit

Nonlinear equation solving is required on each step

22 / 41

Page 23: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Trapezoidal rule Order and convergence

Insert exact solution and expand in Taylor series

y(tn+1)− {y(tn) +h

2[f (tn, y(tn)) + f (tn+1, y(tn+1))]}

= y(tn) + h y ′(tn) +h2

2y ′′(tn) +

h3

6y ′′′(tn) + O(h4)

− {y(tn) +h

2

(y ′(tn) + [y ′(tn) + h y ′′(tn) +

h2

2y ′′′(tn)]

)}

= −h3

12y ′′′(tn) + O(h4)

Theorem The trapezoidal rule is convergent of order two(No proof given here)

23 / 41

Page 24: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

The dramatic impact of 2nd order convergence

y ′ = −y cos t; y(0) = 1; t ∈ [0, 8π]

Stepsize h = 8π/N with N = 96 gives h = π/12

0 5 10 15 20 250

0.5

1

1.5

2

2.5

3

N=96 Trapezoidal rule

0 5 10 15 20 250

0.5

1

1.5

2

2.5

3

N=96 Explicit Euler

Numerical solutions with Trapezoidal rule and Explicit Euler

24 / 41

Page 25: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Implicit methods Implicit Euler

Implicit Euler yn+1 = yn + h f (tn+1, yn+1)

We need to solve a nonlinear equation to compute yn+1

The extra cost is motivated if we can take larger steps

There are some problems where implicit methods can takeenormously large time steps without losing accuracy!

We will return to how to solve nonlinear equations

25 / 41

Page 26: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Implicit methods Implicit Midpoint Rule

We can also approximate the derivative y ′(t) by

y ′(t) ≈ f

(tn + tn+1

2,yn + yn+1

2

), t ∈ [tn, tn+1]

resulting in the 2nd order Implicit Midpoint Method

yn+1 = yn + h f

(tn + tn+1

2,yn + yn+1

2

)

26 / 41

Page 27: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

6. Theta methods

Approximate y ′ by a convex combination of y ′(tn) and y ′(tn+1)

yn+1 = yn + h [θf (tn+1, yn+1) + (1− θ)f (tn, yn)], θ ∈ [0, 1]

• Explicit Euler θ = 0

• Trapezoidal rule (implicit) θ = 1/2

• Implicit Euler θ = 1 ⇒ yn+1 = yn + h f (tn+1, yn+1)

27 / 41

Page 28: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Theta methods Order and convergence

Use Taylor series expansion to get

y(tn+1)− y(tn)− h [θf (tn+1, y(tn+1)) + (1− θ)f (tn, y(tn))]

= −(θ − 1

2)h2y ′′(tn)− 1

2(θ − 2

3)h3y ′′′(tn) + O(h4)

If θ = 1/2 the method is of order 2; otherwise it is of order 1

Theorem (without proof) The Theta-methods are convergent

28 / 41

Page 29: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

7. Numerical tests Explicit Euler

y = λ(y − sin t) + cos t with λ = −0.2

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

h = π/10 h = π/20

Local error O(h2), global error O(h)

29 / 41

Page 30: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Numerical tests Implicit Euler

y = λ(y − sin t) + cos t with λ = −0.2

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

h = π/10 h = π/20

Local error O(h2), global error O(h)

30 / 41

Page 31: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Numerical tests Implicit Euler

y = λ(y − sin t) + cos t with λ = −10

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

h = π/10 h = π/20

Local error O(h2), global error O(h)

31 / 41

Page 32: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Numerical tests Explicit Euler

y = λ(y − sin t) + cos t with λ = −10

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

h = π/10 h = π/20

Numerical instability!

32 / 41

Page 33: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

8. The linear test equation

Definition The linear test equation is

y ′ = λy , y(0) = 1, t ≥ 0, λ ∈ C

As y(t) = eλt , we have

|y(t)| ≤ K ⇔ Re(λ) ≤ 0

Mathematical stability Bounded solutions if Re(λ) ≤ 0

When does a numerical method have this property?

Does Re(λ) ≤ 0 imply numerical stability?

33 / 41

Page 34: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Numerical stability Stability region

Definition The stability region D of a method is the set of allhλ ∈ C such that |yn| ≤ K when the method is applied to the testequation

Example For Euler’s method, yn+1 = (1 + hλ)yn, implying thatyn remains bounded if and only if |1 + hλ| ≤ 1

−4 −3 −2 −1 0 1 2 3 4−4

−3

−2

−1

0

1

2

3

4

DEuler = {z ∈ C : |1 + z | ≤ 1}

34 / 41

Page 35: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

A-stability

Definition A method is called A-stable if C− ⊂ D

For the trapezoidal rule

DTR =

{z ∈ C :

∣∣∣∣∣1 + 12z

1− 12z

∣∣∣∣∣ ≤ 1

}≡ C−

so Re(z) ≤ 0 implies that yn remains bounded for any h > 0

The explicit Euler method is not A-stable but the implicit Eulermethod and the trapezoidal rule are A-stable

Common idea – “If the original problem is stable, then an A-stablemethod will replicate that behavior numerically”

35 / 41

Page 36: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Relevance of linear test equation

Assume that y ′ = Ay is diagonalizable, with AT = TΛ

Then u = T−1y satsifies u′ = Λu (scalar equations)

If the explicit Euler method is applied to y ′ = Ay , we get

yn+1 = (I + hA)yn

Putting un = T−1yn leads to

un+1 = (I + hΛ)un

T diagonalizes the differential equation and its discretization

Interpret λ in linear test equation as eigenvalue of A

36 / 41

Page 37: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

9. Stiff ODEs

Example Solve y = λ(y − sin t) + cos t with λ = −500

Solution

Particular yP(t) = sin tHomogeneous yH(t) = eλt

General y(t) = eλ(t−t0)(y(t0)− sin t0) + sin t

Study the flow of this equation and numerical solutions

37 / 41

Page 38: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Flow (solution trajectories) λ = −50

0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.40.4

0.5

0.6

0.7

0.8

0.9

1

1.1

1.2

t

y

38 / 41

Page 39: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Stiffness

Stiff differential equations are characterized by homogeneoussolutions being strongly damped

Example y = λ(y − sin t) + cos t with λ� −1

Explicit methods have bounded stability regions putting strongstability restrictions on the step size h

39 / 41

Page 40: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Stiffness Explicit methods

With Explicit Euler the solution approaches sin t as t →∞ if andonly if h < 1/250

The step size h must be kept small, not to keep errors small, butto maintain numerical stability

The Trapezoidal Rule solution approaches sin t as t →∞for every h > 0

The step size must only be kept small to keep errors small

For A-stable methods, there is no stability restriction, only anaccuracy restriction

40 / 41

Page 41: Numerical Methods for Differential Equations Chapter 1 ...ctr.maths.lu.se/na/courses/FMNN10/course_media/material/Chapter1.B16.pdf0 5 10 15 20 25 0 0.5 1 1.5 2 2.5 3 N=64 0 5 10 15

Stiffness Implicit methods

Implicit methods with unbounded stability regions put no stabilityrestrictions on h

The stepsize is only restricted by accuracy requirements

Example The implicit Euler applied to the problem above onlyrequires

ln ≈h2y ′′

2≈ h2

2sin tn

to be sufficiently small, independently of λ

41 / 41