Exercises — Boundary value problems — shooting method, finite difference
Two symbols recur; pin them down once so no line uses an undefined mark:
Level 1 — Recognition
L1.1 — IVP or BVP?
Classify each. State whether you'd march (IVP) or aim / puzzle-solve (BVP), and why.
- (a)
- (b)
Recall Solution
What decides it: count where the conditions live. Both at the same point ⇒ IVP (you know and there, so you can step forward). One at each end ⇒ BVP.
- (a) Both conditions at ⇒ IVP. You know the whole state at the start, so march forward with e.g. RK4.
- (b) at the left end, at the right end ⇒ two-point BVP. You cannot march (the starting slope is missing) — use shooting or finite difference.
L1.2 — Read off the stencil coefficients
For the linear BVP written in standard form , the finite-difference row at interior node is For with , write the three coefficients (lower, diagonal, upper) and the right-hand side at a node where .
Recall Solution
Identify so .
- lower
- diagonal
- upper
- RHS
Notice lower upper — the asymmetry is exactly the first-derivative (convection) term .
Level 2 — Application
L2.1 — One secant shooting step
A BVP has landing-miss function . Two shots gave Do one secant update to produce .
Recall Solution
Why secant: we can't cheaply differentiate (each evaluation is a full IVP solve), so we approximate by the straight line through the last two points and read off where that line crosses zero. Sign check: changed sign between and , so the root lies between and — and does. Good.
L2.2 — Linear shooting in exactly two shots
Solve the linear BVP by the linear-interpolation shortcut. Use shots and . Target .
Recall Solution
Why two shots suffice: for a linear ODE the landing value is a straight-line function of , so is a line — two points fix it exactly, no iteration.
- Shot : IVP , so .
- Shot : by linearity , so . Interpolate to hit : The exact starting slope of is . ✓ Recovered exactly in two shots.
L2.3 — FDM with one interior node
Solve with (so , one interior node ).
Recall Solution
Here . The single interior row (): With : . Boundary values known: . Move them to the right: True value ; error with just two intervals.
Level 3 — Analysis
L3.1 — Build and solve the tridiagonal system ()
Solve with (). Set up the tridiagonal system for and solve it. Compare to the truth.
Recall Solution
, . Each interior row: , i.e. diagonal , off-diagonals . Nodes . Boundaries , .
i=1:&\quad -2.0625\,y_1 + y_2 = -y_0 = 0,\\ i=2:&\quad y_1 -2.0625\,y_2 + y_3 = 0,\\ i=3:&\quad y_2 -2.0625\,y_3 = -y_4 = -1.1752. \end{aligned}$$ **Thomas / elimination** (forward sweep): - Row 1: $y_1=y_2/2.0625$. - Substitute into row 2: $\dfrac{y_2}{2.0625}-2.0625\,y_2+y_3=0\Rightarrow(-2.0625+0.4848)y_2+y_3=0\Rightarrow -1.5777\,y_2+y_3=0$, so $y_3=1.5777\,y_2$. - Substitute into row 3: $y_2-2.0625(1.5777\,y_2)=-1.1752\Rightarrow(1-3.2540)y_2=-1.1752\Rightarrow -2.2540\,y_2=-1.1752$. $$y_2=\frac{1.1752}{2.2540}=\mathbf{0.5214}.$$ Back-substitute: $y_1=0.5214/2.0625=\mathbf{0.2528}$, $y_3=1.5777(0.5214)=\mathbf{0.8226}$. **Compare:** $\sinh(0.5)=0.5211$. Error at the midpoint is now $\approx0.0003$ — versus $0.0012$ at $N=2$. Halving $h$ dropped the error by about $4\times$, confirming $O(h^2)$.
L3.2 — Why the naive secant can miss the bracket
Given and (same as L2.1), suppose instead the true is curved: actually. Explain in one line why one linear secant step is not the exact answer here, and what you must do.
Recall Solution
The secant step assumed was a straight line, so it predicted a root at . But the real : the function is curved (the ODE is nonlinear), so a line through two points cannot land the root in one shot. Fix: iterate — use the new pair … actually the sign-changing pair since — and take another secant step, repeating until . Exactness in two shots is a linear-only privilege.
Level 4 — Synthesis
L4.1 — FDM with a convection term
Set up and solve with (, one interior node ). Note the standard form is with .
Recall Solution
Coefficients at the single interior row:
- lower ,
- diagonal ,
- upper ,
- RHS .
Row: . Boundaries : The asymmetry lowerupper is the fingerprint of the convection term : information leans in the flow direction.
L4.2 — Order-of-accuracy audit
Two FDM runs of the same BVP give midpoint errors and . Estimate the observed order from Is the scheme performing as designed?
Recall Solution
Why : if , then halving multiplies error by ; the ratio , and of that recovers . The central-difference scheme is designed for , and the measured order is — it performs exactly as designed. (See Truncation error and order of accuracy.)
Level 5 — Mastery
L5.1 — Choose the method and justify
You must solve a stiff, nonlinear BVP on a long domain where a tiny slope error at grows exponentially. Which method — shooting or FDM — do you pick, and give two concrete reasons.
Recall Solution
Pick finite difference. Reasons:
- Stability on long/stiff domains: shooting marches an IVP forward, so a small error in the guessed slope is amplified exponentially across — the very definition of the difficulty here. FDM solves all nodes simultaneously, keeping errors local rather than propagating.
- No sensitive root-find: for a stiff problem is wildly steep, so secant/Newton on is ill-conditioned. FDM turns the problem into a (banded) algebraic system; for the nonlinear part you apply Newton to the whole system (Jacobian is tridiagonal-ish, still cheap via Tridiagonal systems — Thomas algorithm).
Trade-off acknowledged: FDM needs a nonlinear solve per Newton step, but its stability wins decisively when shooting blows up.
L5.2 — Full pipeline, one clean pass
Solve by shooting with RK-free reasoning: because the ODE is linear you may use the exact IVP solution . Shoot and , then linearly interpolate to the exact slope, and finally state from the recovered solution.
Recall Solution
Why : for , the unique IVP solution is (it satisfies the ODE, , and ).
- Shot : .
- Shot : .
- Target . Interpolate: With : , so — the exact midpoint value (shooting recovered the true solution because the ODE is linear).
Recall One-line self-test
Central second-difference stencil for ::: , accurate to . Landing-miss function in shooting ::: ; solve . Why linear BVP shoots exact in 2 tries ::: is a straight line, and 2 points fix a line. Observed order from two errors ::: .