Question 8.1: LINEAR BVP Solve the following BVP using the shooting method...
LINEAR BVP
Solve the following BVP using the shooting method.
\overset{..}{u}= 0.02u+ 1, u(0)=10, u(10)=100, \overset{..}{u}=\frac{d^{2}u }{dt^{2} }Learn more on how do we answer questions.
Since the ODE is second order, there are two state variables: x_1 = u, x_2 = \overset{.}{u} . The state-variable equations are then formed as
\left\{ \begin{matrix} \overset{.}{x_1}=x_2 \\ \overset{.}{x_2}= 0.02x_1+ 1 \end{matrix}, \begin{matrix} x_1(0)=10 \\ x_2(0)= ? \end{matrix}\right . (8.1)
This system could be solved numerically via RK4 but that would require initial conditions x_1(0) and x_2(0). Of these two, however, only x_1(0) = 10 is available. Note that there is a unique value of x_2(0) for which the above system yields the solution of the original BVP.
Strategy to Find x_2(0)
We first guess a value for x_2(0) and solve the system in Equation 8.1 using RK4. From the solution, we extract the first state variable x_1 which happens to be u. The value of this variable at the right end (namely, u(10)) is then compared with the boundary condition at that end, that is, u(10) = 100, which will serve as the target here. Next, we guess another value for x_2(0) and go through the process a second time. This way, for each guess of x_2(0), we find a value for u(10). Because the original ODE is linear, these values are linearly related as well. As a result, a linear interpolation of this data will provide the unique value for x_2(0) that will result in the correct solution. As a first guess, we arbitrarily choose x_2(0) = 10 so that Equation 8.1 becomes
> f = @(t,x)([x(2);0.02*x(1)+1]);
>> x0_first = [10;10];
>> t = linspace(0,10,20);
>> x_first = RK4System(f,t,x0_first);
>> u_10_first = x_first(1,end)
u_10_first =
217.5208
The result overshoots the target u(10) = 100. As a second guess, we pick x_2(0) = 0 so that Equation 8.1 becomes
\left\{ \begin{matrix} \overset{.}{x_1}=x_2 \\ \overset{.}{x_2}= 0.02x_1 + 1 \end{matrix}, \begin{matrix} x_1(0)=10 \\ \boxed{x_2(0)=10} \end{matrix} \right .
Note that f and t in our MATLAB code remain unchanged; only the initial state vector is modified.
>> x0_second = [10;0];
>> x_second = RK4System(f,t,x0_second);
>> u_10_second = x_second(1,end)
u_10_second =
80.6910
This time the result is below the target. In summary,
\begin{matrix} x_2(0)=10 & u(10)=217.5208 \\ x_2(0)=0 & u(10)=80.6910 \end{matrix} (8.2)
Linear interpolation of this data will lead to the correct value for x_2(0); see Figure 8.1. We will handle this by using linear Lagrange interpolation (Chapter 5), more specifically, the user-defined function LagrangeInterp:
>> yi = LagrangeInterp([u_10_first, u_10_second],[10, 0],100)
yi =
1.4112
Therefore, x_2(0) = 1.4112. Using this information in Equation 8.1, we have
\left\{ \begin{matrix} \overset{.}{x_1}=x_2 \\ \overset{.}{x_2}= 0.02x_1 + 1 \end{matrix}, \begin{matrix} x_1(0)=10 \\ x_2(0)=1.4112 \end{matrix} \right .
>> x0_final = [10;yi];
>> x_final = RK4System(f,t,x0_final);
>> x_final(1,end)
ans =
100.0000
The numerical solution u to the original BVP is obtained by extracting the first row of x_final, which contains 20 values of the first state variable x_1 = u. In order to generate a smooth solution trajectory, however, we should use at least 100 points, as opposed to the current 20 points. Similarly, the first row of x_first gives the solution corresponding to the first guess of x_2(0), and the first row of x_second gives the solution corresponding to the second guess of x_2(0).
This is summarized in the script below.
>> t = linspace(0,10); % 100 points
>> x_first = RK4System(f,t,x0_first);
>> u_first = x_first(1,:); % Solution based on the first guess
>> x_second = RK4System(f,t,x0_second);
>> u_second = x_second(1,:); % Solution based on the second guess
>> x_final = RK4System(f,t,x0_final);
>> u_final = x_final(1,:); % True solution
>> plot(t,u_first,t,u_second,t,u_final) % Figure 8.2
A linear BVP such as in Example 8.1 is relatively easy to solve using the shooting method because the data generated by two initial-value estimates can be interpolated linearly leading to the correct estimate. This, however, will not be enough in the case of a nonlinear BVP. One remedy would be to apply the shooting method three times and then use a quadratic interpolating polynomial to estimate the initial value. But it is not very likely that this approach would generate the correct solution, and further iterations would probably be required. A more viable option is the following: guess a value for the missing initial condition, solve the ensuing system, and find the value of the solution at the right end. This is either above the unused boundary condition (target) or below it. If it is above the target, we must pick a second guess that leads to a value below the target. If it is below the target, we must pick a second guess that leads to a value above the target. Subsequently, the bisection method (Chapter 3) is employed to find the unique value of the missing initial condition that will result in the true solution. Of course, the bisection method uses iterations that terminate when a tolerance is met. Therefore, the precision of the final outcome is directly dependent on the magnitude of the selected tolerance. The example that follows demonstrates the details of this approach.

