# Problem of stochastic differential equation (SDE) We assume that the price at time $$t$$ of a zero-coupon bond, with maturity $$u$$ and unit face value, is of the form \begin{align*} f(u-t, r_t, x_t) = E\left(e^{-\int_t^u r_s ds}\mid \mathcal{F}_t\right). \end{align*} Note that \begin{align*} M(t, r_t, x_t) &\equiv f(u-t, r_t, x_t) e^{-\int_0^t r_s ds} \\ &=E\left(e^{-\int_0^u r_s ds} \mid \mathcal{F}_t \right) \end{align*} is a martingale. Moreover, \begin{align*} dM &= - r f e^{-\int_0^t r_s ds}dt + e^{-\int_0^t r_s ds}df\\ &= e^{-\int_0^t r_s ds}\bigg[- r f dt + \frac{\partial f}{\partial t}dt + \frac{\partial f}{\partial r} dr_t + \frac{\partial f}{\partial x} dx_t\\ &\qquad\qquad\qquad + \frac{1}{2}\frac{\partial^2 f}{\partial r^2}d\langle r, r\rangle_t + \frac{1}{2}\frac{\partial^2 f}{\partial x^2}d\langle x, x\rangle_t + \frac{\partial^2 f}{\partial r\partial x}d\langle r, x\rangle_t \bigg]\\ &=e^{-\int_0^t r_s ds}\bigg[\frac{\partial f}{\partial t} - r f + \kappa_r(x-r)\frac{\partial f}{\partial r} + \kappa_x(\theta - x) \frac{\partial f}{\partial x} \\ &\qquad\qquad\qquad\qquad\qquad\qquad + \frac{1}{2}(\alpha + \beta r)\frac{\partial^2 f}{\partial r^2} + \frac{1}{2}\sigma^2 x \frac{\partial^2 f}{\partial x^2} \bigg]dt\\ & \quad +e^{-\int_0^t r_s ds}\left[ \sqrt{\alpha + \beta r_t}\frac{\partial f}{\partial r}dB_r(t) + \sigma \sqrt{x} \frac{\partial f}{\partial x}dB_x(t)\right]. \end{align*} Therefore, \begin{align*} \frac{\partial f}{\partial t} - r f + \kappa_r(x-r)\frac{\partial f}{\partial r} + \kappa_x(\theta - x) \frac{\partial f}{\partial x} + \frac{1}{2}(\alpha + \beta r)\frac{\partial^2 f}{\partial r^2} + \frac{1}{2}\sigma^2 x \frac{\partial^2 f}{\partial x^2}=0. \end{align*} In term of $$\tau = u-t$$, \begin{align*} -\frac{\partial f}{\partial \tau} - r f + \kappa_r(x-r)\frac{\partial f}{\partial r} + \kappa_x(\theta - x) \frac{\partial f}{\partial x} + \frac{1}{2}(\alpha + \beta r)\frac{\partial^2 f}{\partial r^2} + \frac{1}{2}\sigma^2 x \frac{\partial^2 f}{\partial x^2}=0. \end{align*} The remaining derivation of the Ricaati equation is then straightforward.