Message Boards Message Boards

0
|
7363 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Compilation for computational speed-up

Posted 10 years ago

Hi,

I have tried "compile" for the following function below but no computational speed-up is noticed. Is there a special way to "compile" and achieve the speed-up for this particular function.

CallPrice[T_Real, K_Real, S0_Real, R_Real, 
  V0_Real, \[Lambda]_Real, \[Mu]_Real, \[Sigma]1_Real, \[Theta]_Real, \
\[Kappa]_Real, \[Sigma]2_Real, \[Rho]_Real] :=

 (S0*(0.5 + (1.0/\[Pi])*
        NIntegrate[
         Re[(1/(I*\[Phi]))
          E^(-I*\[Phi]*Log[K])*( 
            E^((I*\[Phi]*R*
                T - \[Theta]/\[Sigma]2^2*(2.0*
                  Log[1.0 - ((\[Xi]1 - \[Kappa] + (1.0 + 
                    I*\[Phi])*\[Rho]*\[Sigma]2)*(1 - E^(-\[Xi]1*T)))/(
                    2.0*\[Xi]1)]) - \[Theta]/\[Sigma]2^2*(\[Xi]1 - \
\[Kappa] + (1.0 + I*\[Phi])*\[Rho]*\[Sigma]2)*T + 
               I*\[Phi]*Log[S0] + \[Lambda]*(1.0 + \[Mu])*
                T*((1.0 + \[Mu])^(I*\[Phi])*E^(
                   0.5*I*\[Phi]*(1.0 + I*\[Phi]) \[Sigma]1^2) - 
                  1.0) - \[Lambda]*I*\[Phi]*\[Mu]*T + (
                I*\[Phi]*(I*\[Phi] + 1.0)*(1.0 - E^(-\[Xi]1*T)))/(
                2.0*\[Xi]1 - (\[Xi]1 - \[Kappa] + (1.0 + 
                    I*\[Phi])*\[Rho]*\[Sigma]2)*(1.0 - 
                    E^(-\[Xi]1*T)))*
                V0) /. \[Xi]1 -> (Sqrt[(\[Kappa] - (1 + 
                    I*\[Phi])*\[Rho]*\[Sigma]2)^2 - 
                 I*\[Phi]*(I*\[Phi] + 1)*\[Sigma]2^2])))], {\[Phi], 
          0.0, \[Infinity]}]) - 
    K*E^(-R*
      T)*(0.5 + (1.0/\[Pi])*
        NIntegrate[
         Re[(1/(I*\[Phi]))
          E^(-I*\[Phi]*
            Log[K])*(E^((I*\[Phi]*R*
                T - \[Theta]/\[Sigma]2^2*(2.0*
                  Log[1.0 - ((\[Xi]2 - \[Kappa] + (I*\[Phi])*\[Rho]*\
\[Sigma]2)*(1.0 - E^(-\[Xi]2*T)))/(
                    2.0*\[Xi]2)]) - \[Theta]/\[Sigma]2^2*(\[Xi]2 - \
\[Kappa] + I*\[Phi]*\[Rho]*\[Sigma]2)*T + 
               I*\[Phi]*Log[S0] + \[Lambda]*
                T*((1.0 + \[Mu])^(I*\[Phi])*E^(
                   0.5*I*\[Phi]*(I*\[Phi] - 1.0) \[Sigma]1^2) - 
                  1.0) - \[Lambda]*I*\[Phi]*\[Mu]*T + (
                I*\[Phi]*(I*\[Phi] - 1.0)*(1 - E^(-\[Xi]2*T)))/(
                2.0*\[Xi]2 - (\[Xi]2 - \[Kappa] + 
                    I*\[Phi]*\[Rho]*\[Sigma]2)*(1.0 - E^(-\[Xi]2*T)))*
                V0) /. \[Xi]2 -> (Sqrt[(\[Kappa] - 
                    I*\[Phi]*\[Rho]*\[Sigma]2)^2 - 
                 I*\[Phi]*(I*\[Phi] - 1)*\[Sigma]2^2])))], {\[Phi], 
          0.0, \[Infinity]}])) // N;
T = 1.0;
K = 0.9;
S0 = 1.0;
R = 0.0;
V0 = 0.1;
\[Lambda] = 0.0;
\[Mu] = 0.0;
\[Sigma]1 = 0.0;
\[Theta] = 0.25;
\[Kappa] = 1.0;
\[Sigma]2 = 0.5;

\[Rho] = 0.5;

CallPrice[T, K, S0, R, V0, \[Lambda], \[Mu], \[Sigma]1, \[Theta], \
\[Kappa], \[Sigma]2, \[Rho]]
POSTED BY: Nabeel Butt

enter image description here

POSTED BY: Simon Cadrin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract