The Euler Method - School of Mathematicspjohnson/CFD/Lectures/euler_method… · Review Initial...

Preview:

Citation preview

Review Initial Value Problems Euler’s Method Summary

THE EULER METHOD

P.V. Johnson

School of Mathematics

Semester 1 2008

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

ERRORS

Be careful when interpreting results from a computer

Errors can arise in all sorts of places

Using Taylor Series to approximate a differential

Truncation errors

Review Initial Value Problems Euler’s Method Summary

ERRORS

Be careful when interpreting results from a computer

Errors can arise in all sorts of places

Using Taylor Series to approximate a differential

Truncation errors

Review Initial Value Problems Euler’s Method Summary

EULER’S METHOD

Initial value problems for ODEs

Solving ODEs numerically

Euler’s Method

Truncation errors again

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

THE INITIAL VALUE PROBLEM

Here we will look at the solution of ordinary differentialequations of the type, say

dydx

= f (x , y), a ≤ x ≤ b

subject to an initial condition

y(a) = α

Review Initial Value Problems Euler’s Method Summary

THE INITIAL VALUE PROBLEM

Here we will look at the solution of ordinary differentialequations of the type, say

dydx

= f (x , y), a ≤ x ≤ b

subject to an initial condition

y(a) = α

Review Initial Value Problems Euler’s Method Summary

EXAMPLES

CONSIDER THE PROBLEM:

dydx

= y(

1 −y4

)

, x ≥ 0

with the initial condition

y(0) = 1

What can we say about the solution?

How can we go about solving it?

Review Initial Value Problems Euler’s Method Summary

EXAMPLES

CONSIDER THE PROBLEM:

dydx

= y(

1 −y4

)

, x ≥ 0

with the initial condition

y(0) = 1

What can we say about the solution?

How can we go about solving it?

Review Initial Value Problems Euler’s Method Summary

EXTENSION TO HIGHER ORDER ODES

We normally would like to solve higher order ODEs

We can do this by rearranging them as a system of firstorder ODEs

EXAMPLE

y ′′ − 2xyy ′ + y2 = 1, y(1) = 1, y ′(1) = 2.

The equivalent first order system is:

(y1(x), y2(x))T = (y(x), y ′(x))T ,f1(x , y1, y2) = y2(x),

f2(x , y1, y2) = 1 + 2xy1(x)y2(x) − y21 (x),

and initial condition

(y1(1), y2(1))T = (1, 2)T .

Review Initial Value Problems Euler’s Method Summary

EXTENSION TO HIGHER ORDER ODES

We normally would like to solve higher order ODEs

We can do this by rearranging them as a system of firstorder ODEs

EXAMPLE

y ′′ − 2xyy ′ + y2 = 1, y(1) = 1, y ′(1) = 2.

The equivalent first order system is:

(y1(x), y2(x))T = (y(x), y ′(x))T ,f1(x , y1, y2) = y2(x),

f2(x , y1, y2) = 1 + 2xy1(x)y2(x) − y21 (x),

and initial condition

(y1(1), y2(1))T = (1, 2)T .

Review Initial Value Problems Euler’s Method Summary

EXTENSION TO HIGHER ORDER ODES

We normally would like to solve higher order ODEs

We can do this by rearranging them as a system of firstorder ODEs

EXAMPLE

y ′′ − 2xyy ′ + y2 = 1, y(1) = 1, y ′(1) = 2.

The equivalent first order system is:

(y1(x), y2(x))T = (y(x), y ′(x))T ,f1(x , y1, y2) = y2(x),

f2(x , y1, y2) = 1 + 2xy1(x)y2(x) − y21 (x),

and initial condition

(y1(1), y2(1))T = (1, 2)T .

Review Initial Value Problems Euler’s Method Summary

GENERAL SYSTEM OF FIRST ORDER ODES

The general system can be written

dYdx

= F (x , Y ), a ≤ x ≤ b,

where

Y = (y1(x), y2(x), ..., yn(x))T ,F = (f1(x , Y ), f2(x , Y ), ..., fn(x , Y ))T ,

with initial data

Y (a) = α,α = (α1, α2, ..., αn)

T .

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

WELL-POSED PROBLEMS

DEFINITION:

An initial value problem is said to be well-posed if:

A unique solution, y(x), to the problem exists;

The associated perturbed problem has a unique solutionand is sufficiently close to the original solution

How do we go about showing this for a general problem?

What do we mean by a perturbed problem?

With a computer, we are always solving the perturbedproblem

First, we need to know about the Lipschitz condition

Review Initial Value Problems Euler’s Method Summary

WELL-POSED PROBLEMS

DEFINITION:

An initial value problem is said to be well-posed if:

A unique solution, y(x), to the problem exists;

The associated perturbed problem has a unique solutionand is sufficiently close to the original solution

How do we go about showing this for a general problem?

What do we mean by a perturbed problem?

With a computer, we are always solving the perturbedproblem

First, we need to know about the Lipschitz condition

Review Initial Value Problems Euler’s Method Summary

WELL-POSED PROBLEMS

DEFINITION:

An initial value problem is said to be well-posed if:

A unique solution, y(x), to the problem exists;

The associated perturbed problem has a unique solutionand is sufficiently close to the original solution

How do we go about showing this for a general problem?

What do we mean by a perturbed problem?

With a computer, we are always solving the perturbedproblem

First, we need to know about the Lipschitz condition

Review Initial Value Problems Euler’s Method Summary

THE LIPSCHITZ CONDITION

DEFINITION:

A function is said to satisfy the Lipschitz condition in thevariable y on a set D ⊂ R2 if a constant L > 0 exists such that:

|f (x , y1) − f (x , y2)| ≤ L|y1 − y2|

whenever (x , y1), (x , y2) ∈ D. The constant L is called theLipschitz constant for f .

Review Initial Value Problems Euler’s Method Summary

PERTURBED PROBLEM

THE PERTURBED PROBLEM

Let δ(x) be a pertubation to the problem so that δ(x) < ǫ for anyǫ > 0, then

dzdx

= f (x , z) + δ(x), a ≤ x ≤ b, z(a) = α + ǫ0

and the solution z(x) exists with

|z(x) − y(x)| < k(ǫ)ǫ for all a ≤ x ≤ b,

for some constant k(ǫ).

Review Initial Value Problems Euler’s Method Summary

THE THEORY

THEOREM

Suppose D = {(x , y)|a ≤ x ≤ b and −∞ < y < ∞}. If f iscontinuous and satisfies a Lipschitz condition in the variable yon the set D, then the initial-value problem

dydx

= f (x , y), a ≤ x ≤ b, y(a) = α

is well-posed.

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

SOLVING AN INITIAL VALUE PROBLEM

The simplest method to solve an ODE is the Euler method

In order to solve, we must discretise the problem – make acontinuous (infinite) problem discrete (finite)

Divide up the interval [a, b] into n equally spaced intervals

bah

x x x xx0 1 2 i n... ...

Review Initial Value Problems Euler’s Method Summary

SOLVING AN INITIAL VALUE PROBLEM

Suppose y(x) is the unique solution to the ODE, and istwice differentiable

Apply a Taylor series approximation around xi then wehave

y(xi+1) = y(xi) + y ′(xi)h +12

y ′′(ξ)

where xi ≤ ξ ≤ xi+1 .

Review Initial Value Problems Euler’s Method Summary

SOLVING AN INITIAL VALUE PROBLEM

Suppose y(x) is the unique solution to the ODE, and istwice differentiable

Apply a Taylor series approximation around xi then wehave

y(xi+1) = y(xi) + f (xi , y(xi))h +12

y ′′(ξ)

where xi ≤ ξ ≤ xi+1 .

Since y is a solution to the ODE, we can replace y ′ by thefunction f (x , y)

Review Initial Value Problems Euler’s Method Summary

THE EULER METHOD

Assume wi is our approximation to y at xi , then

w0 = α

Then to find all subsequent values of w ,set the remainderto zero in the previous equation to obtain:

wi+1 = wi + hf (xi , wi), for each i = 0, 1, . . . , n − 1

Review Initial Value Problems Euler’s Method Summary

OUTLINE

1 REVIEW

2 INITIAL VALUE PROBLEMS

The ProblemPosing a Problem

3 EULER’S METHOD

MethodErrors

4 SUMMARY

Review Initial Value Problems Euler’s Method Summary

TRUNCATION ERRORS

We would like to be able to compare the errors for differentmethods

We can use the local truncation error – difference betweenequation and the approximation

For the Euler method we have:

τi+1(h) =yi+1 − (yi + hf (xi , yi))

h

=yi+1 − yi

h− f (xi , yi)

Review Initial Value Problems Euler’s Method Summary

TRUNCATION ERRORS

We would like to be able to compare the errors for differentmethods

We can use the local truncation error – difference betweenequation and the approximation

For the Euler method we have:

τi+1(h) =yi+1 − (yi + hf (xi , yi))

h

=yi+1 − yi

h− f (xi , yi)

Review Initial Value Problems Euler’s Method Summary

TRUNCATION ERRORS

We can calculate the truncation error as

τi+1(h) =h2

y ′′(ξi),

and if y ′′ is bounded by the constant M on the interval[a, b] then

|τi+1(h)| ≤h2

M.

Hence the truncation error is O(h).

A method with truncation error O(hp) is called an order pmethod

Review Initial Value Problems Euler’s Method Summary

TRUNCATION ERRORS

We can calculate the truncation error as

τi+1(h) =h2

y ′′(ξi),

and if y ′′ is bounded by the constant M on the interval[a, b] then

|τi+1(h)| ≤h2

M.

Hence the truncation error is O(h).

A method with truncation error O(hp) is called an order pmethod

Review Initial Value Problems Euler’s Method Summary

TRUNCATION ERRORS

We can calculate the truncation error as

τi+1(h) =h2

y ′′(ξi),

and if y ′′ is bounded by the constant M on the interval[a, b] then

|τi+1(h)| ≤h2

M.

Hence the truncation error is O(h).

A method with truncation error O(hp) is called an order pmethod

Review Initial Value Problems Euler’s Method Summary

SUMMARY

Need Lipschitz condition to say a problem is well PosedProblems

Euler’s Method is a first order method

wi+1 = wi + hf (xi , wi), for each i = 0, 1, . . . , n − 1

Truncation errors give a quick estimate of error bounds onthe problem

Recommended