A Julia package for computing the Meijer G-function defined by the Mellin-Barnes integral
The Meijer-G function is a single unifying function that encompasses many classical special functions as particular cases and appears, even in its more general forms, in many applications.
The package is built on top of
HypergeometricFunctions.jl
and SpecialFunctions.jl
and supports arbitrary Julia numeric types: pass Float64, Complex{Float64} for standard
double precision or BigFloat, Complex{BigFloat} for arbitrary-precision results.
The default algorithm uses special-case reductions when available, Slater expansions when safe, adaptive perturbation for confluent-pole robustness and finally deploys numerical contour integration as a fallback. See the math notes in the docs for details.
The package is not yet registered; install directly from this repository:
using Pkg
Pkg.add(url = "https://github.com/TSGut/MeijerG.jl")using MeijerG
# exp(x) = G_{0,1}^{1,0}(-x | _ ; 0)
meijerg((), (), (0,), (), -0.3)
# sin(y) = √π · G_{0,2}^{1,0}(y²/4 | _ ; 1/2, 0)
sqrt(pi) * meijerg((), (), (0.5,), (0,), 0.49)
# Arbitrary precision via BigFloat
setprecision(512) do
x = big"0.3"
meijerg((), (), (big"0.0",), (), -x)
end
# Split-parameter form: G_{2,2}^{1,1}(z | a_L, a_R ; b_L, b_R)
meijerg((0.25,), (1.75,), (0.5,), (1.25,), 2.0)
# Power-user API: pure Slater residue evaluation, no reductions or perturbation
meijerg_slater((0.25,), (1.75,), (0.5,), (1.25,), 2.0)
# Power-user API: direct Mellin-Barnes contour evaluation
meijerg_contour((0.25,), (1.75,), (0.5,), (1.25,), 2.0)The @formatter macro exported by MeijerG.jl provides a convenient way to convert Meijer G-function syntax into widely used formats:
julia> plain, latex, math = @formatter meijerg((1, 2), (3, 4), 1, 1, 5);
==============================================
Plaintext: G_{2,2}^{1,1}(5 | 1, 2 ; 3, 4)
LaTeX: G_{2,2}^{1,1}\left(5\;\middle|\begin{matrix}1, 2\\3, 4\end{matrix}\right)
Mathematica: MeijerG[{{1}, {2}}, {{3}, {4}}, 5]
==============================================meijerg(a, b, m, n, z) -> NumberCompute a and b are the complete upper and lower
parameter vectors (or tuples), m and n are the Meijer G indices
satisfying 0 ≤ m ≤ length(b) and 0 ≤ n ≤ length(a), and z is the
evaluation point.
meijerg(a_left, a_right, b_left, b_right, z) -> NumberSplit-parameter form following the Wolfram Mathematica convention. Here n = length(a_left) and m = length(b_left). The full parameter tuples are assembled as a = [a_left; a_right] and b = [b_left; b_right].
Both forms accept Tuple or AbstractVector for the parameter arguments.
meijerg_slater(a, b, m, n, z) -> Number
meijerg_slater(a_left, a_right, b_left, b_right, z) -> NumberPure Slater residue evaluation without reductions or perturbation. This will fail on confluent-pole cases (e.g., integer-separated parameters). Use only when you specifically want raw Slater residue sums.
meijerg_contour(a, b, m, n, z; kwargs...) -> Number
meijerg_contour(a_left, a_right, b_left, b_right, z; kwargs...) -> NumberDirect numerical Mellin-Barnes contour integration.
In production use, meijerg() typically handles these cases via adaptive perturbation instead. Use meijerg_contour for specific workflows if you know what you are doing.
- DLMF (Meijer G section)
- Wolfram Functions Site (Meijer G)
- HypergeometricFunctions.jl
- SpecialFunctions.jl
- ComplexPhasePortrait.jl (for the generation of complex phase portraits)

