Click or drag to resize
FeynmanKac Class
Solves the generalized Feynman-Kac PDE.
Inheritance Hierarchy
SystemObject
  Imsl.MathFeynmanKac

Namespace: Imsl.Math
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax
[SerializableAttribute]
public class FeynmanKac

The FeynmanKac type exposes the following members.

Constructors
  NameDescription
Public methodFeynmanKac
Constructs a PDE solver to solve the Feynman-Kac PDE.
Top
Methods
  NameDescription
Public methodComputeCoefficients
Determines the coefficients of the Hermite quintic splines that represent an approximate solution for the Feynman-Kac PDE.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAbsoluteErrorTolerances
Returns absolute error tolerances.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetRelativeErrorTolerances
Returns relative error tolerances.
Public methodGetSplineCoefficients
Returns the coefficients of the Hermite quintic splines that represent an approximate solution of the Feynman-Kac PDE.
Public methodGetSplineCoefficientsPrime
Returns the first derivatives of the Hermite quintic spline coefficients that represent an approximate solution of the Feynman-Kac PDE.
Public methodGetSplineValue
Evaluates for time value 0 or a time value in tGrid the derivative of the Hermite quintic spline interpolant at evaluation points within the range of xGrid.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSetAbsoluteErrorTolerances(Double)
Sets the absolute error tolerances.
Public methodSetAbsoluteErrorTolerances(Double)
Sets the absolute error tolerances.
Public methodSetForcingTerm
Sets the user-supplied method that computes approximations to the forcing term \phi(x) and its derivative \partial \phi/\partial y used in the FeynmanKac PDE.
Public methodSetInitialData
Sets the user-supplied method for adjustment of initial data or as an opportunity for output during the integration steps.
Public methodSetRelativeErrorTolerances(Double)
Sets the relative error tolerances.
Public methodSetRelativeErrorTolerances(Double)
Sets the relative error tolerances.
Public methodSetTimeDependence
Sets the time dependence of the coefficients, boundary conditions and function \phi in the Feynman Kac equation.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyGaussLegendreDegree
The number of quadrature points used in the Gauss-Legendre quadrature formula.
Public propertyInitialStepsize
The starting step size for the integration.
Public propertyMaximumBDFOrder
The maximum order of the backward differentiation formulas (BDF).
Public propertyMaximumStepsize
The maximum internal step size used by the integrator.
Public propertyMaxSteps
The maximum number of internal steps allowed.
Public propertyMethod
The step control method used in the integration of the Feynman-Kac PDE.
Public propertyTimeBarrier
Sets or returns the barrier used for integration in the time direction.
Top
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.

See Also