Skip to article frontmatterSkip to article content

Shooting

One way to attack the TPBVP (10.1.1) is to adapt our IVP solving techniques from Chapter 6 to it. Those techniques work only when we know the entire initial state, but we can allow that state to vary in order to achieve the stated conditions.

This is the idea behind the shooting method. Imagine adjusting your aiming point and power to sink a basketball shot from the free-throw line. The way in which you miss—too long, flat trajectory, etc.—informs how you will adjust for your next attempt.

We can do much better than trial-and-error for the unknown part of the initial state. As usual, we can rewrite the ODE u(x)=ϕ(x,u,u)u''(x) = \phi(x,u,u') in first-order form as

y1=y2,y2=ϕ(x,y1,y2).\begin{split} y_1' &= y_2,\\ y_2' &= \phi(x,y_1,y_2). \end{split}

We turn this into an IVP by specifying y(a)=s1y(a)=s_1, y(a)=s2y'(a)=s_2, for a vector s\mathbf{s} to be determined by the boundary conditions. Define the residual function v(s)\mathbf{v}(\mathbf{s}) by

v1(s1,s2)=g1(y1(a),y2(a))=g1(s1,s2),v2(s1,s2)=g2(y1(b),y2(b)).\begin{split} v_1(s_1,s_2) &= g_1(y_1(a),y_2(a)) = g_1(s_1,s_2),\\ v_2(s_1,s_2) &= g_2(y_1(b),y_2(b)). \end{split}

The dependence of v2v_2 on s\mathbf{s} is indirect, through the solution of the IVP for y(x)\mathbf{y}(x). We now have a standard rootfinding problem that can be solved via the methods of Chapter 4.

10.2.1Implementation

Our implementation of shooting is given in Function 10.2.1. Note the structure: we use a rootfinding method that in turn relies on an IVP solver. This sort of arrangement is what makes us concerned with minimizing the number of objective function calls when rootfinding.

10.2.2Instability

The accuracy of the shooting method should be comparable to those of the component pieces, the rootfinder, and the IVP solver. However, the shooting method is unstable for some problems. An example illustrates the trouble.

The essence of the instability is that errors can grow exponentially away from the boundary at x=ax=a, where the state is arbitrarily being set (see Theorem 6.1.2). Using shooting, acceptable accuracy near x=bx=b therefore means requiring extraordinarily high accuracy near x=ax=a.

The instability of shooting can be circumvented by breaking the interval into smaller pieces and thus limiting the potential for error growth. However, we do not go into these details. Instead, the methods in the rest of this chapter treat both ends of the domain symmetrically and solve over the whole domain at once.

10.2.3Exercises

  1. ⌨ For each BVP in Exercise 10.1.2 , use Function 10.2.1 to compute the solution. Plot the solution and, separately, its error as functions of xx.

  2. ⌨ (Continuation of Exercise 10.1.4.) Consider the pendulum from Example 10.1.1 with g=L=1g=L=1. Suppose we want to release the pendulum from rest such that θ(5)=π/2\theta(5)=\pi/2. Find one solution that passes through θ=0\theta=0, and another solution that does not. Plot θ(t)\theta(t) for both cases together.

  3. ⌨ (Continuation of Exercise 10.1.5.) The stationary Allen–Cahn equation is

    ϵu=u3u,0x1,u(0)=1,u(1)=1.\epsilon u'' = u^3-u, \qquad 0 \le x \le 1, \qquad u(0)=-1, \quad u(1)=1.

    As ϵ0\epsilon\rightarrow 0, the solution tends toward a step function transition between -1 and 1. By symmetry, u(x)=u(1x)u'(x)=-u'(1-x).

    (a) Use Function 10.2.1 to solve the equation for ϵ=0.2\epsilon=0.2. Plot the solution and compute the numerical value of u(0)u(1)u'(0)-u'(1).

    (b) Repeat for ϵ=0.02\epsilon=0.02.

    (c) Repeat for ϵ=0.002\epsilon=0.002. You will receive multiple warning messages. Does the result look like a valid solution?

  4. ✍ Consider the linear TPBVP

    u=p(x)u+q(x)u+r(x),u(a)=0,u(b)=β.\begin{split} u'' &= p(x)u' + q(x)u + r(x),\\ u'(a) &= 0, \quad u(b)=\beta. \end{split}

    The shooting IVP uses the same ODE with initial data u(a)=s1u(a)=s_1, u(a)=s2u'(a)=s_2 to solve for a trial solution u(x)u(x). Define

    z(x)=us1.z(x) = \frac{\partial u}{\partial s_1}.

    By differentiating the IVP with respect to s1s_1, show that zz satisfies the IVP

    z=p(x)z+q(x)z,z(0)=1,  z(0)=0.z'' = p(x)z' + q(x)z, \quad z(0)=1, \; z'(0)=0.

    It follows that z(x)z(x) is independent of s1s_1, and therefore u(x)u(x) is a linear function of s1s_1 at each fixed xx. Use the same type of argument to show that u(x)u(x) is also a linear function of s2s_2, and explain why the residual function v\mathbf{v} in (10.2.2) is a linear function of s\mathbf{s}.