# why do these two Meijer G functions not cancel each other?

I encountered such expressions in Mathematica

MeijerG[{{ }, {1, c + 1/2}}, {{0, c, c, c}, { }}, 1] +
MeijerG[{{1}, {c + 1/2}},    {{c, c, c},    {0}}, 1]

which in the notation of Wiki is given by the sum of the following Mellin–Barnes integrals $$G_{2,4}^{4,0}\left(\left.\begin{array}{c} 1, c+\frac12\\ c,c,c,0\end{array} \right| 1\right) = \frac{1}{2\pi i} \int_C\frac{\Gamma\left(-s\right)\Gamma\left(c-s\right)^3}{\Gamma\left(1-s\right)\Gamma\left(c+\frac12-s\right)} ds = - \frac{1}{2\pi i} \int_C \frac{ \Gamma\left(c-s\right)^3}{s\Gamma\left(c+\frac12 -s\right)}ds$$ and $$G_{2,4}^{3,1}\left(\left.\begin{array}{c} 1, c+\frac12\\ c,c,c,0\end{array} \right| 1\right) = \frac{1}{2\pi i} \int_C \frac{\Gamma\left(s\right) \Gamma\left(c-s\right)^3}{\Gamma\left(1+s \right)\Gamma\left(c+\frac12 -s\right)}ds = \frac{1}{2\pi i} \int_C \frac{ \Gamma\left(c-s\right)^3}{s\Gamma\left(c+\frac12 -s\right)}ds$$ and both contours $$C$$ should be chosen to be the one beginning and ending on $$+\infty$$. Therefore the two Meijer G functions should be exactly opposite to each other and the sum is identically zero, right?

However, Mathematica yields very different result, by which I mean numerical evaluation of the function with some value of $$c$$ plugged in. I am wondering what is causing the problem?

Actually, the contours $$C$$ in the two integrals are different.

By definition, $$C$$ goes from $$+\infty$$ through an clockwise path return to $$+\infty$$, encircling all poles of $$\prod_{j=1}^m\Gamma(b_j-s)$$ (each pole exactly once) and none pole of $$\prod_{j=1}^n\Gamma(1-a_j-s)$$. In this case, the integral-contours of $$\textrm{G}^{4, 0}_{2, 4}\Big({1,c+\frac12\atop c,c,c,1}\Big|1\Big)$$ encircles poles:

$$c, c+1, c+2,\dotsc, c+k,\dotsc,$$

and poles:

$$0, -1, -2, \dotsc, -k, \dotsc,$$

must be outside the contours. Similar for $$\textrm{G}^{3, 1}_{2, 4}\Big({1,c+\frac12\atop c,c,c,1}\Big|1\Big)$$, we needs the contour encircles poles:

$$0, 1, 2, \dotsc, k,\dotsc,\quad \mathrm{and}\quad c, c+1,c+2,\dotsc,c+k,\dotsc,$$

As you have found, $$1,2,\dotsc,n,\dotsc$$ are actually normal points of the integrand, so the contour can "deform" over these points. However, $$0$$ remains to be a pole, so the contour can not cross over it, which makes the expression obtain a non-zero value.

Thus, for any $$c\neq0,-1,-2,\dotsc,-k,\dotsc$$ (by definition, they're not allowed), the sum of this two Meijer functions is:

$$-\operatorname{Res}\frac{[\Gamma(c-s)]^3}{s\,\Gamma\big(c+\frac12-s\big)}\Bigg|_{s=0} =-\dfrac{[\Gamma(c)]^3}{\Gamma\big(\frac12+c\big)}.$$

Using Mathematica, we can check our answer:

Table[-MeijerG[{{},{1,c+1/2}},{{0,c,c,c},{}},1,-1]
-MeijerG[{{1},{c+1/2}},{{c,c,c},{0}},1,-1]
+Gamma[c]^3/Gamma[1/2+c]//N,
{c, SetPrecision[RandomReal[{1,2}, 10]
+I RandomReal[{1, 2}, 10], 10]}
]//Column

Notice that in Mathematica

-MeijerG[{{__}, {__}}, {{__}, {__}}, _, -1]

is corresponding to the definition in Wikipedia(Bateman & Erdelyi).

Edit You may notice that when $$c=-k-\frac12$$, $$s=0$$ will also be a normal point. Fortunately, the residue here as we have shown will be zero as we expected.

• Just to add to this excellent answer, there is an undocumented function for visualizing the poles of the gamma function ratios that occur in the defining Mellin-Barnes integral: With[{c = 1}, SystemMeijerGDumpMeijerGPolePattern[MeijerG[{{}, {1, c + 1/2}}, {{0, c, c, c}, {}}, 1]]]. Also of interest is SystemMeijerGDumpMeijerGInfo[MeijerG[{{}, {1, c + 1/2}}, {{0, c, c, c}, {}}, 1]]. Commented Jan 17, 2021 at 13:18
• @J.M., thank you! These functions are really useful. Of course, one also has to be careful about the difference in definitions of the Meijer G function, as pointed out by Chromo Runge. I was going to write such functions myself. Can't believe Mathematica doesn't put such useful functions in the help document. How does one know the existence of such undocumented function?
– Jing
Commented Jan 17, 2021 at 14:05
• @Jing, just try something like ?? **Meijer*. And use GeneralUtilitiesPrintDefinitions to get the definitions of symbols. Commented Jan 17, 2021 at 14:43
• RawBoxes[ToBoxes[Information["**Meijer*"]] /. {ButtonBox[a___] :> ButtonBox[a, ButtonFunction :> (GeneralUtilitiesPrintDefinitions[Symbol[#[[2, 2]] <> #[[2, 1]]]] &)]}] may help you, as well. Commented Jan 17, 2021 at 15:30