Step-doubling error estimation (source code)

= Step-doubling error estimation
{title2=$\widehat e_{\rm fine}=(Y_{h/2,h/2}-Y_h)/(2^p-1)$}

For an order-$p$ one-step method with leading numerical error $Ch^{p+1}$, two half steps have leading error $Ch^{p+1}/2^p$. The displayed difference estimates exact minus the finer approximation. Adding it implements <Richardson extrapolation>. It requires a common starting value, the smooth local expansion, and accuracy of all algebraic solves; it can fail across a nonsmooth event.