The Meijer G-function is defined as a contour integral in the complex plane. Mathematica is able to numerically evaluate such a function quickly and accurately. How does she do that?
-
1$\begingroup$ Internal numerical algorithms that are not likely to be publicly viewable, is my understanding. $\endgroup$– CA TrevillianCommented Aug 3, 2021 at 9:23
-
$\begingroup$ According to NIST, there seem to be some fortran libraries that calculate the Meijer G-function, see for example dlmf.nist.gov/16.27 , so if I could venture a guess, probably Mathematica uses either a wrapper around that or some similar implementation. The actual details are of course not publicly available. $\endgroup$– Hans OloCommented Aug 3, 2021 at 9:31
-
$\begingroup$ Actually, by googling I found something and added it as an answer. I will update it if I find anything more. $\endgroup$– Hans OloCommented Aug 3, 2021 at 9:37
2 Answers
According to this old draft by Folkmar Bornemann, the implementation of Meijer G-function is a bit complicated and it happens in various stages. The article mentions a comment by Daniel Lichtblau on July 27, 2003:
I'll be discussing aspects of MeijerG issues at ACA next week. It is basically a lookup that converts various functions to MeijerG, then figures out the integral of a product of 2 MeijerG's via Slater convolution.
Furthermore, the Notes on Internal Implementation say the following:
Many other definite integrals are done using Marichev-- Adamchik Mellin transform methods. The results are often initially expressed in terms of Meijer G functions, which are converted into hypergeometric functions using Slater's Theorem and then simplified.
So in a nutshell, when one asks for the value of a Meijer G-function, this is converted to hypergeometric functions and then evaluated using the latter. The attached article also contains some mathematical details, that an interested reader may enjoy.
-
$\begingroup$ Many thanks for this answer! I looked up the references you mentioned, but it was not super helpful. I suppose that mathematica is just very good at summing the corresponding series. $\endgroup$ Commented Aug 3, 2021 at 10:53
Contrary to the comments, alot of the implementation is actually viewable. The evaluation seems to be a bit convoluted. First there a a whole lot of definitions for special cases which then get converted into other forms. A lot of Bessel Functions, Pochhammer, SinIntegrals and Elliptic functions. If this does not match, it gets into the gereral evaluation which seems to consist of alot of Hypergeometric functions and finding of poles (residuals of some kind maybe?) But it seems extremely complex for various pathways of possible parameters.
If you want to read it yourself, type:
<<"GeneralUtilities`"
GeneralUtilities`PrintDefinitions@MeijerG
Hope this helps.
-
$\begingroup$ As already noted,
MeijerG[]
usually does a table lookup. In the event that doesn't work, it does numerical contour integration of the defining Mellin-Barnes integral, with specially chosen contours. $\endgroup$ Commented Dec 10, 2021 at 15:10