Feynman-Kac formula, named after Richard Feynman and Mark Kac, establishes a link between parabolic partial differential equations (PDEs) and stochastic processes. Suppose \(S(t)\) follows the stochastic process

\(dS(t)=\mu(t,\omega)dt+\sigma(t,\omega)dW(t)\)

and if \(V\) is defined as

\(V(t,S(t))=E^Q_t[H(T,S(T))]\)

then \(V\) satisfies

\(\frac{\partial V}{\partial t}+\mu\frac{\partial V}{\partial S}+\frac{1}{2}\sigma^2\frac{\partial^2 V}{\partial S^2}=0\), \(V(T,S(T))=H(T,S(T))\).

The theorem can be stated the other way around. Thus, Feynman-Kac formula could be applied to interest rate models, for example, under Hull-White model, zero coupon bond price \(P(t,T)\) satisfies

\(\frac{\partial P}{\partial t}+(\theta(t)-ar(t))\frac{\partial P}{\partial r}+\frac{1}{2}\sigma^2\frac{\partial^2 P}{\partial r^2}=r(t)P\), \(P(T,T)=1\)

we can deduce the analytic solution for \(P(t,T)\) by using the theorem described above.

Another application of Feynman-Kac formula in finance is discretization: explicit schemes and implicit schemes. For explicit schemes, we use such discretization method:

\(\left(\frac{\partial S}{\partial r}\right)*{i,j}\approx\frac{S*{i,j+1}-S_{i,j-1}}{2\Delta r}\),

\(\left(\frac{\partial^2 S}{\partial r^2}\right)*{i,j}\approx\frac{S*{i,j+1}-2S_{i,j}+S_{i,j-1}}{(\Delta r)^2}\),

\(\left(\frac{\partial S}{\partial t}\right)*{i,j}\approx\frac{S*{i,j}-S_{i-1,j}}{\Delta t}\)

substitute these into the PDE then the equation could be written as

\(S_{i-1,j}=A_{i,j}S_{i,j+1}+B_{i,j}S_{i,j}+C_{i,j}S_{i,j-1}\)

This kind of scheme has equivalence to trinomial tree valuation

\(S_{i-1,j}=p_uS_{i,j+1}+p_mS_{i,j}+p_dS_{i,j-1}-r_j\Delta tS_{i,j}\)

and setting the size of rate step \(\Delta r=\sigma(3\Delta t)^{1/2}\) leads to the most efficient approximation, under which the scheme becomes 4th order w.r.t. to \(r\).

While applying explicit finite difference methods, boundary conditions have very little effect. We need to have

\(\sigma^2_{i,j}\frac{\Delta t}{(\Delta r)^2}\leq\frac{1}{2}\)

hold cause otherwise small numerical errors can grow uncontrollably.

For implicit scheme, we discretize the PDE like this:

\(\left(\frac{\partial S}{\partial r}\right)*{i,j}\approx\frac{S*{i-1,j+1}-S_{i-1,j-1}}{2\Delta r}\),

\(\left(\frac{\partial^2 S}{\partial r^2}\right)*{i,j}\approx\frac{S*{i-1,j+1}-2S_{i-1,j}+S_{i-1,j-1}}{(\Delta r)^2}\),

\(\left(\frac{\partial S}{\partial t}\right)*{i,j}\approx\frac{S*{i,j}-S_{i-1,j}}{\Delta t}\)

then Feynman-Kac formula becomes

\(A_{i,j}S_{i-1,j+1}+B_{i,j}S_{i-1,j}+C_{i,j}S_{i-1,j-1}=S_{i,j}\)

It has a relationship to trinomial trees:

\((1-r_j\Delta t)S_{i,j}\approx p_uS_{i-1,j+1}+p_mS_{i-1,j}+p_dS_{i-1,j-1}\)

Since we use time \(i-1\) value to calculate \(S_{i,j}\), then if we want to do pricing backward, we need to solve a system of linear equations. Also, we need to care about the boundary conditions where we usually set \(r_0=0\) and \(r_M=r_\infty\) which is large enough. Hence, implicit scheme is slightly more difficult to implement than the explicit one. However, it is always stable and convergent. In practice, one method that is used very often is called Crank-Nicolson method which combines both explicit scheme and implicit scheme:

\(\left(\frac{\partial S}{\partial r}\right)*{i,j}\approx(1-\theta)\frac{S*{i,j+1}-S_{i,j-1}}{2\Delta r}+\theta \frac{S_{i-1,j+1}-S_{i-1,j-1}}{2\Delta r}\),

\(\left(\frac{\partial^2 S}{\partial r^2}\right)*{i,j}\approx(1-\theta)\frac{S*{i,j+1}-2S_{i,j}+S_{i,j-1}}{(\Delta r)^2}+\theta \frac{S_{i-1,j+1}-2S_{i-1,j}+S_{i-1,j-1}}{(\Delta r)^2}\),

\(\left(\frac{\partial S}{\partial t}\right)*{i,j}\approx(1-\theta)\frac{S*{i,j}-S_{i-1,j}}{\Delta t}+\theta \frac{S_{i,j}-S_{i-1,j}}{\Delta t}\)

Although Crank-Nicolson method is a little bit harder to implement than both the explicit and implicit scheme, it is as stable as the fully implicit method and is the second-order accurate w.r.t. time step which is better than explicit and implicit schemes.