Survival under regime switching
The expansion in $\varepsilon = 1/\lambda$, one term at a time.
The hazard rate mean-reverts at speed $\kappa = 2$ towards a level that switches between $\theta_1 = 0.15$ and $\theta_2 = 0.02$, with variance $\sigma_1^2 = 0.0555$ in the first regime and $\sigma_2^2 = 0.0055$ in the second. Order 0 is Vasicek's bond price with the averaged parameters. Order $n$ adds every term through $\varepsilon^n$: the outer series in $E = 1 - e^{-\kappa t}$ and the initial layer, which enters the regime-dependent bracket from order 2, as the transient $\tfrac14\varepsilon^2\tilde g'(0)\,e^{-2\lambda t}$. Its permanent contribution to the common log amplitude starts at order 4.
The upper chart shows the partial sums settling onto the numerical solution. The lower chart shows the absolute error of each partial sum on a log scale; the notches are where an error changes sign.
At the default $\lambda \approx 20$ each added term cuts the error by a factor of 10 to 20, down to about $10^{-12}$. The gain per term shrinks as switching slows: near $\lambda = 3$ it is only a factor of two or three, and the errors of successive orders alternate in sign, because the expansion is asymptotic rather than convergent. A term that failed to shrink as $\lambda$ grows would refute the expansion.
Near $t = 0$ the outer series alone would miss the layer transient, which is of order $\varepsilon^2$ over the first $1/(2\lambda)$ years; the partial sums include it, so each order starts at $1$. At the slider's minimum, $\lambda = 0.5$, the terms grow instead of shrinking: at $t = 1/16$ the orders 0 to 6 give 0.9927, 0.985, 0.977, 0.955, 0.897, 0.720 and 0.127 against a numerical solution of 0.9924, which is an asymptotic series used outside its range.
The numerical solution integrates the two-state linear ODE by fourth-order Runge–Kutta in your browser. The partial sums are computed from the recursion in all_orders.py, ported to JavaScript, and agree with the Python to $10^{-16}$. The numerical solution agrees with a 30-digit solution to about $10^{-12}$.
Certificate: verify_all_orders.py.