Exact forward-curve fit in the Hull-White model (source code)

= Exact forward-curve fit in the Hull-White model
{title2=$\beta(t)=f_0'(t)+af_0(t)+\frac{\eta^2}{2a}(1-e^{-2at})$}

Let $f_0(t)$ be the initial <instantaneous forward rate> curve and choose $r_0=f_0(0)$. In the <Hull-White model>, take $\beta(t)=f_0'(t)+af_0(t)+\eta^2(1-e^{-2at})/(2a)$. To verify the fit, write $r_t=x_t+\phi(t)$ with $dx_t=-ax_tdt+\eta dW_t^Q$, $x_0=0$, and $\phi(t)=f_0(t)+\eta^2(1-e^{-at})^2/(2a^2)$. The <Gaussian> exponential formula gives $-\partial_T\log P(0,T)=\phi(T)-\eta^2(1-e^{-aT})^2/(2a^2)=f_0(T)$.