Message Boards Message Boards

0
|
4889 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Run this integral code faster?

Posted 7 years ago

Define source[gamma,t]:

source[gamma, t] = gamma^(-2.2)(t0/t)^((1.2)/2)(1 - gamma2/31.2910^5t^(1/2)*(1/t0^(3/2) - 1/t^(3/2)))^(0.2)

Define F[x]:

    F[x_] = Piecewise[{{x((2^(2/3)Gamma[2/3]* HypergeometricPFQ[{-(1/3)}, {-(2/3), 2/3}, x^2/4])/x^(2/3) 
+ (Pi(-320 + (812^(1/3)x^(8/3) HypergeometricPFQ[{4/3}, {7/3, 8/3}, x^2/4])/ Gamma[-(1/3)]))/(320*Sqrt[3])), 
Between[x, {10^-7, 10}]}, {0, x < 10^-7 || x > 10}}]

Define gammamin[gamma]:

all1 = Solve[ gamma == 1/(21.2910^5((t/t0)^(3/2) - 1)/(3t) + Sqrt[t/t0]/10), t] pos1 = all1[[3]] gammamin[gamma_] = t /. pos1

Define infinity[gamma]:

all2 =Solve[gamma == (3t)/(2(b*((t/t1)^(3/2) - 1))), t] pos2 = all2[[1]] infinity[gamma_] = t /. pos2

Then I set t0 is a constant 10^6.

Then I use code as below to do integral

LogLogPlot[{NIntegrate[ 3.710^(-22)source[gamma, t]* F[3.7910^(-9)nu/((gamma^2))], {gamma, 12.719, Infinity}, {t, t0, infinity[gamma]}] + 
NIntegrate[ 3.710^(-22)source[gamma, t]* F[3.7910^(-9)nu/((gamma^2))], {gamma, 10, 12.719}, {t, t0, 2t0}] +
 NIntegrate[ 3.710^(-22)source[gamma, t] F[3.7910^(-9)nu/((gamma^2))], {gamma, 4.54455, 10}, {t, gammamin[gamma], 2t0}}, {nu, 1.4510^8, 2.5*10^10}]

The code is ok and I can get the result from my code. But the whole process takes more than 4 hours. Is there any way which can improve my code? I expect to get the result within half hour. Basically it's just two numerical integral, I really don't understand why it takes very long time.

POSTED BY: Yonggang Luo
4 Replies
Posted 7 years ago

What is the value which must be assigned to b

all2 = Solve[gamma == (3 t)/(2 (b*((t/t1)^(3/2) - 1))), t]
POSTED BY: Bill Simpson
Posted 7 years ago

b=1.29*10^5, t1=10^6.

POSTED BY: Yonggang Luo
Posted 7 years ago

Define source[gamma,t]:

source[gamma_, t_] = 
 gamma^(-2.2)*(t0/t)^((1.2)/2)*(1 - 
    gamma*2/3*1.29*10^5*t^(1/2)*(1/t0^(3/2) - 1/t^(3/2)))^(0.2)

Define F[x]:

F[x_] = Piecewise[{{x*((2^(2/3)*Gamma[2/3]*
          HypergeometricPFQ[{-(1/3)}, {-(2/3), 2/3}, x^2/4])/x^(2/3) + 
           (Pi*(-320 + (81*2^(1/3)*x^(8/3)*
               HypergeometricPFQ[{4/3}, {7/3, 8/3}, x^2/4])/
             Gamma[-(1/3)]))/(320*Sqrt[3])), 
    Between[x, {10^-7, 10}]}, {0, x < 10^-7 || x > 10}}]

Define gammamin[gamma]:

all1 = Solve[
  gamma == 1/(2*1.29*10^5*((t/t0)^(3/2) - 1)/(3*t) + Sqrt[t/t0]/10), t]
pos1 = all1[[3]]
gammamin[gamma_] = t /. pos1

Define infinity[gamma]:

all2 =Solve[gamma == (3*t)/(2*(b*((t/t1)^(3/2) - 1))), t]
pos2 = all2[[1]]
infinity[gamma_] = t /. pos2

Then I set t0 is a constant 10^6.

Then I use code as below to do integral

LogLogPlot[{NIntegrate[ 3.710^(-22)source[gamma, t]* F[3.7910^(-9)nu/((gamma^2))], {gamma, 12.719, Infinity}, {t, t0, infinity[gamma]}] 
+ NIntegrate[ 3.710^(-22)source[gamma, t]* F[3.7910^(-9)nu/((gamma^2))], {gamma, 10, 12.719}, {t, t0, 2*t0}] 
+ NIntegrate[ 3.710^(-22)source[gamma, t]* F[3.7910^(-9)nu/((gamma^2))], {gamma, 4.54455, 10}, {t, gammamin[gamma], 2t0}}, {nu, 1.4510^8, 2.5*10^10}]

This code is very slow and inefficiency. Dose anyone can speed it up for me? Thank you!

POSTED BY: Yonggang Luo

Please give all your code, properly indent in, and there might be hope someone can speed it up for you.

POSTED BY: Sander Huisman
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