For definite integrals MMA gives identities in terms of Meijer G-functions, e.g.

$\begin{align}\sqrt{\pi}\int_0^\infty \textrm{e}^{-4x/t^2-t}\ \textrm{d}t &= G_{0,\,3}^{3,\,0} \left( x\left. \right|\ 0,1/2,1 \right) \tag{1}\\ \sqrt{\pi}\int_0^\infty t\ K_1(t)\ \textrm{e}^{-4\sqrt{x}/t} \ \textrm{d}t &= G_{0,\,4}^{4,\,0} \left(\left. x \ \right| \ 0,1/2,1/2,3/2 \right) \tag{2}\\ 4\int_0^\infty t^{-1}\ K_2(t) \ \textrm{e}^{-4x/t^2} \ \textrm{d}t &= G_{0,\,3}^{3,\,0} \left(\left. x \ \right| -1,0,1 \right) \tag{3}\end{align}$

$\Tiny{\text{In eqs.(1-3) it is assumed that x>0.}\\K_1,K_2\ldots \text{modified Bessel functions of order 1 and 2}\\ G\ldots \text{Meijer G-function}}$




Given a Meijer G-function (e.g. eqs.(1-3) or other ones), how to tell MMA to express the Meijer G-function by an integral or other expressions?

MMA 12.1

  • $\begingroup$ Perhaps you could use InverseLaplaceTransform? $\endgroup$
    – mikado
    Jun 8, 2021 at 12:32
  • $\begingroup$ With a change of variables, your desired integral could represent a Laplace transform. So perhaps change variables x->x s and inverse transform $\endgroup$
    – mikado
    Jun 8, 2021 at 14:32
  • $\begingroup$ Think of a simpler problem: Integrate[Exp[-k*x],{x,0,Infinity},Assumptions->k>=0] performs 1/k. How to restore that integral from 1/k? $\endgroup$
    – user64494
    Jun 11, 2021 at 7:10
  • $\begingroup$ By a lookup table $\endgroup$ Jun 11, 2021 at 9:12
  • 2
    $\begingroup$ Have a look at this link www-m3.ma.tum.de/bornemann/Numerikstreifzug/Chapter9/… It demonstrates how MA comes with MeijerG function for some large class of integrals $\int_0^\infty f_1(x) f_2(\frac{z}{x}) \frac{dx}{x}$ -- the Mellin convolution. Indeed, all you integrals belong to this class. It should be possible to revert the procedure. $\endgroup$
    – yarchik
    Jun 12, 2021 at 2:07

3 Answers 3


Let me first emphasize that the requested procedure cannot be unique and is best performed by hands. Nonetheless, a completely automatic approach can be suggested:

MeijerGIntegral[expr_, var_, dum_] := 
 Module[{s, sA, sB, tvar, si, fA, fB, xx},
  s = MellinTransform[expr, var, tvar];
  si = First[
      s], {Gamma[ tvar] | Gamma[ a_ tvar] | Gamma[ tvar + b_] | 
       Gamma[ a_ tvar + b_], k_}]];
  sA = First[si]^Last[si];
  sB = Cancel[s/sA];
  fA[xx_] := InverseMellinTransform[sA, tvar, xx];
  fB[xx_] := InverseMellinTransform[sB, tvar, xx];
  fA[dum] fB[var/dum]/dum

Let us test it. Get the integrals

r1 = Assuming[x > 0, 
  Integrate[Sqrt[Pi]*Exp[-4 x/t^2 - t], {t, 0, Infinity}]];
r2= Assuming[x > 0, 
   Integrate[Sqrt[Pi]*t*Exp[-4 Sqrt[x]/t]*BesselK[1, t], {t, 0, Infinity}]];
r3 = Assuming[x > 0, 
  Integrate[4/t*BesselK[2, t]*Exp[-4 x/t^2], {t, 0, Infinity}]];

Apply the function

MeijerGIntegral[r1, x, t]
MeijerGIntegral[r2, x, t]
MeijerGIntegral[r3, x, t]

The results are

$$\frac{4 \sqrt{\pi } x e^{-\frac{4 x}{t}-\sqrt{t}}}{t^2};\\ \frac{\sqrt{\pi } e^{-\sqrt{t}} }{2 t} \left(4 \sqrt{\frac{x}{t}} K_0\left(4 \sqrt{\frac{x}{t}}\right)-2 G_{1,3}^{2,1}\left(\frac{4 x}{t}| \begin{array}{c} 0 \\ \frac{1}{2},\frac{1}{2},1 \\ \end{array} \right)\right);\\ \frac{2 e^{-t} \sqrt{\frac{x}{t}} K_1\left(2 \sqrt{\frac{x}{t}}\right)}{t^2} $$

I am actually very happy that the random choice made in MeijerGIntegral not always leads to the original integrand illustrating what I have said above.

My approach is based on the paper in the comment above. Consider the integral $$I(z) = \int_{0}^\infty f_1(x) f_2\!\left(\frac{z}{x}\right) \frac{\mathrm{d}x}{x}.$$ Assume that the Melline transform of $f_1$ and $f_2$ can be analytically computed $$f^*_j(s)=\int_0^\infty\!\! f_j(x)x^{s-1}\,\mathrm{d}x.$$ Then the Mellin transform of $f^*(s)$ is given by a product


This explains how MA comes to Meijer G-function result. It originates from the inverse Mellin transform of $f^*(s)$, which is often expressible in terms of the Meijer G-function.

  • $\begingroup$ This is really good. It would be nice to have some explanation of how it works. I think you are choosing arbitrarily 1 of 6? possible answers. It would be interesting to see all of them (we could perhaps choose the simplest). $\endgroup$
    – mikado
    Jun 12, 2021 at 14:48
  • 1
    $\begingroup$ @mikado Thank you! In fact I am choosing among a smaller number of possibilities for the given examples. The Mellin transform will typically be given by a product of several Gamma functions. I choose on of them for the inverse Mellin and hope that the inverse Mellin can be done for the rest. There is no guarantee. In principle, one should try all possibilities and select the simplest answer. I will add a couple of sentences into my post. $\endgroup$
    – yarchik
    Jun 12, 2021 at 17:46
  • $\begingroup$ The given routine works for the examples of the OP, but for other examples it returns a result that contains another shorter Meijer G-function. How to deal in these cases? Example: MeijerGIntegral[ MeijerG[{{}, {}}, {{0, 1/2, 1, 3/2, 2, 5/2, 3}, {}}, x], x, t] Result: Exp[-Sqrt[t]] Sqrt[Pi]/t MeijerG[{{},{}},{{1,3/2,2,5/2,3},{}},4x/t] $\endgroup$ Jun 13, 2021 at 12:41
  • $\begingroup$ @granularbastard In the function MeijerGIntegral the result of Mellin transform s typically contains a product of several Gamma functions. Next, I split it into a product of two terms sA and sB, where sA necessarily contains Gamma. This splitting is not unique. If you would like to have a different result, you need to split in a different way making sure that for both sA and sB the InverseMellinTransform exists. $\endgroup$
    – yarchik
    Jun 13, 2021 at 12:49

As @yarchik points out in the comments, your Meijer G-functions can be expressed as Mellin integrals. The integrands are found with

f1[t_] = MellinTransform[MeijerG[{{}, {}}, {{0, 1/2, 1}, {}}, x], x, t]
(*    2^(1 - 2 t) Sqrt[π] Gamma[2 t] Gamma[1 + t]    *)

f2[t_] = MellinTransform[MeijerG[{{}, {}}, {{0, 1/2, 1/2, 3/2}, {}}, x], x, t]
(*    2^(1 - 2 t) Sqrt[π] (1/2 + t) Gamma[2 t] Gamma[1/2 + t]^2    *)

f3[t_] = MellinTransform[MeijerG[{{}, {}}, {{-1, 0, 1}, {}}, x], x, t]
(*    Gamma[-1 + t] Gamma[t] Gamma[1 + t]    *)

These Mellin-integral representations of the Meijer G-functions can either be written through InverseMellinTransform, which simply inverts the above operations, or explicitly: (I can only do this step numerically, exemplarily for $x=0.7$; but it's supposed to work for any $x$)

With[{γ = 1, x = 0.7},
  {MeijerG[{{}, {}}, {{0, 1/2, 1}, {}}, x],
   NIntegrate[1/(2π) * f1[t] * x^-t /. t -> γ + I η, {η, -∞, ∞}]}]
(*    {0.272116, 0.272116 + 0. I}    *)

As usual for Mellin integrals, we have to pick $\gamma$ in the right region in order to get the right branch of the solution. Here I've picked $\gamma=1$ for simplicity; but in this example I think any $\gamma>0$ will work.

For the second example, we can again choose any $\gamma>0$:

With[{γ = 1, x = 0.7},
  {MeijerG[{{}, {}}, {{0, 1/2, 1/2, 3/2}, {}}, x],
   NIntegrate[1/(2π) * f2[t] * x^-t /. t -> γ + I η, {η, -∞, ∞}]}]
(*    {0.269902, 0.269902 + 9.84629*10^-14 I}    *)

For the third example, we must choose any $\gamma>1$:

With[{γ = 2, x = 0.7},
  {MeijerG[{{}, {}}, {{-1, 0, 1}, {}}, x],
   NIntegrate[1/(2π) * f3[t] * x^-t /. t -> γ + I η, {η, -∞, ∞}]}]
(*    {0.663027, 0.663027 + 4.94414*10^-14 I}    *)

To summarize,

$$ G_{0,3}^{3,0}\left(x\left| \begin{array}{c} 0,\frac{1}{2},1 \\ \end{array} \right.\right) = \frac{1}{2\pi} \int_{-\infty}^{\infty} d\eta x^{-(\gamma+i\eta)} \sqrt{\pi } 2^{1-2 (\gamma +i \eta )} \Gamma (2 (\gamma +i \eta )) \Gamma (\gamma +i \eta +1) $$ and similar for the other two functions, where the integrand was found automatically via MellinTransform, and $\gamma$ can be chosen quite freely.


The following is true

LaplaceTransform[Exp[-(x/t)^2], t, s]
(* MeijerG[{{}, {}}, {{0, 1/2, 1}, {}}, (s^2 x^2)/4]/(Sqrt[π] s) *)

Note that your integral is given by the value obtained when s=1.

If Mathematica could evaluate

 MeijerG[{{}, {}}, {{0, 1/2, 1}, {}}, (s^2 x^2)/4]/(Sqrt[π] s), s, t]

you would get something close to your integral. Unfortunately, it returns unevaluated.


Here is a general procedure, though it only works if Mathematica can evaluate an InverseLaplaceTransform.

Consider an example of a MeijerG function (though in this case, Mathematica will automatically simplify it)

expression = MeijerGReduce[1/(1 + x^2), x]
(* Inactive[MeijerG][{{0}, {}}, {{0}, {}}, x^2] *)

Now consider its inverse Laplace transform. Presumably there are other ways in which one might introduce the auxiliary variable s.

ilt = 
 Activate /@ InverseLaplaceTransform[expression /. x -> x s, s, t]
(* Sin[t/x]/x *)

Here, Mathematica can compute the transform, and we have an integral giving us our original expression

integrand = ilt *Exp[-t]
(* (E^-t Sin[t/x])/x *)

 Assuming[x > 0, Integrate[integrand, {t, 0, ∞}]], x]
(* Inactive[MeijerG][{{0}, {}}, {{0}, {}}, x^2] *)

Unfortunately, Mathematica is unable to evaluate the transform for your examples. However, this might be an approach you could follow - you might find some clever way of evaluating the integral in the inverse transform.


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.