# Need help understanding shooting method

I'm trying to solve a set of differential equations that all depend on a parameter, $\kappa$. I can use the system of ODEs to reduce the four equations into one second order differential equation, for $y[x;\kappa]$. I've seen certain tricks to solving equations such as $d^2y/dx^2 = \kappa y[x]$.But I can not put my equation in that form. So the real trick is,how do I solve for $\kappa$ and $y[x]$ with only one equation.

My idea is as follows, I will look at the limit of the differential equation at $x =0$ (ODE1), and the limit of it at the other boundary $x = a$, (ODE2).Then I will technically have two differential equations. Then I pick a value for $\kappa$, from some physics that I know about the problem, i.e. set $\kappa = constant$. After this I solve ODE1 in the domain $x= 0$ to $x0$ and I solve ODE2 in the domain $x0$ to $x=a$. Finally I check whether or not the function $y[x]$ matches at the point $x0$. If it doesn't match I try this again until I find the value of $\kappa$ that makes the two sides match up.

Its the last part that I don't know how to implement? How do I use the mis-match to get me a new value of $\kappa$? I've read several sources about this idea, under "shooting method", but I really don't get how I should update the values of $\kappa$.

Thanks for reading, and any help is much appreciated.

1st Edit Hey Marty Cohen,

Thanks for the response. I was thinking about using the secant method, but my confusion lies in this: The nth root for the secant method is given by

$x_n = x_{n-1} - f(x_{n-1})* \frac{x_{n-2} - x_{n-1}}{f(x_{n-2}) - f(x_{n-1})}$,

so for me this boils down to

$\kappa_3 = \kappa_{2} - f(\kappa_{2})* \frac{\kappa_{2} - \kappa_{1}}{f(\kappa_{2}) - f(\kappa_{1})}$,

and I'm ok with this so far. I just need to pick two values of $\kappa$ to get the third. But what I don't get is this function $f(\kappa$). Even if I integrate both ODE1 and ODE2 and check the mismatch at a fixed point ($x0$), so something like

$\kappa_3 = \kappa_{2} - f(x0,\kappa_{2})* \frac{\kappa_{2} - \kappa_{1}}{f(x0,\kappa_{2}) - f(x0,\kappa_{1})}$,

the question is : Which f do I use, is it $f1$ which is the solution of ODE1 or $f2$ which is the solution of ODE2. It was because of the mistmatch in functions that I thought I would need to use something like Newton-Raphson where I would have to build derivatives.

Sorry it took me so long to get to the question. Also this problem is related to bit of research I'm doing, so no worries about what my prof wants. I'm just doing this for me, and I really need to understand it, in order to move the research forward.

Thanks again.

-
$f(\kappa)$ could be the difference between the solutions of ODE1 and ODE2 at $x_0$. – Robert Israel Aug 21 '12 at 4:43
@Robert, Thanks. Ok, that does make sense. Not to be rude, but how sure are you,since you are saying it "could be the difference". – tau1777 Aug 21 '12 at 5:19
Completely sure. "Could be" as in, one possible $f(\kappa)$ is the difference ... Other choices could be made, but I would think this would be the default unless there's some particular reason to do it differently. – Robert Israel Aug 21 '12 at 5:57
@RobertIsrael, Thanks indeed. Sorry about the added confusion there, I just had to make sure before I implement this tomorrow. Thanks. – tau1777 Aug 21 '12 at 7:00

Another way is just to use the secant method (look it up!) for finding a root of $f(x) = 0$. This is essentially a discretized version of Newton's method for finding a root of a function, but has the advantage of not needing the derivative of $f$ and the disadvantage of needing more function evaluations.

In your case, $f(x)$ is the numerically integrated value of the ODE at the end of the interval minus the desired value, where $x$ is the value of the parameter you want to find. Choose two values for $x$ and, if they are reasonably close to the correct value, the secant method will choose successive values that will often (but not always) converge to the desired value.

You can also choose a sequence of values for $x$ and start the secant method when two consecutive values of $f(x)$ have different signs.

An advantage of this is that it only needs the original ODE and does not need to have it differentiated. A disadvantage is that your instructor may want you to learn about the shooting method as you described it.

-
For safety, one might want to implement some form of bracketing along with the secant method. – J. M. Aug 21 '12 at 3:31
Hey Marty Cohen, – tau1777 Aug 21 '12 at 3:54
Hey. Ho. Hi. Hoo. Haa. – marty cohen Aug 21 '12 at 4:04
Sorry meant to write more, couldn't fit it all, but I put it in a edit to my original post. – tau1777 Aug 21 '12 at 4:11
@J.M. What exactly is bracketing? I don't think I've come across that in my readings. A link would suffice, thanks. – tau1777 Aug 21 '12 at 5:49

It might help if we could see your differential equation. But let's say you have the equation $y'' + f(y, y', \kappa) = 0$ with initial conditions $y(0) = y_0$, $y'(0) = y'_0$. y differentiating the differential equation with respect to $\kappa$ you get another second order differential equation for $\dfrac{\partial y}{\partial \kappa}$ in terms of $y$ and $y'$. At the same time as you solve the DE for $y$, you can solve that second equation. Use the values of $y$ and $\dfrac{\partial y}{\partial \kappa}$ at $x = x_0$ and solve the linear approximation to choose the next $\kappa$.

For example, say you want to solve $y'' + \kappa y' + y^2 = 0$, $y(0)=0$, $y'(0) = 1$, $y(5) = 0$. Then differentiating with respect to $\kappa$, if $w = \dfrac{\partial y}{\partial \kappa}$ we get $w'' + y' + \kappa w' + 2 y w = 0$, $w(0) = w'(0) = 0$. Taking an inital guess $\kappa = 1$, the numerical solution of the system \eqalign{y'' &+ y' + y^2 = 0\cr w'' & + y' + \kappa w' + 2 y w = 0\cr y(0) &= 0,\ y'(0) = 1,\ w(0) = 0,\ w'(0) = 0\cr} has $y(5) = .126717388689442, w(5) = .321379976308191$. The linear approximation is $y(5, \kappa) \approx .126717388689442 + .321379976308191 (\kappa - 1)$, so we take $\kappa = 1 - .126717388689442 /.321379976308191 = .605708513190240$.

-
Thanks Robert, this cools pretty interesting, I'm still trying to figure out how to implement this with my system, since I've never thought of, or since this method before. – tau1777 Aug 21 '12 at 4:11