# Calibrating Hull White volatility on swap rate volatility

I'm strugling with the Hull-White 1F model. I'am trying to calibrate the volatility with the swap rate volatility. Here is the model I'am curently working on : \begin{align} dr_t = a(b-r_t)dt + \sigma_t^{HW} dW_t \end{align} Some one gave me a code that compute de HW1F volatility, with the swap rate volatility for a maturity $$T_i$$ and tenor $$\delta_i$$, by inversing the formulae bellow. From my understanding $$\sigma_t^{Mkt}$$ is the swap rate volatility at time $$t$$ \begin{align} \sigma^{Mkt}_{T_i} &= VF(T_i,\delta_i) \sqrt{\frac{1}{T_i}\int_0^{T_i}(\sigma^{HW}_s)^2e^{2as} ds} \\ \\ VF(T_i,\delta_i) &= \frac{S(T_i,\delta_i)}{a}\times \bigg[\frac{P(0,T_i)e^{-aT_i}-P(0,T_i+\delta_i)e^{-a(T_i+\delta_i)}}{P(0,T_i)-P(0,T_i+\delta_i)} - \sum_{j=1}^{\delta_i} \frac{P(0,T_i+j)e^{-a(T_i+j)}}{\sum_{k=1}^{\delta_i}P(0,T_i+k)} \bigg] \\ \\ S(T_i,\delta_i) &=\frac{P(0,T_i)-P(0,T_i+\delta_i)}{\sum_{k=1}^{\delta_i}P(0,T_i+k)} \end{align}

I have understand the principle but don't know where this formulae for $$\sigma^{Mkt}_t$$ came from. I have compute the volatility of the swap rate by using Itô formulae on $$S(T_0,T_n)$$ but came up with this formulae (might be some small mistake): $$\sigma_t^S = \sigma_t^{HW}\bigg[\frac{S(T_0,T_n)}{a}\bigg(e^{-a(T_n-t)}+\frac{e^{-a(T_0-t)}-e^{-a(T_n-t)}}{a}+\frac{\sum_{i=1}^nP(t,T_i)e^{-a(T_i-t)}}{\sum_{i=1}^nP(t,T_i)}\bigg)+\frac{P(t,T_n)}{\sum_{i=1}^nP(t,T_i)}\frac{e^{-a(T_0-t)}-e^{-a(T_n-t)}}{a}\bigg]$$

I have also compute the volatility for an approximation of the swap rate $$\tilde{S}(T_0,T_n) = \frac{P(0,T_n)}{\sum_{i=1}^nP(0,T_i)}\bigg[\frac{P(t,T_0)}{P(t,T_n)}-1\bigg]$$ (see calibration-hull-white page 6) and came up with this formulae

$$\sigma_t^{\tilde{S}} = \sigma^{HW}_t \frac{\tilde{S}(T_0,T_n)}{a} \bigg( \frac{P(0,T_n)e^{-a(T_0-t)}-P(0,T_n)e^{-a(T_n-t)}}{P(t,T_n)-P(t,T_n)} \bigg)$$

If any one know where the formulae for $$\sigma^{Mkt}_t$$ came from I would be pleased to know.

Every result is expressed using the risk free measure.