Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Solve a linear BVP by shooting

Use when: you have a LINEAR second-order BVP y''=p(x)y'+q(x)y+r(x), y(a)=\alpha, y(b)=\beta, with p,q,r continuous on [a,b]

Goal: the BVP's solution values at every grid point, accurate to whatever error RK4 itself carries -- reached by two ordinary IVP solves and one exact combination, no iteration

Taught in The Linear Shooting Method

  1. 1

    Write u_1=y,\ u_2=y', exactly Chapter 12 Section 11's own move: u_1'=u_2,\ u_2'=p(x)u_2+q(x)u_1+r(x).

    Example

    For y''=y+x (so p=0,\ q=1,\ r(x)=x) on [0,1]: u_1'=u_2,\ u_2'=u_1+x.

    Why: RK4, and every method Chapter 12 built, only ever knows how to advance a full state (u_1,u_2) one step. This is what makes "integrate forward" possible at all.

  2. 2

    Solve u_1(a)=\alpha,\ u_2(a)=0 forward to b with RK4, keeping the FULL r(x). Call the resulting solution values y_1(x).

    Example

    \alpha=1: RK4 with h=0.25 gives y_1(0)=1,\ y_1(0.25)\approx1.03402,\ y_1(0.5)\approx1.14870,\ y_1(0.75)\approx1.36696,\ y_1(1)\approx1.71821 (the exact solution of this particular IVP is y_1(x)=e^x-x, so this already matches e^1-1\approx1.71828 to 4 places).

    Why: this shot already satisfies the LEFT boundary condition exactly (u_1(a)=\alpha by construction), and solves the real equation. It just has no reason yet to land on \beta at b, since the slope 0 was arbitrary.

  3. 3

    Solve u_1(a)=0,\ u_2(a)=1 forward to b with RK4, this time with r(x) replaced by 0. Call the resulting values y_2(x).

    Example

    Homogeneous: u_2'=u_1 (no +x term). RK4 with h=0.25 gives y_2(0)=0,\ y_2(0.25)\approx0.25260,\ y_2(0.5)\approx0.52108,\ y_2(0.75)\approx0.82229,\ y_2(1)\approx1.17516 (exactly \sinh x here, so y_2(1)\approx\sinh1\approx1.17520).

    Why: zeroing r is what makes y_2 purely a "sensitivity" measurement. cy_2 can be added to y_1 without introducing a second, unwanted copy of r(x) into the combined solution.

  4. 4

    Compute c from the two numbers Steps 2-3 just produced, then report y(x)=y_1(x)+cy_2(x) at every grid point.

    Example

    c=\dfrac{1-1.71821}{1.17516}\approx-0.61116. Combined: y(0.25)\approx1.03402+(-0.61116)(0.25260)\approx0.87964, and by construction y(1)=1.71821+(-0.61116)(1.17516)\approx1.00000 -- exactly \beta.

    • y_2(b) is (numerically) zero — no unique blend exists. The matching homogeneous BVP has a solution that isn't just zero -- exactly what Section 1's theorem's q(x)>0 hypothesis rules out. In practice this rarely shows up as a clean division error. y_2(b) is usually only CLOSE to zero, not exactly zero (RK4's own round-off sitting where the true value is exactly 0). The visible symptom is c swelling to a huge number that swings wildly with the step count, rather than a clean failure.
    • y_2(b)\ne0 — c is well-defined and unique; proceed as above.

    Why: superposition (the Textbook tab's own derivation) guarantees y_1+cy_2 solves the equation and the left condition for every c. This step's algebra is the ONLY place the right condition ever gets imposed, and it does so exactly, not approximately.

Common mistakes

  • Trying this exact combine-and-done trick on a NONLINEAR equation. Superposition is what makes Step 4's single division exact, and superposition is a fact about LINEAR equations only. A nonlinear r (or nonlinear p,q depending on y) means y_1+cy_2 generally doesn't even solve the original equation for c\ne0,1. There is no algebraic c to solve for. Section 3's genuinely different method (Newton's method on the boundary miss, reusing Chapter 11's own recipe by name) is what a nonlinear BVP actually needs.
  • Forgetting to zero out r(x) in Step 3. Running the SAME nonhomogeneous equation for both shots breaks superposition: y_1+cy_2 would then solve y''=py'+qy+(1+c)r, not the original equation, for every c except c=0.
  • Swapping which shot gets which starting values. Step 2's slope is 0 (not \alpha twice), and Step 3's height is 0 (not \alpha again). Using \alpha for both shots' starting heights makes y_2 satisfy the SAME left condition as y_1, instead of measuring pure sensitivity to slope -- and the combination's left boundary condition breaks.
  • A sign slip in Step 4. Computing c=(y_1(b)-\beta)/y_2(b) instead of (\beta-y_1(b))/y_2(b) flips the correction's direction. It overshoots the target by twice the original miss, instead of closing the gap.