from a given set of values PHID of a continuous time-dependent function at a set of discrete points TD, where is the current time and is the maturity time. Thus and are first and second order averages of over the remaining life of an option.
The routine may be used in conjunction with D03NDF in order to value an option in the case where the risk-free interest rate , the continuous dividend , or the stock volatility is time-dependent and is described by values at a set of discrete times (see Section 8.2). This is illustrated in Section 9.
1: T0 – REAL (KIND=nag_wp)Input
On entry: the current time .
2: TMAT – REAL (KIND=nag_wp)Input
On entry: the maturity time .
3: NTD – INTEGERInput
On entry: the number of discrete times at which is given.
On entry: must contain the value of at time , for .
6: PHIAV() – REAL (KIND=nag_wp) arrayOutput
On exit: contains the value of interpolated to , contains the first-order average and contains the second-order average , where:
7: WORK(LWORK) – REAL (KIND=nag_wp) arrayWorkspace
8: LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which D03NEF is called.
9: IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to , . If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value is recommended. If the output of error messages is undesirable, then the value is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is . When the value is used it is essential to test the value of IFAIL on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6 Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by X04AAF).
Suppose you wish to evaluate the analytic solution of the Black–Scholes equation in the case when the risk-free interest rate is a known function of time, and is represented as a set of values at discrete times. A call to D03NEF providing these values in PHID produces an output array PHIAV suitable for use as the argument R in a subsequent call to D03NDF.
Time-dependent values of the continuous dividend and the volatility may be handled in the same way.
8.3 Algorithmic Details
The NTD data points are fitted with a cubic B-spline using the routine E01BAF. Evaluation is then performed using E02BBF, and the definite integrals are computed using direct integration of the cubic splines in each interval. The special case of is handled by interpolating at that point.
This example demonstrates the use of the routine in conjunction with D03NDF to solve the Black–Scholes equation for valuation of a -month American call option on a non-dividend-paying stock with an exercise price of $50. The risk-free interest rate varies linearly with time and the stock volatility has a quadratic variation. Since these functions are integrated exactly by D03NEF the solution of the Black–Scholes equation by D03NDF is also exact.
The option is valued at a range of times and stock prices.