# How could I make this numerical integral precise?

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?

• 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. – Henrik Schumacher Jul 24 '18 at 16:15

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
];


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