0
$\begingroup$

I am attempting to compute a numerical integral but I seem to not get the desired numerical stability. The integral in question is

num[c_, w_, prec_, rec_] := NIntegrate[
    SetPrecision[(y^((2*π)/11*(1/w - c) + 1)*E^-y)/(1-(y*11*w)/(2*π)),prec+1],
    {y,0,SetPrecision[(2*π)/11*1/w,prec+1],∞},
    WorkingPrecision->prec,
    MinRecursion->rec,
    Method-> "PrincipalValue"
]

for instance, if I evaluate

num[1, 0.1, 30, 3]=-145.67943817523307026331395062

where I get many error messages. But If I increase the working precision and the amount of minimal recursion I instead get

num[1, 0.1, 40, 4]=-10171.12237422827887743490803771360414548

which is totally different from the previous result. I have attempted going to higher values in the arguments prec and rec but I do not get any kind of stability. I think I am making a suboptimal use of NIntegrate. I have attempted reading the NIntegrate pages online, and I have attempted playing with AccuracyGoal and PrecisionGoal but I haven't really obtained any improvement. How should I improve my expression?

$\endgroup$
1
  • $\begingroup$ You call num it with exact input: num[1, 1/10, 40, 3]. Or, in the body of num, set the precision of the inputs to higher precision before submitting them to NIntegrate. $\endgroup$ Commented Jul 24, 2018 at 16:15

1 Answer 1

4
$\begingroup$

It is best to feed NIntegrate exact values, and allow NIntegrate to approximate as necessary. So:

num[c_, w_, opts:OptionsPattern[NIntegrate]] := NIntegrate[
    (y^((2*π)/11*(1/w-c)+1)*E^-y)/(1-(y*11*w)/(2*π)),
    {y, 0, 2 π/(11 w), ∞},
    Method -> "PrincipalValue",
    opts
];

For your sample input:

num[1, 1/10, WorkingPrecision -> 50]

-666.3617050447222935780196636918737896573472951093 + 0.*10^-47 I

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.