You are on page 1of 33

Review

Boundary Value Problems


Newtons Shooting Method
Summary

B OUNDARY VALUE P ROBLEMS

Dr. Johnson

School of Mathematics

Semester 1 2008

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

I NTIAL VALUE PROBLEMS FOR ODE S

So far we have have encountered initial value problems


We can start at one end and march to the other
We have seen different methods of differing order
We will select a method based upon:
Accuracy – the order of errors in the method
Expense – how time consuming a method is
Stability – yet to talk about this!!

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

I NTIAL VALUE PROBLEMS FOR ODE S

So far we have have encountered initial value problems


We can start at one end and march to the other
We have seen different methods of differing order
We will select a method based upon:
Accuracy – the order of errors in the method
Expense – how time consuming a method is
Stability – yet to talk about this!!

Dr. Johnson MATH65241


Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

B OUNDARY CONTITIONS
All ODEs and PDEs require boundary conditions in order
that a solution may exist
In initial value problems, the boundary conditions are all on
one side
This is not always the case, for instance take the following
problem:

d 2y dy
2
+κ + xy = 0
dx dx
with the boundary conditions

y (0) = 0 and y (1) = 1.

then we have conditions at both ends!


Dr. Johnson MATH65241
Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

B OUNDARY CONTITIONS
All ODEs and PDEs require boundary conditions in order
that a solution may exist
In initial value problems, the boundary conditions are all on
one side
This is not always the case, for instance take the following
problem:

d 2y dy
2
+κ + xy = 0
dx dx
with the boundary conditions

y (0) = 0 and y (1) = 1.

then we have conditions at both ends!


Dr. Johnson MATH65241
Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

B OUNDARY CONTITIONS
All ODEs and PDEs require boundary conditions in order
that a solution may exist
In initial value problems, the boundary conditions are all on
one side
This is not always the case, for instance take the following
problem:

d 2y dy
2
+κ + xy = 0
dx dx
with the boundary conditions

y (0) = 0 and y (1) = 1.

then we have conditions at both ends!


Dr. Johnson MATH65241
Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

R EDUCE THE PROBLEM TO AN ODE


We can rewrite the problem above as a system of first
order ODEs:

Y1 = y (x);
dy
Y2 = ;
dx
dY1
= Y2 ;
dx
dY2
= −κY2 − xY1 .
dx
and the boundary conditions are:

Y1 (x = 0) = 0 and Y1 (x = 1) = 0.
Dr. Johnson MATH65241
Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

W HAT NEXT ?
In order to solve the problem by marching through x we
need to assign a value to Y2 (x = 0)
How to choose a value of Y2 – our choice must satisfy the
boundary condition
2
1.8
1.6
1.4
1.2
y1(x)

1
0.8
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
x
Dr. Johnson MATH65241
Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

W HAT NEXT ?
In order to solve the problem by marching through x we
need to assign a value to Y2 (x = 0)
How to choose a value of Y2 – our choice must satisfy the
boundary condition
2
1.8
1.6
1.4
1.2
y1(x)

1
0.8
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1
x
Dr. Johnson MATH65241
Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

TAKING A GUESS

Start by making a guess, g, to Y2 (0) so that


µ ¶ µ ¶
Y1 (0) 0.
Y (0) = =
Y2 (0) g

Next, solve using your favourite method, to get


µ ¶ µ ¶
Y1 (1) β1
Y (1) = =
Y2 (1) β2

then by comparing the value β1 to our boundary condition,


we can see how good the guess was

Dr. Johnson MATH65241


Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

U P A BIT... DOWN A BIT...

In order to make our guess better, we want to know


whether we have shot above or below
Let us look at the value

φ(g) = Y1 (1; g) − 1,

then the guess is right when φ = 0.


This now looks like a root finding problem
which leads us to Newtons Shooting Method

Dr. Johnson MATH65241


Review
Boundary Value Problems Condition at Both Ends
Newtons Shooting Method Taking a guess
Summary

U P A BIT... DOWN A BIT...

In order to make our guess better, we want to know


whether we have shot above or below
Let us look at the value

φ(g) = Y1 (1; g) − 1,

then the guess is right when φ = 0.


This now looks like a root finding problem
which leads us to Newtons Shooting Method

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

C ORRECTING THE GUESS


Suppose we have taken a guess ĝ, then seek a correction
dg such that

φ(ĝ + dg) = 0

Then take a Taylor expansion around φ(ĝ) to obtain


φ(ĝ + dg) = φ(ĝ) + dg (ĝ) + O(dg 2 )
dg

So equating this to zero and rearranging we find our


correction is
φ(ĝ)
dg = −
φ′ (ĝ)

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

R EMINDER ...

Newton’s root finding algorithm has quadratic convergence


The formula is:

xn+1 = xn − f (x)/f ′ (x)

0.8
Start with a guess x0 = 0.8
0.6
0.4 In order to generate the
0.2 green line, we need the
f(x)

0 gradient of f at x0 = 0.8
-0.2
The new guess is
-0.4
x1 = 0.55625
-0.6
0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

R EMINDER ...

Newton’s root finding algorithm has quadratic convergence


The formula is:

xn+1 = xn − f (x)/f ′ (x)

0.8
Start with a guess x0 = 0.8
0.6
0.4 In order to generate the
0.2 green line, we need the
f(x)

0 gradient of f at x0 = 0.8
-0.2
The new guess is
-0.4
x1 = 0.55625
-0.6
0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

S ECANT M ETHOD
Our formula to generate new guesses is:

φ(gn )
gn+1 = gn −
φ′ (gn )

How do we find φ′ (gn )?


We could estimate it by

φ(gn ) − φ(gn−1 )
φ′ (gn ) =
gn − gn−1

to give the Secant Method

φ(gn )(gn − gn−1 )


gn+1 = gn −
φ(gn ) − φ(gn−1 )
Dr. Johnson MATH65241
Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

S ECANT M ETHOD
Our formula to generate new guesses is:

φ(gn )
gn+1 = gn −
φ′ (gn )

How do we find φ′ (gn )?


We could estimate it by

φ(gn ) − φ(gn−1 )
φ′ (gn ) =
gn − gn−1

to give the Secant Method

φ(gn )(gn − gn−1 )


gn+1 = gn −
φ(gn ) − φ(gn−1 )
Dr. Johnson MATH65241
Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

O UTLINE

1 R EVIEW
2 B OUNDARY VALUE P ROBLEMS
Condition at Both Ends
Taking a guess

3 N EWTONS S HOOTING M ETHOD


Correcting the guess
The Secant Method
Newtons Method

4 S UMMARY

Dr. Johnson MATH65241


Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

I NITIAL VALUE P ROBLEM FOR g


Consider again
dY1
=Y2
dx
dY2
= − κY2 − xY1
dx

with Y (0) = (0, g)T


Then we can write
∂Y1
φ′ (gn ) = (1; gn )
∂g

This suggests we should differentiate the original


equations with respect to g
Dr. Johnson MATH65241
Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

I NITIAL VALUE P ROBLEM FOR g


Consider again
dY1
=Y2
dx
dY2
= − κY2 − xY1
dx

with Y (0) = (0, g)T


Then we can write
∂Y1
φ′ (gn ) = (1; gn )
∂g

This suggests we should differentiate the original


equations with respect to g
Dr. Johnson MATH65241
Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

I NITIAL VALUE P ROBLEM FOR g


Then the initial value problem for φ′ is given by

½ ¾ Ã ∂Y2
!
d ∂Y ∂g
= ,
dx ∂g −κ ∂Y ∂Y1
∂g − x ∂g
2

¯ µ ¶
∂Y ¯¯ 0
= .
∂g x=0
¯ 1

Then we may recover φ′ since

∂Y1
φ′ (gn ) = (1; gn )
∂g

and use newton’s formula to generate new guesses


Dr. Johnson MATH65241
Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

I NITIAL VALUE P ROBLEM FOR g


Then the initial value problem for φ′ is given by

½ ¾ Ã ∂Y2
!
d ∂Y ∂g
= ,
dx ∂g −κ ∂Y ∂Y1
∂g − x ∂g
2

¯ µ ¶
∂Y ¯¯ 0
= .
∂g x=0
¯ 1

Then we may recover φ′ since

∂Y1
φ′ (gn ) = (1; gn )
∂g

and use newton’s formula to generate new guesses


Dr. Johnson MATH65241
Review
Correcting the guess
Boundary Value Problems
The Secant Method
Newtons Shooting Method
Newtons Method
Summary

T HE N EWTON -AUGMENTED S YSTEM

Simultaneously solve for Y and φ′ , setting

Y1 = y , Y2 = y ′ , Y3 = ∂y /∂g and Y4 = ∂y ′ /∂g

Resulting system looks something like

   
Y2 0
dY  −κY2 − xY1   g 
= , Y (x = 0) =  0 .
 
dx  Y4 
−κY4 − xY3 1

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

S UMMARY

Boundary value problems are commonplace in CFD and


mathematics in general
Newton’s Shooting method is one of the most common
methods for solving these types of problem
Newton’s method is quadratic, so should converge in 5-15
iterations
Start worrying if it doesn’t!

Dr. Johnson MATH65241


Review
Boundary Value Problems
Newtons Shooting Method
Summary

S UMMARY

Boundary value problems are commonplace in CFD and


mathematics in general
Newton’s Shooting method is one of the most common
methods for solving these types of problem
Newton’s method is quadratic, so should converge in 5-15
iterations
Start worrying if it doesn’t!

Dr. Johnson MATH65241

You might also like