ORDINARY DIFFERENTIAL EQUATIONS Student Notes

95
ORDINARY DIFFERENTIAL EQUATIONS Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier

description

ORDINARY DIFFERENTIAL EQUATIONS Student Notes. ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier. Photo Credit: Mr. Jeffrey Burdick. Ordinary Differential Equations… where to use them. - PowerPoint PPT Presentation

Transcript of ORDINARY DIFFERENTIAL EQUATIONS Student Notes

Page 1: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

ORDINARY DIFFERENTIAL EQUATIONSStudent NotesENGR 351 Numerical Methods for EngineersSouthern Illinois University CarbondaleCollege of EngineeringDr. L.R. ChevalierDr. B.A. DeVantier

Page 2: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Photo Credit: Mr. Jeffrey Burdick

Page 3: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations…where to use them

The dissolution (solubilization) of a contaminant into groundwater is governed by the equation:

where kl is a lumped mass transfer coefficient and Cs is the maximum solubility of the contaminant into the water (a constant). Given C(0)=2 mg/L, Cs = 500 mg/L and kl = 0.1 day-1, estimate C(0.5) and C(1.0) using a numerical method for ODE’s.

CCkdtdC

sl

Page 4: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

A mass balance for a chemical in a completely mixed reactor can be written as:

where V is the volume (10 m3), c is concentration (g/m3), F is the feed rate (200 g/min), Q is the flow rate (1 m3/min), and k is reaction rate (0.1 m3/g/min). If c(0)=0, solve the ODE for c(0.5) and c(1.0)

2kVcQcFdtdcV

Ordinary Differential Equations…where to use them

Page 5: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Before coming to an exam Friday afternoon, Mr. Jones forgot to place 24 cans of a refreshing beverage in the refrigerator. His guests are arriving in 5 minutes. So, of course he puts the beverage in the refrigerator immediately. The cans are initially at 75, and the refrigerator is at a constant temperature of 40.

Ordinary Differential Equations…where to use them

Page 6: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

The rate of cooling is proportional to the difference in the temperature between the beverage and the surrounding air, as expressed by the following equation with k = 0.1/min.

Use a numerical method to determine the temperature of the beverage after 5 minutes and 10 minutes.

airTTkdtdT

Ordinary Differential Equations…where to use them

Page 7: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• A differential equation defines a

relationship between an unknown function and one or more of its derivatives

• Physical problems using differential equations• electrical circuits• heat transfer• motion• contaminant transport

Page 8: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• The derivatives are of the dependent

variable with respect to the independent variable

• First order differential equation with y as the dependent variable and x as the independent variable would be:• dy/dx = f(x,y)

Page 9: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• A second order differential

equation would have the form:d ydx

f x y dydx

2

2

, ,}

does not necessarily have to includeall of these variables

Page 10: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• An ordinary differential equation is

one with a single independent variable.

• Thus, the previous two equations are ordinary differential equations

• The following is not: dy

dxf x x y

11 2 , ,

Page 11: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• The analytical solution of ordinary

differential equation as well as partial differential equations is called the “closed form solution”

• This solution requires that the constants of integration be evaluated using prescribed values of the independent variable(s).

Page 12: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• An ordinary differential equation of

order n requires that n conditions be specified.

• Boundary conditions• Initial conditions

consider this beam where the deflection is zero at the boundariesx= 0 and x = LThese are boundary conditions

Page 13: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

a

yo

P

In some cases, the specific behavior of a system(s)is known at a particular time. Consider how the deflection of a beam at x = a is shown at time t =0 to be equal to yo.Being interested in the response for t > 0, this is called the initial condition.

Page 14: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ordinary Differential Equations• At best, only a few differential

equations can be solved analytically in a closed form.

• Solutions of most practical engineering problems involving differential equations require the use of numerical methods.

Page 15: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Scope of Lectures on ODE• One Step Methods

• Euler’s Method• Heun’s Method• Improved Polygon• Runge Kutta• Systems of ODE

• Boundary Value Problems

Page 16: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Specific Study Objectives• Understand the visual representation of

Euler’s, Heun’s and the improved polygon methods

• Understand the difference between local and global truncation errors

• Know the general form of the Runge-Kutta methods

• Understand the derivation of the second-order RK method and how it relates to the Taylor series expansion

Page 17: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Specific Study Objectives• Realize that there are an infinite number

of possible versions for second- and higher-order RK methods

• Know how to apply any of the RK methods to systems of equations

• Understand the difference between initial value and boundary value problems

Page 18: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Review of Analytical Solutiondydx

x

dy x dx

y x C

4

4

43

2

2

3

At this point lets consider initial conditions.

y(0)=1andy(0)=2

Page 19: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y x C

for y

C

then Cfor y

C

and C

430 1

14 0

31

0 2

24 0

32

3

3

3

What we see are differentvalues of C for the twodifferent initial conditions.

The resulting equations are:

y x

y x

43

1

43

2

3

3

Page 20: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

0

4

8

12

16

0 0.5 1 1.5 2 2.5x

yy (0)=1y (0)=2y (0)=3y (0)=4

Page 21: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

One Step Methods

• Focus is on solving ODE in the form

dydx

f x y ,y

x

xi, yi

Page 22: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

One Step Methods

• Focus is on solving ODE in the form

dydx

f x y

y y hi i

,

1

y

x

xi, yi

Page 23: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

One Step Methods

• Focus is on solving ODE in the form

dydx

f x y

y y hi i

,

1

y

x

h

This is the same as saying:new value = old value + slope x step size

xi, yi

Page 24: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

One Step Methods• Focus is on solving ODE in the form

dydx

f x y

y y hi i

,

1

y

x

slope = dy/dxThis is the same as saying:new value = old value + (dy/dx)(h)where h is the step size

yi

h

Page 25: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

One Step Methods• Focus is on solving ODE in the form

dydx

f x y

y y hi i

,

1

y

x

slope = dy/dxyi

h

This is the same as saying:new value = old value + (dy/dx)(h)where h is the step size

yi+1

Page 26: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Euler’s Method

• The first derivative provides a direct estimate of the slope at xi

• The equation is applied iteratively, or one step at a time, over small distance in order to reduce the error

• Hence this is often referred to as Euler’s One-Step Method

Page 27: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Example

24xdxdy

For the initial condition y(1)=1, determine y for h = 0.1 analytically and using Euler’s method given:

STRATEGY

Page 28: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Strategy• Determine the analytical solution based on the

initial conditions y(1) = 1• i.e. x=1, y=1

• Determine xi+1 = xi + h• Recognize that f(x,y) = = 4x2

• yi+1 = yi + 4(xi)2h• Recognize the meaning of “one-step”

• yi+1 = yi + 4(xi)2h• yi+2 = yi+1 + 4(xi+1)2h• yi+3 = yi+2 + 4(xi+2)2h…..and so on

Page 29: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Error Analysis of Euler’s Method• Truncation error - caused by the nature

of the techniques employed to approximate values of y• local truncation error (from Taylor Series)• propagated truncation error• sum of the two = global truncation error

• Round off error - caused by the limited number of significant digits that can be retained by a computer or calculator

Page 30: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Higher Order Taylor Series Methods

• This is simple enough to implement with polynomials

• Not so trivial with more complicated ODE

• In particular, ODE that are functions of both dependent and independent variables require chain-rule differentiation

• Alternative one-step methods are needed

y y f x y h

f x yhi i i i

i i 1

2

2,

' ,

Page 31: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Modification of Euler’s Methods• A fundamental error in Euler’s method is

that the derivative at the beginning of the interval is assumed to apply across the entire interval

• Two simple modifications will be demonstrated graphically in order to give insight on the different strategies that can be employed

• These modification actually belong to a larger class of solution techniques called Runge-Kutta which we will explore and apply later

Page 32: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Heun’s Method• Determine the derivative for the

interval • the initial point• end point

• Use the average to obtain an improved estimate of the slope for the entire interval

Page 33: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xi xi+1

Take the slope at xiProject to get f(xi+1 )based on the step size h

h

x

Page 34: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

Use this “average” slopeto predict yi+1

hyxfyxfyy iiiiii 2

,, 111

{xxi xi+1

Page 35: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

Use this “average” slopeto predict yi+1

hyxfyxfyy iiiiii 2

,, 111

{xxi xi+1

Page 36: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

y

xi xi+1

hyxfyxfyy iiiiii 2

,, 111

xxi xi+1

Euler’s

Heun’s

x

Page 37: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1

hyxfyxfyy iiiiii 2

,, 111

hyy ii 1

Page 38: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Improved Polygon Method

• Another modification of Euler’s Method

• Uses Euler’s to predict a value of y at the midpoint of the interval

• This predicted value is used to estimate the slope at the midpoint

Page 39: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

• We then assume that this slope represents a valid approximation of the average slope for the entire interval

• Use this slope to extrapolate linearly from xi to xi+1 using Euler’s algorithm

Improved Polygon Method

Page 40: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi

f(xi)

Page 41: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1/2 xi+1

h/2

h

Page 42: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1/2

h/2

Page 43: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1/2

f(xi+1/2)

Page 44: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1/2

f’(xi+1/2)

Page 45: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1/2 xi+1

h

Extend your slopenow to get f(x i+1)

Page 46: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y

xxi xi+1/2 xi+1

f(xi+1)

Page 47: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Both Heun’s and the Improved Polygon Method have been introduced graphically. However, the algorithms used are not as straight forward as they can be.

Let’s review the Runge-Kutta Methods. Choices in values of variable will give us these methods and more. It is recommend that you use this algorithm on your homework.

Runge-Kutta Methods

Page 48: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Runge-Kutta Methods• RK methods achieve the accuracy of a

Taylor series approach without requiring the calculation of a higher derivative

• Many variations exist but all can be cast in the generalized form:

y y x y h hi i i i 1 , ,{

is called the incremental function

Page 49: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

, Incremental Functioncan be interpreted as a representative slope over the interval

a k a k a kwhere the a s are constant and the k s arek f x yk f x p h y q k hk f x p h y q k h q k h

k f x p h y q k h q k h q k h

n n

i i

i i

i i

n i n i n n n n n

1 1 2 2

1

2 1 11 1

3 2 21 1 22 2

1 1 1 1 2 2 1 1 1

' ' :,

,,

, , , ,

Page 50: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

a k a k a kwhere the a s are constant and the k s arek f x yk f x p h y q k hk f x p h y q k h q k h

k f x p h y q k h q k h q k h

n n

i i

i i

i i

n i n i n n n n n

1 1 2 2

1

2 1 11 1

3 2 21 1 22 2

1 1 1 1 2 2 1 1 1

' ' :,

,,

, , , ,

NOTE:k’s are recurrence relationships,that is k1 appears in the equation for k2which appears in the equation for k3This recurrence makes RK methods efficient for computer calculations

Page 51: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Second Order RK Methods

y y a k a k hwherek f x yk f x p h y q k h

i i

i i

i i

1 1 1 2 2

1

2 1 11 1

,,

a k a k a kwhere the a s are constant and the k s arek f x yk f x p h y q k hk f x p h y q k h q k h

k f x p h y q k h q k h q k h

n n

i i

i i

i i

n i n i n n n n n

1 1 2 2

1

2 1 11 1

3 2 21 1 22 2

1 1 1 1 2 2 1 1 1

' ' :,

,,

, , , ,

Page 52: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Second Order RK Methods

• We have to determine values for the constants a1, a2, p1 and q11

• To do this consider the Taylor series in terms of yi+1 and f(xi,yi)

y y a k a k h

y y f x y h f x yh

i i

i i i i i i

1 1 1 2 2

1

2

2, ' ,

Page 53: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

f x yfx

fy

dydx

substituting

y y f x y hfx

fy

dydx

h

i i

i i i i

' ,

,

1

2

2

Now, f’(xi , yi ) must be determined by thechain rule for differentiation

The basic strategy underlying Runge-Kutta methodsis to use algebraic manipulations to solve for valuesof a1, a2, p1 and q11

Page 54: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y y a k a k h

y y f x y hfx

fy

dydx

hi i

i i i i

1 1 1 2 2

1

2

2,

By setting these two equations equal to each other andrecalling:

k f x y

k f x p h y q k hi i

i i

1

2 1 11 1

,,

we derive three equations to evaluate the four unknown constants

Page 55: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

a a

a p

a q

1 2

2 1

2 11

11212

Because we have three equations with four unknowns,we must assume a value of one of the unknowns.

Suppose we specify a value for a2.

What would the equations be?

Page 56: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

a a

p qa

1 2

1 112

11

2

Because we can choose an infinite number of valuesfor a2 there are an infinite number of second orderRK methods.

Every solution would yield exactly the same resultif the solution to the ODE were quadratic, linear or a constant.

Lets review three of the most commonly used andpreferred versions.

Page 57: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

y y a k a k hwherek f x yk f x p h y q k ha a

a p

a q

i i

i i

i i

1 1 1 2 2

1

2 1 11 1

1 2

2 1

2 11

11212

,,

Consider the following:

Case 1: a2 = 1/2

Case 2: a2 = 1

These two methodshave been previouslystudied.

What are they?

Page 58: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

a a

a p

a q

p qa

y y k k h

wherek f x yk f x h y k h

i i

i i

i i

1 2

2 1

2 11

1 112

1 1 2

1

2 1

1 1 1 2 1 21212

12

1

12

12

/ /

,,

Case 1: a2 = 1/2

This is Heun’s Method

Note that k1 is the slope atthe beginning of the interval and k2 is the slope at the end of the interval.

y y a k a k hwherek f x yk f x p h y q k h

i i

i i

i i

1 1 1 2 2

1

2 1 11 1

,,

Page 59: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

a a

a p

a q

p qa

y y k hwherek f x y

k f x h y k h

i i

i i

i i

1 2

2 1

2 11

1 112

1 2

1

2 1

1 1 1 01212

12

12

12

12

,

,

y y a k a k hwherek f x yk f x p h y q k h

i i

i i

i i

1 1 1 2 2

1

2 1 11 1

,,

Case 2: a2 = 1

This is the Improved Polygon Method (also called Mid-Point Technique).

Page 60: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Ralston’s Method

Ralston (1962) and Ralston and Rabinowitiz (1978)determined that choosing a2 = 2/3 provides a minimum bound on the truncation error for the second order RKalgorithms.

This results in a1 = 1/3 and p1 = q11 = 3/4

y y k k h

wherek f x y

k f x h y k h

i i

i i

i i

1 1 2

1

2 1

13

23

34

34

,

,

Page 61: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Example

1.0

11..11..

4 2

hsizestepyeixatyCI

yxdxdy Evaluate the following

ODE using Heun’s Methods (e.g. a2 = ½)

STRATEGY

Page 62: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Strategy• Calculate k1=f(x,y) = =

4x2y• Use initial values x=1, y=1

• Calculate the x and y values for k2• x= xi + h• y= yi + 4(xi)2(yi)h

• Calculate k2 = 4(xi+1 )2(yi+1)• Calculate

• yi+1 = yi +0.5(k1 + k2)h• Start process again using

this value of y and x+h as the new initial values

a a

a p

a q

p qa

y y k k h

wherek f x y

k f x h y k h

i i

i i

i i

1 2

2 1

2 11

1 112

1 1 2

1

2 1

1 1 1 2 1 21212

12

1

12

12

/ /

,

,

Page 63: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Third Order Runge-Kutta Methods• Derivation is similar to the one for the second-

order • Results in six equations and eight unknowns.• One common version results in the following

y y k k k h

wherek f x y

k f x h y k h

k f x h y hk hk

i i

i i

i i

i i

1 1 2 3

1

2 1

3 1 2

16

4

12

12

2

,

,

,

Note the third term

NOTE: if the derivative is a function of x only, this reduces to Simpson’s 1/3 Rule

Page 64: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Fourth Order Runge Kutta• The most popular• The following is sometimes called the

classical fourth-order RK method

y y k k k k h

wherek f x y

k f x h y k h

k f x h y hk

k f x h y hk

i i

i i

i i

i i

i i

1 1 2 3 4

1

2 1

3 2

4 3

16

2 2

12

12

12

12

,

,

,

,

Page 65: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

• Note that for ODE that are a function of x alone that this is also the equivalent of Simpson’s 1/3 Rule

34

23

12

1

43211

,21,

21

21,

21

,

2261

hkyhxfk

hkyhxfk

hkyhxfk

yxfkwhere

hkkkkyy

ii

ii

ii

ii

ii

Page 66: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Example

Use 4th Order RK to solve the following differential equation:

dydx

xyx

I C y

1

1 12 . .

using an interval of h = 0.1

STRATEGY

Page 67: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Strategy• Calculate k1 = f(x,y)• Determine the x and y value for k2, then

calculate k2

• Determine the x and y value for k3, then calculate k3

• Determine the x and y value for k4, then calculate k4

• Estimate • yi+1 = yi +1/6(k1 + 2k2+2k3+k4)h

Page 68: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Higher Order RK Methods

• When more accurate results are required, Bucher’s (1964) fifth order RK method is recommended

• There is a similarity to Boole’s Rule• The gain in accuracy is offset by

added computational effort and complexity

Page 69: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Systems of Equations• Many practical problems in engineering

and science require the solution of a system of simultaneous differential equations

dydx

f x y y y

dydx

f x y y y

dydx

f x y y y

n

n

nn n

11 1 2

22 1 2

1 2

, , , ,

, , , ,

, , , ,

Page 70: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

• Solution requires n initial conditions• All the methods for single equations

can be used• The procedure involves applying the

one-step technique for every equation at each step before proceeding to the next step

dydx

f x y y y

dydx

f x y y y

dydx

f x y y y

n

n

nn n

11 1 2

22 1 2

1 2

, , , ,

, , , ,

, , , ,

Page 71: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Boundary Value Problems

• Recall that the solution to an nth order ODE requires n conditions

• If all the conditions are specified at the same value of the independent variable, then we are dealing with an initial value problem

• Problems so far have been devoted to this type of problem

Page 72: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Boundary Value Problems

• In contrast, we may also have conditions a different value of the independent variable.

• These are often specified at the extreme point or boundaries of as system and customarily referred to as boundary value problems

• To approaches to the solution• shooting method• finite difference approach

Page 73: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

General Methods for Boundary Value ProblemsThe conservation of heat can be used to develop a heat balance for a long, thin rod. If the rod is not insulated along its length and the system is at steady state. The equation that results is: d Tdx

h T Ta

2

2 0 '

T1 T2

Ta

Ta

Page 74: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

T1 T2

Ta

Ta

d Tdx

h T Ta

2

2 0 '

Clearly this second orderODE needs 2 conditions.This can be satisfied byknowing the temperatureat the boundaries,i.e. T1 and T2

T(0) = T1

T(L) = T2

Page 75: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

d Tdx

h T Ta

2

2 0 '

T(0) = T1

T(L) = T2

Use these conditions to solvethe equation analytically.

For a 10 m rod with Ta = 20T(0) = 40T(10) = 200h’ = 0.01

T e ex x 7345 5345 200 1 0 1. .. .

Now that we have an analytical solution, lets evaluate ourtwo proposed numerical methods.

Page 76: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Shooting Method

d Tdx

h T T

dTdx

z

dzdx

h T T

a

a

2

2 0

'

'

Given:

We need an initial valueof z.

For the shooting method, guessan initial value.

Guessing z(0) = 10

Page 77: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

dzdx

h T Ta '

Using a fourth-order RK method with a step sizeof 2, T(10) = 168.38

This differs from the BC T(10) = 200

Making another guess, z(0) = 20

T(10) = 285.90

Because the original ODE is linear, the estimates of z(0) are linearly related.

Guessing z(0) = 10

Page 78: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Using a linear interpolation formula between the valuesof z(0), determine a new value of z(0)

Recall:

first estimate z(0) = 10 T(20) = 168.38 second estimate z(0)=20 T(20) = 285.90

What is z(0) that would give us T(20)=200?

150

200

250

300

0 5 10 15 20 25

z(0)

T(20)

Page 79: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

z 0 10 20 1028590 168 38

200 168 38 12 69

. .

. .

150

200

250

300

0 5 10 15 20 25

z(0)

T(20)

Page 80: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

z 0 10 20 1028590 168 38

200 168 38 12 69

. .

. .

150

200

250

300

0 5 10 15 20 25

z(0)

T(20)

d Tdx

h T T

dTdx

z

dzdx

h T T

a

a

2

2 0

'

'

We can now use this to solve the first order ODE

Page 81: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

For nonlinear boundary value problems, linear interpolation will not necessarily result in an accurate estimation. One alternative is to apply three applications of the shooting method and use quadratic interpolation..

0

50

100

150

200

250

0 5 10

distance (m)

TAnaly ticalSolution

ShootingMethod

Page 82: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Finite Difference MethodsThe finite divided difference approximation forthe 2nd derivative can be substituted into the governing equation.

d Tdx

T T Tx

d Tdx

h T T

T T Tx

h T T

i i i

a

i i ia i

2

21 1

2

2

2

1 12

2

0

2 0

'

'

Page 83: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

T T Tx

h T T

T h x T T h x T

i i ia i

i i i a

1 12

12

12

2 0

2

'

' '

Collect terms

We can now apply this equation to each interior nodeon the rod.

Divide the rod into a grid, and consider a “node” to beat each division. i.e.. x = 2m

T1 T2

L = 10 m

x = 2 m

Page 84: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)L = 10 m

x = 2 m

Consider the previous problem:L = 10 m Ta = 20T(0) = 40T(10) = 200h’ = 0.01

We need to solve for thetemperature at the interiornodes (4 unknowns). Apply the governingequation at these nodes (4equations).What is the matrix?

Page 85: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)x=0 2 4 6 8 10

i=0 1 2 3 4 5

Notice the labeling for numbering x and i

Page 86: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)x=0 2 4 6 8 10

i=0 1 2 3 4 5

40 200

Note also that the dependent values are known at the boundaries (hence the term boundary value problem)

Page 87: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)x=0 2 4 6 8 10

i=0 1 2 3 4 5

40 200Apply the governing equation at node 1

8.4004.28.004.240

''2

21

21

221

20

TTTT

TxhTTxhT a

Page 88: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)x=0 2 4 6 8 10

i=0 1 2 3 4 5

40 200Apply the equation at node 2

8.004.2

''2

321

232

21

TTTTxhTTxhT a

Page 89: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)x=0 2 4 6 8 10

i=0 1 2 3 4 5

40 200

We get a similar equation at node 3

8.004.2

''2

432

243

22

TTTTxhTTxhT a

Page 90: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

aiii TxhTTxhT 21

21 ''2

T(0) T(10)x=0 2 4 6 8 10

i=0 1 2 3 4 5

40 200

8.20004.28.020004.2

''2

43

43

254

23

TTTT

TxhTTxhT a

At node 4, we consider theboundary at the right.

Page 91: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

For the four interior nodes, we get the following4 x 4 matrix

48.15954.12478.9397.65

8.2008.08.08.40

04.2100104.210

0104.2100104.2

4

3

2

1

TT

TTTT

Page 92: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

0

50

100

150

200

250

0 5 10

distance (m)

TAnaly ticalSolutionShootingMethodFiniteDifference

Page 93: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Example

Consider the previous example, but with x=1. What is the matrix?

Page 94: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Specific Study Objectives• Understand the visual representation of

Euler’s, Heun’s and the improved polygon methods.

• Understand the difference between local and global truncation errors

• Know the general form of the Runge-Kutta methods.

• Understand the derivation of the second-order RK method and how it relates to the Taylor series expansion.

Page 95: ORDINARY DIFFERENTIAL  EQUATIONS Student Notes

Specific Study Objectives• Realize that there are an infinite number

of possible versions for second- and higher-order RK methods

• Know how to apply any of the RK methods to systems of equations

• Understand the difference between initial value and boundary value problems