Shooting Method Tutorial
Shooting Method Tutorial
Gary Parker
July 9, 2006
Now the right value of s is the one that satisfies (1c), or thus
R(s) = f (1, s) −1 = 0 (14)
new
For any guess s, a better guess s is given as
R(s) f (1, s) −1
s new
=s− =s−
dR ∂f (15)
ds ∂s x =1
But in order to implement this we need to know ∂f/∂s at x = 1. So to do this we
specify the variational parameters F(x,s) and G(x,s), where
∂f
F≡
∂s
(16a,b)
∂f
G=
∂s
(Now in principle we should write ∂f/∂x in equation (11a) etc., because f is also a
function of s, but for simplicity we will retain the notation df/dx and dg/dx.) We
now take the derivatives of (11a,b,c,d) with respect to x to specify the variational
problem:
dF
= G( x, s)
dx
dG
= −F( x, s) (17a,b,c,d)
dx
F(0, s) = 0
G(0, s) =1
Now we can also solve the variational problem using the Euler step method;
Fn +1 = Fn + Gn ∆x
(18a,b)
G n +1 = G n −Fn ∆x
F1 = 0
G1 = 1
(18c,d)
Thus (14) becomes
f N +1 − 1
snew = s = s − (19)
FN +1
Try it out. The code is easy to implement in, for example, Matlab or Visual Basic
for Applications in Excel. Since (1) has the analytical solution (2), it is easy to
verify that the correct value of s is
df d sin( x ) 1
s= = = = 1.188 (20)
dx x =0 dx sin( 1) sin( 1)
Try initial guesses of s that are different from 1.188 and see how many steps are
needed for convergence. The shooting method often fails if the initial guess of s
is too far from the correct value, so often one must play around to find first
guesses that lead to convergence.