FEYNMAN_KAC_EVALUATE Function
Computes the value of a Hermite quintic spline or the value of one of its derivatives. In particular, computes solutions to the Feynman-Kac PDE handled by the FEYNMAN_KAC Function.
Usage
result = FEYNMAN_KAC_EVALUATE (breakpoints, w, coef)
Input Parameters
breakpoints—Array of length m containing the breakpoints for the Hermite quintic spline interpolation, where m is the number of breakpoints for the Hermite quintic spline interpolation. The breakpoints must be in strictly increasing order. When applied to FEYNMAN_KAC, breakpoints is identical to array xgrid.
w—Vector of length nw containing the evaluation points for the spline, where nw is the length of the array containing the evaluation points of the spline. It is required that breakpoints(0) w(i) breakpoints(m–1) for i=0,...,nw – 1.
coef—Vector of length 3*m containing the coefficients of the Hermite quintic spline. When applied to FEYNMAN_KAC, this vector is one of the rows of output arrays y or y_prime related to the spline coefficients at time points t=tgrid(j), j=1,..., ntgrid.
Returned Value
result—An array of length nw containing the values of the Hermite quintic spline or one of its derivatives at the evaluation points in array w. If no values can be computed, then NULL is returned.
Input Keywords
Double—If present and nonzero, then double precision is used.
Deriv—Let d = Deriv and let H(w) be the given Hermite quintic spline. Then, this option produces the d-th derivative of H(w) at w, Hd(w). It is required that Deriv = 0,1,2 or 3. Default: Deriv = 0.
Discussion
The Hermite quintic spline interpolation is done over the composite interval [xmin, xmax], where breakpoints(i–1) = xi are given by (xmin = ) x1 < x2 < ... < xm ( = xmax).
The Hermite quintic spline function is constructed using three primary functions, defined by:
For each:
the spline is locally defined by:
where:
are the values of a given twice continuously differentiable function f and its first two derivatives at the breakpoints.
The approximating function H(x) is twice continuously differentiable on [xmin, xmax], whereas the third derivative is in general only continuous within the interior of the intervals [xi, xi+1]. From the local representation of H(x) it follows that:
The spline coefficients, yi, i = 1, ..., 3m, are stored as successive triplets in the array coef. For a given w [xmin, xmax], the FEYNMAN_KAC_EVALUATE function uses the information in coef together with the values of b0, b1, b2 and its derivatives at w to compute H(d) (w), d = 0, ..., 3 using the local representation on the particular subinterval containing w.
Example
Consider function f(x) = x5, a polynomial of degree 5, on the interval [–1, 1] with breakpoints ±1. Then, the end derivative values are:
and:
Since the Hermite quintic interpolates all polynomials up to degree 5 exactly, the spline interpolation on [–1, 1] must agree with the exact function value up to rounding errors.
 
PRO t_feynman_kac_evaluate
 
   nw = 7l 
   m = 2l 
   breakpoints  = [ -1.0, 1.0 ] 
   w = [ -0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 0.75 ] 
   coef = [ -1.0, 5.0, -20.0, 1.0, 5.0, 20.0 ]  
 
   result = FEYNMAN_KAC_EVALUATE(breakpoints, w, coef) 
 
   ;Print results.
   PRINT,"   x          F(x)      Interpolant  Error" 
   FOR i=0L, 6 DO $ 
     PRINT, STRING(w(i),Format="(f6.3)"),"   ", $
            STRING((w(i)^5.0),Format="(f10.3)"),"   ",$
            STRING(result(i),Format="(f10.3)"),"   ",$
            STRING(ABS((w(i)^5.0)-result(i)),Format="(f10.7)")
END
Output
x          F(x)      Interpolant  Error
-0.750       -0.237       -0.237    0.0000000
-0.500       -0.031       -0.031    0.0000000
-0.250       -0.001       -0.001    0.0000000
 0.000        0.000        0.000    0.0000000
 0.250        0.001        0.001    0.0000000
 0.500        0.031        0.031    0.0000000
 0.750        0.237        0.237    0.0000000