I have the following ODE
$$ u'' = -(1 + e^u), u(0)=0, u(1)=1$$
with boundary conditions and $t \in (0,1)$. I want to solve this ODE using the shooting method. First,we convert this to a system of equations. Let $y_1=u, y_2=u'$ and so
$$ \begin{bmatrix} y_1' \\ y_2' \end{bmatrix} = \begin{bmatrix} y_2 \\ -(1+e^{y_1}) \end{bmatrix}, \; \; \; \; \begin{bmatrix} y_1(0) \\ y_2(0) \end{bmatrix} = \begin{bmatrix} 0 \\ u'(0) \end{bmatrix}$$
Im trying to understand how the shooting method works and hopefully code it in matlab. So,I have to make a guess for $u'(0)$ and then use a ODE solve to get $u(1)=1$. Is this how we procced with this method?
Best Answer
As you did, you first write the system as
$\begin{bmatrix} y_1' \\ y_2' \end{bmatrix} = \begin{bmatrix} y_2 \\ -(1+e^{y_1}) \end{bmatrix}, \; \; \; \; \begin{bmatrix} y_1(0) \\ y_2(0) \end{bmatrix} = \begin{bmatrix} 0 \\ u'(0) \end{bmatrix}$
in order to use a standard numerical method for ODEs.
So, the goal is to give the right value to $u'(0)$ in order to have $u(1)=1$. In your system, you have to guess the value of $y_2(0)$.
Of course you could do it by hand, but you can actually write a bisection method in order to find the correct value for the first derivative. The function you have to set to zero is, actually, $F=y_1(N)-1$.
So, assume to use a numerical method for solving your ODE, say explicit Euler (EE) (for sake of simplicity):
The following (runable) MatLab code computes the right value for $y_2(0)$, which is approximately $2.4592$.
The correct numerical solution is the following