hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_pde_1d_blackscholes_means (d03ne)

Purpose

nag_pde_1d_blackscholes_means (d03ne) computes average values of a continuous function of time over the remaining life of an option. It is used together with nag_pde_1d_blackscholes_closed (d03nd) to value options with time-dependent parameters.

Syntax

[phiav, ifail] = d03ne(t0, tmat, td, phid, 'ntd', ntd)
[phiav, ifail] = nag_pde_1d_blackscholes_means(t0, tmat, td, phid, 'ntd', ntd)

Description

nag_pde_1d_blackscholes_means (d03ne) computes the quantities
φ(t0),   T ϕ̂ = 1/(T − t0) ∫ φ(ζ)dζ,   t0 φ =
( T )1/(T − t0) ∫ φ2(ζ)dζ t0 1 / 2
ϕ(t0),   ϕ^=1T-t0 t0Tϕ(ζ)dζ,   ϕ-= (1T-t0 t0Tϕ2(ζ)dζ) 1/2
from a given set of values phid of a continuous time-dependent function φ(t)ϕ(t) at a set of discrete points td, where t0t0 is the current time and TT is the maturity time. Thus ϕ̂ϕ^ and φϕ- are first and second order averages of φϕ over the remaining life of an option.
The function may be used in conjunction with nag_pde_1d_blackscholes_closed (d03nd) in order to value an option in the case where the risk-free interest rate rr, the continuous dividend qq, or the stock volatility σσ is time-dependent and is described by values at a set of discrete times (see Section [Use with ]). This is illustrated in Section [Example].

References

None.

Parameters

Compulsory Input Parameters

1:     t0 – double scalar
The current time t0t0.
Constraint: td(1)t0td(ntd)td1t0tdntd.
2:     tmat – double scalar
The maturity time TT.
Constraint: td(1)tmattd(ntd)td1tmattdntd.
3:     td(ntd) – double array
ntd, the dimension of the array, must satisfy the constraint ntd2ntd2.
The discrete times at which φϕ is specified.
Constraint: td(1) < td(2) < < td(ntd)td1<td2<<tdntd.
4:     phid(ntd) – double array
ntd, the dimension of the array, must satisfy the constraint ntd2ntd2.
phid(i)phidi must contain the value of φϕ at time td(i)tdi, for i = 1,2,,ntdi=1,2,,ntd.

Optional Input Parameters

1:     ntd – int64int32nag_int scalar
Default: The dimension of the arrays td, phid. (An error is raised if these dimensions are not equal.)
The number of discrete times at which φϕ is given.
Constraint: ntd2ntd2.

Input Parameters Omitted from the MATLAB Interface

work lwork

Output Parameters

1:     phiav(33) – double array
phiav(1)phiav1 contains the value of φϕ interpolated to t0t0, phiav(2)phiav2 contains the first-order average ϕ̂ϕ^ and phiav(3)phiav3 contains the second-order average φϕ-, where:
T ϕ̂ = 1/(T − t0) ∫ φ(ζ)dζ,   t0 φ =
( T )1/(T − t0) ∫ φ2(ζ)dζ t0 1 / 2
.
ϕ^=1T-t0 t0Tϕ(ζ)dζ ,   ϕ-= (1T-t0 t0Tϕ2(ζ)dζ) 1/2 .
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,t0 lies outside the range [td(1),td(ntd)td1,tdntd],
ortmat lies outside the range [td(1),td(ntd)td1,tdntd],
orntd < 2ntd<2,
ortd badly ordered,
orlwork < 9 × ntd + 24lwork<9×ntd+24.
  ifail = 2ifail=2
Unexpected failure in internal call to nag_interp_1d_spline (e01ba) or nag_fit_1dspline_eval (e02bb).

Accuracy

If φC4[t0,T]ϕC4[t0,T] then the error in the approximation of φ(t0)ϕ(t0) and ϕ̂ϕ^ is O(H4)O(H4), where H = maxi (T(i + 1)T(i))H=maxi(T(i+1)-T(i)), for i = 1,2,,ntd1i=1,2,,ntd-1. The approximation is exact for polynomials of degree up to 33.
The third quantity φϕ- is O(H2)O(H2), and exact for linear functions.

Further Comments

Timing

The time taken is proportional to ntd.

Use with nag_pde_1d_blackscholes_closed (d03nd)

Suppose you wish to evaluate the analytic solution of the Black–Scholes equation in the case when the risk-free interest rate rr is a known function of time, and is represented as a set of values at discrete times. A call to nag_pde_1d_blackscholes_means (d03ne) providing these values in phid produces an output array phiav suitable for use as the argument r in a subsequent call to nag_pde_1d_blackscholes_closed (d03nd).
Time-dependent values of the continuous dividend QQ and the volatility σσ may be handled in the same way.

Algorithmic Details

The ntd data points are fitted with a cubic B-spline using the function nag_interp_1d_spline (e01ba). Evaluation is then performed using nag_fit_1dspline_eval (e02bb), and the definite integrals are computed using direct integration of the cubic splines in each interval. The special case of T = toT=to is handled by interpolating φϕ at that point.

Example

function nag_pde_1d_blackscholes_means_example
t0 = 0;
tmat = 0.4166667;
td = [0;
     0.1;
     0.2;
     0.3;
     0.4;
     0.5];
phid = [0.1;
     0.11;
     0.12;
     0.13;
     0.14;
     0.15];
[phiav, ifail] = nag_pde_1d_blackscholes_means(t0, tmat, td, phid)
 

phiav =

    0.1000
    0.1208
    0.1214


ifail =

                    0


function d03ne_example
t0 = 0;
tmat = 0.4166667;
td = [0;
     0.1;
     0.2;
     0.3;
     0.4;
     0.5];
phid = [0.1;
     0.11;
     0.12;
     0.13;
     0.14;
     0.15];
[phiav, ifail] = d03ne(t0, tmat, td, phid)
 

phiav =

    0.1000
    0.1208
    0.1214


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013