# Catastrophic loss of precision calculating Fox-H integral

I'm trying to numerically calculate the following Fox-H integral

$$1-e^{-100}\sqrt{\frac{x}{\pi}} \left(\frac{1}{2\pi j}\right)^2\\ \oint_{\mathcal{L}_1}\oint_{\mathcal{L}_2} \frac{\Gamma(z_1)\Gamma(z_2)\Gamma(1/2-z_1-z_2)\Gamma(1-z_1-z_2)}{\Gamma(1/2-z_1)\Gamma(3/2-z_1-z_2)}\left(-100 x\right)^{-z_1}x^{-z_2}dz_1 dz_2,$$

for $$x$$ going from $$10^{-7}$$ to about $$1000$$, where the contour $$\mathcal{L}_1$$ separates the poles of $$\Gamma(z_1)$$ from the poles of $$\Gamma(1/2-z_1-z_2)\Gamma(1-z_1-z_2)$$, and the contour $$\mathcal{L}_2$$ separates the poles of $$\Gamma(z_2)$$ from the poles of $$\Gamma(1/2-z_1-z_2)\Gamma(1-z_1-z_2)$$. Three types of contour are possible:

Reference for the images: https://dlmf.nist.gov/16.17

I'm using the NIntegrate function, and I tried all possible contours, but for values of $$x$$ above some threshold, like $$1086.66$$, the Mathematica returns the Catastrophic error. I already tried to change the Working Precision but have no better results. From the theory, this integral should be fine, resulting values from $$0$$ to $$1$$.

Do you guys have some clues about how can I solve this problem? The code I'm using is:

1 - Re[NIntegrate[
Exp[-100] \[Sqrt](x/\[Pi]) (1/(2 \[Pi] I))^2
(
(Gamma[z1] Gamma[z2] Gamma[1/2 - z1 - z2] Gamma[1 - z1 - z2])/
(Gamma[1/2 - z1] Gamma[3/2 - z1 - z2])
) (-100 x)^-z1 x^-z2,
{z2, 0.25 - I 20, 0.25 + I 20},
{z1, -20 - 5 I, 0.125 - 5 I, 0.125 + 5 I, -20 + 5 I}
]]


Edit: There were some typo errors in the Mathematica code, elegantly appointed in the comments. Edit 2: Update the values to achieve the error.

• Why are you using inexact numbers like 0.0025 instead of exact ones like 1/400? Commented Jun 30, 2022 at 14:47
• Sorry guys, I tried to clean the code at max to not distract your attention, but I made a mess. The $0.0025x$ term should be $-0.0025x$. @J.M.'sslightlylessbusy, I used these numbers aiming to easy your analysis. Sorry. Commented Jun 30, 2022 at 15:23
• I still get only a NIntegrate::slwcon warning no loss of precision error for x = 50, 100, 150, 500, 1000. I'm using V13.0.1, if that makes a difference. Commented Jun 30, 2022 at 15:59
• Please, forgive my bad attention. The error occurs when the $0.0025$ is changed to $100$, and for the value of $x=1086.66$. I will update the main question to these new values. Commented Jun 30, 2022 at 23:12

I'm not particularly familiar with this integral, but with the factor of Exp[-100], it's pretty small. I changed the 1 -... to 0 -... so we can see the value of the integral:

Block[{x = 108666/100},
0 - Re[NIntegrate[
Exp[-100] \[Sqrt](x/\[Pi]) (1/(2 \[Pi] I))^2 ((Gamma[z1] Gamma[
z2] Gamma[1/2 - z1 - z2] Gamma[1 - z1 - z2])/(Gamma[
1/2 - z1] Gamma[3/2 - z1 - z2])) (-1/400 x)^-z1 x^-z2,
{z2, 1/4 - I 20, 1/4 + I 20}, {z1, -20 - 5 I, 1/8 - 5 I,
1/8 + 5 I, -20 + 5 I}]]
]


NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

(*  -3.65721*10^-44  *)


Of course the main difference is using exact numbers for the integration path and x. (See @J.M.'s comment.)

The integration takes a long time, maybe more than a minute or minutes, certainly long enough to be worth a warning. I did something else for a while.

At machine precision, 1 minus the integral equals 1. (exactly). Without the Exp[-100] factor, the integral is a little more than -1.