Fundamentals / Numerical mathematics / Numerical ordinary differential equations

Why a boundary value problem can be easier than its shooting equation

A concentration decays across a slab, with concentrations known at both faces. Computing a solution from the first face alone can bring in an exponentially growing mode. Enforcing both faces together gives a different numerical problem with the same differential equation.

Distinguish the boundary map from the physical solution

Use a nondimensional interval \(0\le x\le1\) and write \(y''=\lambda^2y\), with \(y(0)=1\), \(y(1)=e^{-\lambda}\), \(\lambda>0\). The exact solution is \(e^{-\lambda x}\), a smooth layer of thickness approximately \(1/\lambda\). A shooting method prescribes a tentative slope \(s=y'(0)\), integrates the initial value problem, and adjusts \(s\) to meet the second boundary. The exact initial-value solution is \(\cosh(\lambda x)+(s/\lambda)\sinh(\lambda x)\). The correct slope is \(-\lambda\). The small right boundary is recovered by subtracting two large nearly equal terms.

Perturb the exact slope by \(\delta s\). Superposition gives the resulting error everywhere without a second initial-value solve:

\[\delta y(x)=\frac{\delta s}{\lambda}\sinh(\lambda x),\]
\[\frac{d\,y(1)}{ds}=\frac{\sinh\lambda}{\lambda}.\]

At \(\lambda=20\) the right-end amplification is \(1.21\times10^7\). A slope error as small as \(10^{-12}\) gives about \(1.21\times10^{-5}\) endpoint error, while the target value is just \(2.06\times10^{-9}\). The actual boundary problem is much less sensitive to changes in prescribed concentrations. Its basis functions for arbitrary face values are \(\sinh[\lambda(1-x)]/\sinh\lambda\) and \(\sinh(\lambda x)/\sinh\lambda\), each bounded by one. A stable physical boundary problem can be paired with an ill-conditioned forward initial-value calculation. The particular derivative above measures sensitivity of the forward shooting evaluation.

Enforce the equation at the interior nodes

Take \(N\) equal intervals with \(h=1/N\). The centred second difference of any smooth exact solution equals \(y''(x_j)+h^2y^{(4)}(x_j)/12+O(h^4)\), by Taylor expansion about \(x_j\). Set that second difference equal to \(\lambda^2Y_j\). Incorporate the known boundary data \(Y_0,Y_N\) into the first and last right-hand sides. The interior equations are

\[-Y_{j-1}+[2+(\lambda h)^2]Y_j-Y_{j+1}=0,\]
\[j=1,\ldots,N-1.\]

Each row now couples neighbouring nodes and no row asks for a missing starting slope. The diagonal exceeds the sum of the off-diagonal magnitudes for \(\lambda>0\). Eliminate the lower diagonal from left to right and substitute back from the right. Both work and storage grow linearly with \(N\). This finite-difference collocation approximates the differential equation at grid points. It still needs enough points inside the layer. The grid parameter \(\lambda h\) measures its resolution.

At \(\lambda=5\) and just two intervals there is one unknown midpoint. Its equation gives \(Y_1=(1+e^{-5})/(2+2.5^2)=0.1220\), while the exact midpoint is

\[e^{-2.5}=0.08208.\]

Both boundary values are satisfied exactly. Their residual alone cannot reveal the interior error. As \(h\) is halved at fixed \(\lambda\), a well-resolved smooth solution exhibits second-order convergence.

Compare errors with a common physical target

The graph plots logarithmic absolute errors against position. The shooting curve isolates propagation of a controlled absolute initial slope perturbation of \(10^{-12}\), using the analytical propagation factor to avoid cancellation in the demonstration. The collocation curve solves the tridiagonal system numerically and compares each node to \(e^{-\lambda x_j}\). Values below \(10^{-16}\) are plotted at a floor. These are different sources of error. Increasing \(N\) improves collocation truncation error but cannot repair an error in the supplied shooting slope. At low \(\lambda\) the perturbed shooting solution may be much more accurate. Increase \(\lambda\) while keeping \(N\) fixed and identify where each method struggles.

Tutorial on a boundary tolerance

At \(\lambda=15\), require the error caused by the shooting slope alone to be less than \(10^{-8}\) at the right face. What absolute accuracy is needed in \(s\)? Give an independent accuracy check for the collocation solution.

Work through the solution

Rearrangement gives

\[|\delta s|<15\times10^{-8}/\sinh15=9.18\times10^{-14}.\]

For collocation solve on a nested mesh with half the spacing and compare shared nodes. In the second-order regime the refined error is roughly one third of the coarse-to-fine difference there. Check that the estimate stabilises under another refinement and that the fine mesh resolves \(1/\lambda\).

Further reading · Driscoll and Braun, finite-difference collocation for linear boundary problems · Driscoll and Braun, shooting and instability.

Study the full derivation

Solving a two-point boundary problem without guessing the start slope · Dynamics and numerical time integration

When endpoint conditions act on different sides of an interval, shooting can amplify a tiny initial error. Construct a cubic collocation system, test its continuous differential residual and quantify which boundary-value solution the residual actually certifies.