# nonlinear ODE shooting method using Newton

$y'' = 2y'-2y+2$
with $y(0)=1$ and $y(\frac{\pi}{2})=2$

I have to solve this using shooting method (Newton).

First thing I need to do it replace the right boundary problem with a specified slope at left boundary. I am told in the question that $y'(0) = 0$. Then the note tells me to use Newton's method for $y(\frac{\pi}{2};0)-2$ ? I am quite confused as to how to proceed and do this question. I cannot find any similar examples.

Thanks.

I'll write out the idea of the shooting method in your problem, although the idea is pretty general. Any solution to $y''=2y'-2y+2,y(0)=1,y(\pi/2)=2$ is also a solution to $y''=2y'-2y+2,y(0)=1,y'(0)=s$ for some unknown number $s$. Denoting the solutions to this family of IVPs by $y(x;s)$, we can define $F(s)=y(\pi/2;s)$. $F$ can be approximately numerically evaluated using an IVP solver.

We then want to solve the equation $F(s)=2$, which can be done using a numerical method for 1D root finding, such as bisection, Newton's method, or the secant method. Newton's method is not easy to implement in this situation, because it is not easy to compute $F'(s)$. But bisection and the secant method are both easy to implement in this situation.

• I agree that finding $F'(s)$ can be troublesome sometimes and there can be issues wrt stability / accuracy that makes it more complicated. However in this case I think Newton's method is the easiest to apply. We pick a small $h$ and compute both $F(s+h)$ and $F(s)$ and then approximate $F'(s) \approx \frac{F(s+h)-F(s)}{h}$. I tested it for $h = 10^{-5}$ and it finds the correct $s \approx 0.2$ (to $\sim h \sim 10^{-5}$ accuracy) in 1-2 steps for practically all $s_0$. – Winther Jan 22 '17 at 21:03
• @Winther That is basically a secant method. (The only difference is that in the secant method $h$ is also variable.) – Ian Jan 22 '17 at 21:09
• Fair point. I would still call it Newton's method, but you are obviously right that it's technically the secant method as we don't have an analytical expression for $F'(s)$. Anyway thanks for clearing it up. – Winther Jan 22 '17 at 21:15

Since this is a second-order dynamical system you will need to compute the derivative at one or both boundaries. You will also need to rewrite the dynamics (differential equations) in first-order form.

The rough outline for a shooting method proceeds as follows:

1) guess the derivative (slope) at the start point

2) use an explicit integration scheme such as Euler' method, mid-point method, or 4th-order Runge-Kutta to simulate the system from the initial condition to the final one.

3) check the difference between the final value that your simulation achieved and the target final value. This is known as a defect.

4) update your initial guess for the slope and then loop back to (2). Typically this guess is updated by using the chain rule to compute a gradient estimate that describes how a change in the initial guess for the slope will affect the value at the final point. Google "Russ Tedrake, MIT, underactuated robotics, multiple shooting gradients" and you should be able to find a video lecture that explains how to compute these gradients. You can also approximate them numerically, which is easier in many cases but slower and less accurate.

If you are not constrained to using shooting methods then you might also look up direct collocation methods, which I have found to be superior to shooting methods for many problems. It also might be worth looking up multiple shooting, a simple extension of the algorithm that I described above, which has significantly better convergence properties.