Fundamentals / Numerical mathematics / Numerical ordinary differential equations / Dynamics and numerical time integration

Solving a two-point boundary problem without guessing the start slope

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.

Sensitivity of shooting need not be sensitivity of the physical solution

Take \(y''=\kappa^2y\) on \(0\le x\le1\), with \(y(0)=1,\ y(1)=0\). The solution \(y=\sinh[\kappa(1-x)]/\sinh\kappa\) decays from the left. To shoot from the left, introduce unknown slope \(s\), yielding endpoint \(y(1)=\cosh\kappa+(s/\kappa)\sinh\kappa\). The correct slope is \(-\kappa\coth\kappa\) and its error is magnified by \(\sinh\kappa/\kappa\) at the far end. For \(\kappa=20\) this factor is about \(1.21\times10^7\). Even an initial slope accurate to \(10^{-10}\) can cause a far-end mismatch of order \(10^{-3}\). The mathematical boundary solution can remain well behaved while this particular representation suffers cancellation of large growing and decaying components.

A collocation boundary solver instead treats approximate states at many locations as simultaneous unknowns and enforces both boundary conditions directly. Write the equation as first-order system \(Y'=(v,\kappa^2 y)^T=F(x,Y)\), \(Y=(y,v)\). On each panel \([x_i,x_{i+1}]\) choose a cubic Hermite polynomial using unknown endpoint states and endpoint slopes fixed by \(F_i,F_{i+1}\). This already imposes the differential equation at both endpoints. Require the polynomial derivative to satisfy the ODE also at the midpoint. Matching yields two equations for each panel, with the boundary equations closing the overall algebraic system.

Derive a residual with only three right-side evaluations per panel

For panel width \(h\), Hermite interpolation at the midpoint gives

\[Y_m=(Y_i+Y_{i+1})/2+h(F_i-F_{i+1})/8.\]

Its derivative there is \(p'_m=3(Y_{i+1}-Y_i)/(2h)-(F_i+F_{i+1})/4\). Equating this with \(F_m=F(x_i+h/2,Y_m)\) yields

\[Y_{i+1}-Y_i-\frac h6(F_i+4F_m+F_{i+1})=0 .\]

This is a three-point Lobatto collocation relation, resembling Simpson quadrature with a midpoint state determined by the same cubic. Neighbouring panels share endpoint states and slopes, constructing a continuously differentiable piecewise approximation for a smooth right side. The nonlinear algebraic Jacobian has local block structure apart from boundary conditions and a few global unknowns. Dense finite differencing of the entire state would discard that structure and can dominate a large adaptive solve.

As a simple independent test take the scalar ODE \(y'=\lambda y\). With \(z=h\lambda\), substitution of \(Y_m\) yields a one-panel transfer \(R(z)=(1+z/2+z^2/12)/(1-z/2+z^2/12)\), agreeing with \(e^z\) through \(z^4\). The symmetry \(R(-z)=1/R(z)\) checks the derivation. At large negative \(z\), \(R(z)\to1\), so the local solution formula is not strongly damping for unresolved stiff modes. Global enforcement of boundary conditions and adaptive spatial resolution remain important: a stable algebraic solve need not resolve a very thin physical layer.

Interpret a continuous residual through a stability estimate

A collocation residual vanishes at the points where it was imposed, so checking only those values tests the nonlinear algebraic solve, not the differential approximation between points. Evaluate the continuous defect \(d(x)=p'(x)-F(x,p(x))\) at independent points or use its suitably weighted panel norm. Refine where the residual is large, especially where the solution changes rapidly, and enforce the boundary conditions independently. A mesh with many uniform far-interior points can inefficiently resolve a solution having a layer of thickness \(1/\kappa\) near a single wall.

For a scalar linear elliptic boundary problem \(-y''+\kappa^2 y=f\) with zero endpoint error, an approximation with smooth enough derivatives has error governed by \(-e''+\kappa^2e=r\). If \(\|r\|_\infty\le\epsilon\), a maximum-principle argument gives \(\|e\|_\infty\le\epsilon/\kappa^2\) for \(\kappa>0\): at an interior positive error maximum, \(-e''\ge0\), and similarly for the negative minimum. This bound links a differential residual in the same formulation to solution error under the stated boundary conditions. A residual in a differently scaled first-order system requires its own inverse stability estimate. Near a nonunique boundary solution an apparently tiny defect can correspond to a much larger state error.

Reconstruct the entire cubic boundary solution

The calculator solves the same linear collocation equations as the written panel derivation. For this constant matrix, its growing and shrinking eigendirections decouple and one panel applies the stated rational transfer to each. The numerical field shown between nodes is the actual cubic Hermite interpolant through those collocation states and their slopes. The reference is the independently evaluated hyperbolic-sine boundary solution. Increase the layer parameter at fixed panel count first and look just inside the left boundary. Both curves hit the imposed endpoints even on a visibly inadequate mesh.

Then double the number of panels. The displayed maximum difference is measured on 241 independent evaluation locations and is a sampled diagnostic, not a guaranteed global norm. For large layer parameter the shooting endpoint amplification can be enormous even while the collocation solution becomes accurate upon mesh refinement. At only a few cells across the layer the cubic may bend below zero. A solution satisfying the nonlinear algebraic conditions of the chosen discretisation need not preserve positivity of the continuum field at every point.

Tutorial · distinguish mesh, boundary and algebraic errors

Check a cubic against an exactly representable solution

Choose \(y'=3x^2,\ y(0)=0\) on a single unit panel. Verify the collocation residual using the candidate \(y=x^3\) and identify the midpoint state from endpoint data.

Work through the solution

Endpoint values are 0 and 1, slopes 0 and 3. The Hermite midpoint value is \(1/2-(3/8)=1/8\), equal to \((1/2)^3\). The midpoint slope is \(3/4\). Simpson's right side gives \([0+4(3/4)+3]/6=1\), equal to the endpoint difference. Here the entire state polynomial, not just its grid values, is exact. This manufactured case checks signs and factors before using the solver on a stiff boundary layer.

Quantify endpoint sensitivity for one shooting trial

At \(\kappa=10\), an independent integration has a starting-slope error \(2\times10^{-7}\). Estimate its endpoint error. Would measuring that endpoint residual accurately imply the underlying boundary problem is ill conditioned?

Work through the solution

The amplification is \(\sinh10/10\simeq1101.3\), yielding endpoint error \(2.20\times10^{-4}\). This exposes sensitivity of a one-way initial-value representation to the guessed slope. A boundary perturbation instead propagates through bounded functions \(\sinh[\kappa(1-x)]/\sinh\kappa\) and \(\sinh(\kappa x)/\sinh\kappa\). Its effect on interior \(y\) need not contain the huge shooting factor. Distinguish sensitivity of the original boundary data from cancellation in one numerical strategy.

Spot a false residual certificate

A computation checks only \(p'-F=0\) at each panel's two ends and midpoint and reports error below \(10^{-12}\). What evidence is still needed for a claimed \(10^{-6}\) physical solution tolerance?

Work through the solution

Those are exactly the collocation equations; their tiny residual tests the solved discrete system. Evaluate the defect off those nodes or estimate its norm by an independent quadrature, verify boundary mismatches, and relate these defects to solution error using a suitable stability bound or independent reference refinement. For the second-order model with \(\kappa=5\) and zero endpoint error a uniform residual below \(25\times10^{-6}\) in \(-p''+25p-f\) suffices for the stated magnitude bound. A reported first-order-system residual with different units cannot be inserted unchanged.

Further reading