Skip to content

Latest commit

 

History

History
154 lines (115 loc) · 5.77 KB

File metadata and controls

154 lines (115 loc) · 5.77 KB

MeijerG.jl

CI codecov Docs DOI

A Julia package for computing the Meijer G-function defined by the Mellin-Barnes integral

$$ G_{p,q}^{m,n}\left(z \hspace{1mm} \left| {a_1,\dots,a_p}\atop{b_1,\dots,b_q}\right) \right. = \frac{1}{2\pi i}\int_{\mathcal{L}} \frac{\prod_{j=1}^{m}\Gamma(b_j-s)\prod_{j=1}^{n}\Gamma(1-a_j+s)} {\prod_{j=m+1}^{q}\Gamma(1-b_j+s)\prod_{j=n+1}^{p}\Gamma(a_j-s)} z^s ds. $$

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.

Complex phase portraits of $G_{3,3}^{2,1}\!\left(z\,\middle|\,\frac{1}{7}+0.2\cos(2\pi t),\frac{2}{7},\frac{4}{7};\frac{3}{7},\frac{5}{7},\frac{6}{7}\right)$ for $t \in [0,1)$
NIST Standard Animation Viridis (Periodic) Animation
NIST Standard Viridis (Periodic)

Contents

Installation

The package is not yet registered; install directly from this repository:

using Pkg
Pkg.add(url = "https://github.com/TSGut/MeijerG.jl")

Examples

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)

Formatter

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]
==============================================

Interface

meijerg(a, b, m, n, z) -> Number

Compute $G_{p,q}^{m,n}(z | {{a}\atop{b}})$ where 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) -> Number

Split-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.

Power-user API

meijerg_slater(a, b, m, n, z) -> Number
meijerg_slater(a_left, a_right, b_left, b_right, z) -> Number

Pure 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...) -> Number

Direct 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.

References