# Deriving the variance of G2++ Model

I'm studying G2++ Model in Brigo(2007)'s book.

The model constructed as follows,

$$r(t) = x(t) + y(t) + φ(t), \quad r(0) = r_0\\$$ with the dynamics of $$dx(t)$$ and $$dy(t)$$ described by: \begin{align} dx(t) &= -ax(t)dt + σdW_1(t), \quad x(0) = 0,\\ dy(t) &= -by(t)dt + ηdW_2(t),\quad y(0) = 0,\\ \end{align} and $$dW_1(t)\cdot dW_2(t) = ρdt$$.

Problem: When we calculate the variance, There is something that I cannot derive, which is described below:

$$∫^T_t(T-u)dx(u) = -a∫^T_t(T-u)x(u)du + σ∫^T_t(T-u)dW_1(u)$$ Then, $$∫^T_t(T-u)x(u)du = x(t)∫^T_t(T-u)e^{-a(u-t)}du + σ∫^T_t(T-u)∫^T_te^{-a(u-s)}dW_1(s)du.$$

I tried to derive the above integral, $$\int_t^T (T-u) x(u) \: du$$, but failed.

I want to know how to derive this equation. Especially, where in the world $$e^{-a(u-t)}$$ and $$σ∫^T_t(T-u)∫^T_te^{-a(u-s)}dW_1(s)du$$ came from, from the above equation?

## It comes from a direct application of the solution to $$dx_t$$

The solution for this SDE has already been derived by Gordon in this post where the only difference (in your specified SDE) is a sign-change in the drift-term. From the answer in the linked post, we observe that the solution to $$dx_t$$ in your case is given by:

$$x_T = x_t e^{-a(T-t)} + \sigma\int_{t}^T e^{-a(T-s)} \: dW_s.$$

The derivations specified in Gordons answer involve the integrating factor method which is also used to derive the solution for the well-known Vasicek one-factor short-rate model.

Let $$0\leq t < u < T$$. Now we can compute the integral in question:

\begin{align} \int_t^T (T-u) \cdot x_u \: du &= \int_t^T (T-u) \cdot \left[x_t e^{-a(u-t)} + \sigma\int_{t}^u e^{-a(u-s)} \: dW_s \right] \: du \\ &=x_t \int_t^T (T-u) e^{-a(u-t)} \: du + \sigma\int_t^T (T-u)\int_{t}^u e^{-a(u-s)} \: dW_s \: du. \end{align}

In conclusion, $$e^{-a(u-t)}$$ and $$\sigma\int_t^T (T-u)\int_{t}^u e^{-a(u-s)} \: dW_s \: du$$ comes from inserting the solution of $$dx_t$$ in the above integral. I hope this provide some insight.