Message Boards Message Boards

0
|
1614 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Speed up Nintegrate for certain range of function's input

Posted 1 year ago

This is a part of my code

SE[x_, g_, c_] := 1/x NIntegrate[Rationalize[(
6 (10^-10 Sqrt[xP])^2 10^-11 (10^-7 Sqrt[(
   10^-38 c^2 xP + (10^-10 Sqrt[xP])/x)/(
   0.1` + 10^-38  c^2)])^3)/((10^-38 c^2 xP + (10^-10 Sqrt[xP])/
  x)^4/(0.1` + 10^-38  c^2)^4)], {xP, 1.`/g, 10^12}, 
PrecisionGoal -> 10.`, MinRecursion -> 3.`, MaxRecursion -> 15.`, 
Method -> {Automatic, "SymbolicProcessing" -> 0.`}]

For which this part

Sqrt[NIntegrate[(SE[x, 10^-23, 10^14])^2, {x, 10^-5, 
 1}]] // AbsoluteTiming

Taking too much time for my range of values for c->(10^9-10^15) but when I decrease the value of c the integral becomes faster. I have to make the integral atleast 10-100 times more faster

POSTED BY: John Wick
6 Replies

If Mathematica doesn't do it automatically, you can easily work out the point where the HeavisideTheta discontinuity lies, and the conditions under which that point is to the left, within, or to the right of the integration interval [1/g, 10^12].

POSTED BY: Gianluca Gorni
Posted 1 year ago

But I can't assume {g = 10^-23, c = 10^14} as a general solution since it will give the results for a point but in principle g,c have to vary for a range of values g=>(10^-2,10^-24) and c=>(10^10-10^15)

POSTED BY: John Wick

When integrating, I would recommend UnitStep instead of HeavisideTheta. This gives me a symbolic output:

With[{g = 10^-23, c = 10^14}, 
 Integrate[
  Simplify[(6 (10^-10 Sqrt[
           xP])^2 10^-11 (10^-7 Sqrt[(10^-38 c^2 xP + (10^-10 Sqrt[
                  xP])/x)/(1/10 + 
              10^-38 c^2)])^3)/((10^-38 c^2 xP + (10^-10 Sqrt[xP])/
           x)^4/(1/10 + 10^-38 c^2)^4)*
    UnitStep[10^-38 c^2 xP + (10^-10 Sqrt[xP])/x - 1/g]],
  {xP, 1/g, 10^12},
  Assumptions -> And[c > 0, x > 0, xP > 0, g > 0]]]
POSTED BY: Gianluca Gorni
Posted 1 year ago

Also, one important reason I have not gone for symbolic integration is that my integrand in its complete form

SE[x_, g_, c_] = 
 1/x Integrate[
   Simplify[(6 (10^-10 Sqrt[
            xP])^2 10^-11 (10^-7 Sqrt[(10^-38 c^2 xP + (10^-10 Sqrt[
                   xP])/x)/(1/10 + 
               10^-38 c^2)])^3)/((10^-38 c^2 xP + (10^-10 Sqrt[xP])/
            x)^4/(1/10 + 10^-38 c^2)^4)*
     HeavisideTheta[10^-38 c^2 xP + (10^-10 Sqrt[xP])/x - 1/g]], {xP, 
    1/g, 10^12}, Assumptions -> And[c > 0, x > 0, xP > 0, g > 0]]

contains a HeavisideTheta function

POSTED BY: John Wick
Posted 1 year ago

Symbolical evolution seems more faster but it gives a solution for g>10^-12, but my g can be low as 10^-24

POSTED BY: John Wick

Have you tried pre-calculating the first integral symbolically?

SE[x_, g_, c_] = 
 1/x Integrate[
   Simplify[(6 (10^-10 Sqrt[
           xP])^2 10^-11 (10^-7 Sqrt[(10^-38 c^2 xP + (10^-10 Sqrt[
                  xP])/x)/(1/10 + 
              10^-38 c^2)])^3)/((10^-38 c^2 xP + (10^-10 Sqrt[xP])/
           x)^4/(1/10 + 10^-38 c^2)^4)], {xP, 1/g, 10^12}, 
   Assumptions -> And[c > 0, x > 0, xP > 0, g > 0]]
POSTED BY: Gianluca Gorni
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