Search code examples
matlabnormal-distributionintegral

Integral of normcdf in Matlab


I want to compute

$$e_0=r*K \int_{0}^{T} \exp{(-rt)} N\bigg( \frac{\ln{(B_t / S_0)}-e_2 t}{\sigma \sqrt{t}} \bigg)dt,$$ 

where

$$e_2=r-\frac{\sigma^2}{2},$$

and

$$N(x)=\int_{0}^{x} \frac{\exp{(-z^2/2)}}{\sqrt{2\pi}}dz$$

is the standard Normal cumulative distribution function or normcdf in Matlab.

Let r, K, T, B_t, S_0, and sigma are given. Here is my code:

K=90.054
r=0.075
sigma=0.2964203
T=1
Bt=66.0377
S0=206.67
syms t
e0=r*K*int(exp(-r*t)*normcdf((log(Bt/S0)-(r-(sigma^2)/2)*t)/(sigma*sqrt(t))),t,0,T)

However, when I run it, the result is still in variable t:

e0 =

(7604384265810425*int((erfc((9007199254740992*2^(1/2)*((279831188732951*t)/9007199254740992 + 642268209798613/562949953421312))/(5339833410500203*t^(1/2)))*exp(-(3*t)/40))/2, t, 0, 1))/1125899906842624

The first formula is the early exercise premium for American Put Option in Carr et al paper and thus the result should be numeric but the result I got is not. Any idea what did I do wrong?


Solution

  • I suppose your mistake is in using of int. You have to use integral function instead this way:

    K=90.054
    r=0.075
    sigma=0.2964203
    T=1
    Bt=66.0377
    S0=206.67
    syms t
    e0 = r*K*integral( @(t) normcdf((log(Bt/S0)-(r-(sigma^2)/2)*t)./(sigma*sqrt(t))),0,T)
    

    It returns single value:

    e0 =
       2.7014e-05