Solves the generalized Feynman-Kac PDE.

Namespace: Imsl.Math
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.0.0

Syntax

C#
[SerializableAttribute]
public class FeynmanKac
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class FeynmanKac
Visual C++
[SerializableAttribute]
public ref class FeynmanKac

Remarks

Class FeynmanKac solves the generalized Feynman-Kac PDE on a rectangular grid with boundary conditions using a finite element Galerkin method. The generalized Feynman-Kac differential equation has the form


            f_t +\mu(x,t) f_x +\frac{\sigma^2(x,t)}{2}f_{xx}-\kappa(x,t)f=\phi(f,x,t),
where the initial data satisfies f(x,T)=p(x). The derivatives are f_t=\frac{\partial{f}}{\partial{t}}, etc. Method ComputeCoefficients uses a finite element Galerkin method over the rectangle

            [x_{\min},x_{\max}] \times [\bar{T},T]
in (x,t) to compute the approximate solution. The interval [x_{\min},x_{\max}] is decomposed with a grid

            (x_{\min}=)x_1 \lt x_2 \lt \ldots \lt x_m(=x_{\max})\,.
On each subinterval the solution is represented by

            f(x,t) = f_ib_0(z)+f_{i+1}b_0(1-z)+h_i f_i' b_1(z)-h_i f_{i+1}' b_1(1-z)+
            h_i^2f_i''b_2(z)+h_i^2f_{i+1}''b_2(1-z).
The values

            f_i,f_i',f_i'',f_{i+1},f_{i+1}',f_{i+1}''
are time-dependent coefficients associated with each interval. The basis functions b_0,b_1,b_2 are given for

            x \in [x_i, x_{i+1}], \, h_i=x_{i+1}-x_i, \, z=(x-x_i)/h_i, z \in [0,1],
by

            b_0(z)=-6z^5+15z^4-10z^3+1=(1-z)^3(6z^2+3z+1),

            b_1(z)=-3z^5+8z^4-6z^3+z=(1-z)^3z(3z+1),

            b_2(z)=\frac{1}{2}(-z^5+3z^4-3z^3+z^2)=\frac{1}{2}(1-z)^3z^2.
By adding the piece-wise definitions the unknown solution function may be arranged as the series

            f(x,t) = \sum_{i=1}^{3m}y_i\beta_i(x), \; x \in [x_{\min},x_{\max}],
where the time-dependent coefficients are defined by re-labeling:

            y_{3i-2} = f_i,\, y_{3i-1} = f_i',\, y_{3i} = f_i'',\, i=1,\ldots,m.
The Galerkin principle is then applied. Using the provided initial and boundary conditions leads to an Index 1 differential-algebraic equation for the coefficients y_i, \, i=1,\ldots,3m.

This system is integrated using the variable order, variable step algorithm DDASLX noted in Hanson, R. and Krogh, F. (2008), Solving Constrained Differential-Algebraic Systems Using Projections. Solution values and their time derivatives at a grid preceding time T, expressed in units of time remaining, are given back by methods GetSplineCoefficients and GetSplineCoefficientsPrime, respectively. For further details of deriving and solving the system see Hanson, R. (2008), Integrating Feynman-Kac Equations Using Hermite Quintic Finite Elements. To evaluate f or its partials f_x, f_{xx}, f_{xxx}, f_t, f_{tx}, f_{txx}, f_{txxx} at any time point in the grid, use method GetSplineValue.

One useful application of the FeynmanKac class is financial analytics. This is illustrated in Example 2, which solves a diffusion model for call options which, in the special case \alpha = 2 reduces to the Black-Scholes (BS) model. Another useful application for the FeynmanKac class is the calculation of the Greeks, i.e. various derivatives of Feynman-Kac solutions applicable to, e.g., the pricing of options and related financial derivatives. In Example 5, the FeynmanKac class is used to calculate eleven of the Greeks for the same diffusion model introduced in Example 2 in the special BS case. These Greeks are also calculated using the BS closed form Greek equations (see http://en.wikipedia.org/wiki/The_Greeks). The Feynman-Kac and BS solutions are output and compared. Example 5 illustrates that the FeynmanKac class can be used to explore the Greeks for a much wider class of financial models than can BS.

Inheritance Hierarchy

System..::.Object
Imsl.Math..::.FeynmanKac

See Also