---
title: "Spacekime Analytics (Time Complexity and Inferential Uncertainty)"
subtitle: "TCIU: Laplace Transform and Meijer-G Functions"
author: "Yueyang Shen, Ivo Dinov, and the SOCR Team"
date: "`r format(Sys.time(),'%m/%d/%Y')`"
output: 
  html_document:
    theme: spacelab
    highlight: tango
    keep_md: false
    includes:
      before_body: TCIU_header.html
    toc: true
    number_sections: true
    toc_depth: 3
    toc_float:
      collapsed: false
      smooth_scroll: true
    code_folding: hide
---

```{css, echo=FALSE}
.header-section-number::after {
  content: ".";
}
```
<style>
a:link {
    color: red;
}

a:visited {
    color: green;
}

a:hover {
    color: hotpink;
}
.theorem p {
  padding: 15px 15px 15px 15px;
}
.theorem {
  display: block;
  font-style: italic;
  font-size: 16px;
  font-family: "Times New Roman";
  color: black;
  border-radius: 10px;
  background-color: rgb(222,222,231);
  box-shadow: 5px 10px 8px #888888;
}
.theorem[text]::before {
  content: "Theorem (" attr(text) ") ";
}
.theorem::before {
  content: "Theorem. ";
  font-weight: bold;
  font-style: normal;
  display: inline-block;
  width: -webkit-fill-available;
  color: white;
  border-radius: 10px 10px 0 0;
  padding: 10px 5px 5px 15px;
  background-color: rgb(38, 38, 134);
}
.proof p {
  padding: 15px 15px 15px 15px;
}
.proof {
  display: block;
  font-style: italic;
  font-size: 16px;
  font-family: "Times New Roman";
  color: black;
  border-radius: 10px;
  background-color: rgb(193,254,184);
  box-shadow: 5px 10px 8px #C1FEB8;
}
.proof[text]::before {
  content: "Theorem (" attr(text) ") ";
}
.proof::before {
  content: "Proof. ";
  font-weight: bold;
  font-style: normal;
  display: inline-block;
  width: -webkit-fill-available;
  color: white;
  border-radius: 10px 10px 0 0;
  padding: 10px 5px 5px 15px;
  background-color: rgb(29, 213, 2);
}
.corollary p {
  padding: 15px 15px 15px 15px;
}
.corollary {
  display: block;
  font-style: italic;
  font-size: 16px;
  font-family: "Times New Roman";
  color: black;
  border-radius: 10px;
  background-color: rgb(249, 184, 163);
  box-shadow: 5px 10px 8px #F9B8A3;
}
.corollary[text]::before {
  content: "Theorem (" attr(text) ") ";
}
.corollary::before {
  content: "Corollary. ";
  font-weight: bold;
  font-style: normal;
  display: inline-block;
  width: -webkit-fill-available;
  color: white;
  border-radius: 10px 10px 0 0;
  padding: 10px 5px 5px 15px;
  background-color: rgb(295, 66,7);
}
.lemma p {
  padding: 15px 15px 15px 15px;
}
.lemma {
  display: block;
  font-style: italic;
  font-size: 16px;
  font-family: "Times New Roman";
  color: black;
  border-radius: 10px;
  background-color: rgb(252,218,41);
  box-shadow: 5px 10px 8px #FCDA29;
}
.lemma[text]::before {
  content: "Theorem (" attr(text) ") ";
}
.lemma::before {
  content: "Lemma. ";
  font-weight: bold;
  font-style: normal;
  display: inline-block;
  width: -webkit-fill-available;
  color: white;
  border-radius: 10px 10px 0 0;
  padding: 10px 5px 5px 15px;
  background-color: rgb(225,190,10);
}
div.container {
          display:inline-block;
}

</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


Earlier in [Chapter 4](https://www.socr.umich.edu/TCIU/HTMLs/Chapter4_Laplace_Transform_Timeseries_Kimesurfaces.html) we discussed the [Laplace Transform](https://en.wikipedia.org/wiki/Laplace_transform), $\mathcal{L}$, mapping spatio-temporal signals into 2D manifolds called *spacekime surfaces*. The Laplace transformation is a linear operator that maps complex-valued functions of a positive real variable (e.g., time, $t \in\mathbb{R}^+$) to complex valued functions defined over the complex plane, $\kappa\in\mathbb{C}$

$${\mathcal {L}}(f)(\kappa)=\hat{f}(\kappa)\equiv F(\kappa)=\int_{0}^{\infty} {f(t)e^{-\kappa t} dt}.$$


# Theoretical Fundamentals and Geometric Properties

The [Laplace transform](https://en.wikipedia.org/wiki/Laplace_transform) is a special case of the more general [integral transform](https://en.wikipedia.org/wiki/Integral_transform) defined for a specific kernel $K(\cdot,\cdot)$:

$$(Tf)(z)=\int_{t_{1}}^{t_{2}}f(t)\,K(t,z) dt.$$

Under certain cases, the [Meijer-G function](https://en.wikipedia.org/wiki/Meijer_G-function) turns out to be an effective symbolic computation strategy to compute integrals of the form: $\int_0^{\infty}f(x)dx$. It also has really important theoretical connections to the theory of complex numbers and mathematical (integral) transformations. It is an important function class that is closed with respect to many integral transformations (e.g., Fourier, Laplace transforms) and presents many flexibility to metamodeling and enhancing model interpretability. Specifically, this prior work shows the general utilization of the Meijer-G function [1]:

$$\text{Polynomials Approximants (Taylor series)} \subset \text{Algebraic Approximants (Padé)} \subset \text{Analytic Functions (Meijer-G)}$$

Let's explore a few of these aspects.

The Meijer-G function is defined as follows:
\begin{equation}
\begin{split}
    G_{p,q}^{m,n}(a_1,...a_p;b_1,b_2,...b_q|z)\equiv G_{p,q}^{m,n}\left(\begin{array}{c}
a_p\\
b_q
\end{array}\bigg| z\right)\equiv G_{p,q}^{m,n}\left(\begin{array}{c}
\overbrace{a_1,...,a_n}^{\text{n component}};\overbrace{a_{n+1},...,a_{p}}^{\text{p-n component}}\\
\underbrace{b_1,...,b_m}_{\text{m component}};\underbrace{b_{m+1},...,b_{q}}_{\text{q-m component}}
\end{array}\bigg| z\right)=\\\frac{1}{2\pi i}\int_{C}\frac{\Gamma(b_1-s)...\Gamma(b_m-s)\Gamma(1-a_1+s)...\Gamma(1-a_n+s)}{\Gamma(1-b_{m+1}+s)...\Gamma(1-b_q+s)\Gamma(a_{n+1}-s)...\Gamma(a_{p}-s)}z^sds.
\end{split}
\end{equation} 

A key aspect of the *Meijer-G function* is its relation to the *Laplace transform*.

<div class="theorem" text='Laplace transform via Meijer  G'>
  The Laplace transform for Meijer-G function of $x^2$ type is
\begin{equation}
\int_0^{\infty} e^{-s\cdot x}G_{p,q}^{m,n}\left(\begin{array}{c}
a_p\\
b_q
\end{array}\bigg| wx^2\right)dx = \frac{1}{\sqrt{\pi}s}G_{p+2,q}^{m,n+2}\left(\begin{array}{c}
0,\frac{1}{2},a_p\\
b_q
\end{array}\bigg| \frac{4w}{s^2}\right) 
\label{eq1}\tag{1}
\end{equation}
More explicitly, it is 

$$\frac{1}{\sqrt{\pi}s}G_{p+2,q}^{m,n+2}\left(\begin{array}{c}
\overbrace{\overbrace{0,\frac{1}{2},a_1,....,a_n}^{n+2\ components};a_{n+1},....a_{p}}^{p+2\ components} \\
b_q
\end{array} \bigg| \frac{4w}{s^2}\right).$$
</div>

<div class="theorem" text='Meijer-G function representation of the cosine function'>

The cosine family of base functions belong to the general Meijer-G family:

\begin{equation}
    \cos(x) = \sqrt{\pi}G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
0;\frac{1}{2}
\end{array}\bigg| \frac{x^2}{4}\right).
\end{equation}
</div>


<div class="proof">

We can directly derive this from the definition by expanding the right hand side as follows. 

\begin{equation}
\begin{split}
RHS &= \sqrt{\pi} (-\frac{1}{2\pi i})\int_{C}\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}^q\Gamma(a_j-s)}z^sds\bigg|_{z=\frac{x^2}{4}}\\
&=\sqrt{\pi}(-\frac{1}{2\pi i})\int_C \frac{\Gamma(-s)}{\Gamma(1-\frac{1}{2}+s)}z^sds\bigg|_{z=\frac{x^2}{4}}=\sqrt{\pi}(-\frac{1}{2\pi i}) \underbrace{2\pi i\sum_{k=0}^{\infty}res_{k}}_{\text{residue theorem}}
\end{split}
\end{equation}

The gamma function $\Gamma(z)$ has poles $0,-1,-2,....$, and $\frac{1}{\Gamma(z)}$ is entire  since the gamma function has no zeros.
Using the fact that only the poles from the numerator results in residues which contributes to the integration, and $\text{res}_{z=n}\Gamma(-z)=\frac{(-1)^{n+1}}{n!}$ (the rest are scalar factors), we have
\newpage
\begin{equation}
\begin{split}
RHS &= \sqrt{\pi}(-\frac{1}{2\pi i})2\pi i\sum_{k=0}^{\infty}\frac{(-1)^{k+1}}{k!}\frac{1}{\Gamma(\frac{1}{2}+k)}(\frac{x^2}{4})^k=-\sum_{k=0}^{\infty}\frac{(-1)^{k+1}}{k!}x^{2k}\\&=\sum_{k=0}^{\infty}\frac{(-1)^{k}}{k!}x^{2k}=\cos(x)    
\end{split}

\end{equation}
where we have used the fact that $\frac{k!\Gamma(\frac{1}{2}+k)4^k}{\sqrt{\pi}}=(2k)!$. Since $k!2^k=2\cdot 4\cdot 6\cdots 2k$ and $\frac{\Gamma(\frac{1}{2}+k)2^k}{\sqrt{\pi}}=1\cdot 3\cdot 5...\cdot (2k-1).$ 
</div>

Schematically, the red contour of integration, $\gamma$, can be extended to positive infinity on the right and the only contributions to the contour integral of $\Gamma(-z)$ are the poles $0,1,2,\cdots \in \mathbb{R}$.

```{r residue plot, echo=FALSE,message=FALSE,warning=FALSE}
library(plotly)
x=c(0,1,2,3,4,5,6,7,7.5)
xprime=c(-0.5,0.6,1.7,2.8,3.9,5.1,6.3,7.5)
y=c(0,0,0,0,0,0,0,0,0)
yprime=c(0,0.1,0.15,0.2,0.2,0.15,0.1,0)
z=c(0,0,0,0,0,0,0,0,1)
df <- data.frame(x = x, y = y, z = z)


fig <- plot_ly()
fig <- fig %>% add_lines(x = ~xprime,y =~yprime, name = "spline", line = list(shape = "spline"),color = I('red')) 
fig <- fig %>% add_lines(x = ~xprime,y =~-yprime, name = "spline", line = list(shape = "spline"),color = I('red')) 
fig <- fig %>% add_trace(x=~x,y = ~y, mode = 'markers', type = 'scatter', symbol = ~z, symbols = c('x','circle'),color = I('black'), marker = list(size = 10))
fig <- fig %>% layout(showlegend = FALSE,yaxis = list(range = c(-0.8,1), title = 'y'),xaxis = list(range = c(-0.6,7.9), title = 'x'))
fig <- fig %>% add_text(
    x = 7.5, 
    y = 0, 
    size = I(15),
    text = "      \U221E",
    hovertext = c(
           "unicode"
    ),
    textposition = "bottom center",
    hoverinfo = "text"
  )
fig <- fig %>% add_text(
    x = 7.3, 
    y = 0.05, 
    size = I(15),
    color = I('red'),
    text = "      \U03B3",
    hovertext = c(
           "unicode"
    ),
    textposition = "top left",
    hoverinfo = "text"
  )
fig
``` 


# The Laplace transform as a Meijer-G function

We will demonstrate the representations of the Laplace transform of the trigonometric (cosine) basis and Bessel base functions, which are commonly used to expand most "nice" functions.

<div class="corollary" text='Laplace transform of cosine as a Meijer-G funciton'>

The cosine base functions can be represented via the general Meijer-G function as follows.

$\cos(x) = \sqrt{\pi}G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
0;\frac{1}{2}
\end{array}\bigg| \frac{x^2}{4}\right)$. 

As the general form of Meijer-G function is closed under Laplace transform (Equ [1](#mjx-eqn-eq1)), we have:

\begin{equation}
 \mathcal{L}(\cos(wx))(s)=\frac{s}{w^2+s^2}
\end{equation}
</div>

<div class="proof" >
\begin{equation}
\begin{split}
    \mathcal{L}(\cos(wx))(s) &= \frac{1}{\sqrt{\pi}s}\sqrt{\pi}G_{2,2}^{1,2}\left(\begin{array}{c}
0,\frac{1}{2};\\
0;\frac{1}{2}
\end{array}\bigg| \frac{4w'}{s^2}\right)\bigg|_{w'=\frac{w^2}{4}}\\
&=\frac{1}{s}\left(\frac{1}{1+x}\right)\bigg|_{x=\frac{w^2}{s^2}}=\frac{1}{s}\cdot \frac{1}{1+\frac{w^2}{s^2}}=\frac{s}{w^2+s^2}
\end{split}
\end{equation}
</div>

<div class="lemma" >
\begin{equation}
{}_2^1F(\frac{1+n}{2},\frac{2+n}{2},1+n,x)=\frac{2^n(1-\sqrt{1-x})^n}{\sqrt{1-x}x^n}, \forall n\in \mathbb{Z}
\end{equation}
</div>   

<div class="corollary" text='Laplace transform of Bessel J functions'>
The [Bessel J function]() belong to the general Meijer-G family with $J_n(at) = G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
\frac{n}{2};-\frac{n}{2}
\end{array}\bigg|\frac{a^2t^2}{4}\right), -\frac{\pi}{2}\le arg(x)\equiv at \leq \frac{\pi}{2}$.

Using the general form of Meijer-G function being closed under Laplace transform (Equ [1](#mjx-eqn-eq1))
\begin{equation}
 \mathcal{L}(J_n(at))(s)=\frac{(-s+\sqrt{a^2+s^2})^n}{a^n\sqrt{s^2+a^2}}
\end{equation}
</div>



<div class="proof" >
Applying Equation ([1](#mjx-eqn-eq1)), we use $\mathcal{L}{J_n(at)}(s)=G_{2,2}^{1,2}\left(\begin{array}{c}
0,\frac{1}{2};\\
\frac{n}{2};-\frac{n}{2}
\end{array}\bigg|\frac{a^2t^2}{s^2}\right)$ by referring to mathematica or we may refer to the special case for Meijer-G tabularized at wolfram website,
\begin{equation}
\begin{split}
LHS&=\frac{1}{\sqrt{\pi}s}\cdot 2^{-n}\sqrt{\pi}(\frac{a^2}{s^2})^{n/2}{}_2^1F(\frac{1+n}{2},\frac{2+n}{2},1+n,-\frac{a^2}{s^2})\\&=2^{-n}s^{-1-n}a^n\frac{2^n(1-\sqrt{1-x})^n}{\sqrt{1-x}x^n}\bigg|_{x=-\frac{a^2}{s^2}}\\&=s^{n-1}\frac{1}{a^n}\frac{(-1+\sqrt{1+\frac{a^2}{s^2}})^n}{\sqrt{1+\frac{a^2}{s^2}}}=\frac{(-s+\sqrt{a^2+s^2})^n}{a^n\sqrt{s^2+a^2}}
\end{split}
\end{equation}
where we made use the previous *lemma.*
</div>

# Case studies with example animations

Let's explore several animation examples showcasing the parallels between raw and Laplace-transformed signals by expanding (continuing) the *domain* of the original signal ($\mathbb{R}^+$) into the complex plane ($\mathbb{C}$) using the Meijer-G functions.

## The cosine base function

The following [Mathematica](https://en.wikipedia.org/wiki/Wolfram_Mathematica) code illustrates the solution for the original case on the left.

```{r eval=FALSE}
gg[w_, x_] = Sqrt[Pi]*MeijerG[{{}, {}}, {{0}, {1/2}}, (w*x)^2/4]

MeijerGcos[var1_, viewops : OptionsPattern[]] := 
 Module[{plot, cosinepara}, 
  plot = Plot3D[Re[gg[var1, a + b*I]], {a, -10, 10}, {b, -2, 2}, 
    PlotRange -> Automatic, Mesh -> None, PlotPoints -> 500, 
    ColorFunction -> Function[{x, y, z}, Hue[Arg[gg[var1, x + I y]]]], 
    ColorFunctionScaling -> False, Axes -> True, 
    AxesStyle -> Arrowheads[0.01]];
  cosinepara = 
   ParametricPlot3D[{t, 0, Cos[var1*t]}, {t, -10, 10}, 
    PlotStyle -> {Black, Thickness[0.005]}, AxesLabel -> {x, y, z}];
  Show[cosinepara, plot, Axes -> True, 
   AxesLabel -> {Style["Time Ordered Signal - Classical t", Bold, 12],
      Style["Continued axis - y", Bold, 10], 
     Style["Real value", Bold, 16]}, 
   PlotRange -> {{-10, 10}, {-2, 2}, {-2, 2}}, Evaluate[viewops]]]
ani = Table[MeijerGcos[c], {c, 1, 5, 0.3}];
anifb = Join[ani, Reverse[ani]];
Export["C:\\Users\\user\\project\\cosinefb_test.gif", anifb, 
       "DisplayDurations" -> 0.2, 
       "AnimationReptitions" -> 20, 
       "AnimationDirection" -> ForwardBackward, ImageSize -> 800];
```

The corresponding Mathematica code for the transformed case on the right is below.

```{r eval=FALSE}
gtrans[w_, s_] = 1/s*MeijerG[{{0, 1/2}, {}}, {{0}, {1/2}}, w^2/(s^2)]

ani2 = Table[
   Plot3D[Abs[gtrans[c, a + b*I]], {a, -5, 5}, {b, -5, 5}, 
    PlotRange -> Automatic, Mesh -> None, PlotPoints -> 500, 
    PlotLabel -> Style["The Transformed Domain", Bold, 20], 
    AxesLabel -> {Style["Transformed x", Bold, 12], 
      Style["Transformed y", Bold, 12], Style["Intensity", Bold, 12]},
     ColorFunction -> 
     Function[{x, y, z}, Hue[Arg[gtrans[c, x + I y]]]], 
    ColorFunctionScaling -> False, Axes -> True, 
    AxesStyle -> Arrowheads[0.01]], {c, 1, 5, 0.3}];
ani2fb = Join[ani2, Reverse[ani2]];
Export["C:\\Users\\meijertransformed_domain1_forback.gif", ani2fb, 
  "DisplayDurations" -> 0.2, "AnimationReptitions" -> 20, 
  "AnimationDirection" -> ForwardBackward, ImageSize -> 800];
```


![](meijerg_cosinefb.gif){width=45%}  ![](meijertg_forback.gif){width=45%}
 
 
More succinctly, the left-to-right side correspondence (the left graph corresponds to the left equation and the right graph corresponds to the right equation) is shown below.
 
$$\cos(wx)=\sqrt{\pi}G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
0;\frac{1}{2}
\end{array}\bigg| \frac{(wx)^2}{4}\right)\Bigg|_{Im(\cdot)=y=0} \Longleftrightarrow \begin{equation}
\begin{split}
    \mathcal{L}(\cos(wx))(s) &= \frac{1}{\sqrt{\pi}s}\sqrt{\pi}G_{2,2}^{1,2}\left(\begin{array}{c}
0,\frac{1}{2};\\
0;\frac{1}{2}
\end{array}\bigg| \frac{4w'}{s^2}\right)\bigg|_{w'=\frac{w^2}{4}}\\
&=\frac{s}{w^2+s^2}
\end{split}
\end{equation}.$$
 
 <font size="5"> **The <span style="text-decoration:underline">time-ordered signal (event, i.e., the black curve - in this case $\cos(wx)$) is anchored on the xz plane</span>, and the y-axis is a "continuation" for the signal to be defined on the complex plane. The perceived evolution is the changing value for w. Furthermore, the evaluated signal is complex-valued, and the z-axis resembles the real value so that it coincides with the original time-ordered signal, and the coloring resembles the phase where the (real part, phase information) is sufficient to resemble the whole functional landscape.**
</font> 

## The Bessel J base function

The Bessel function example is similar compared to the previous cosine function example animation, but uses an appropriate Meijer-G function corresponding to the Bessel basis.

The general plot set up functionality for the [Bessel J function of the first kind](https://en.wikipedia.org/wiki/Bessel_function), a fixed $n=1$, and varying scenarios is shown below.

```{r eval=FALSE}
# The original Domain
gb[n_, a_, t_] = MeijerG[{{}, {}}, {{n/2}, {-n/2}}, (a*t)^2/4]
MeijerGbessel[var1_, var2_, viewops : OptionsPattern[]] := 
 Module[{plot, besselpara}, 
  plot = Plot3D[Re[gb[var1, var2, a + b*I]], {a, 0, 10}, {b, -2, 2}, 
    PlotRange -> Automatic, Mesh -> None, PlotPoints -> 500, 
    ColorFunction -> 
     Function[{x, y, z}, Hue[Arg[gb[var1, var2, x + I y]]]], 
    ColorFunctionScaling -> False, Axes -> True, 
    AxesStyle -> Arrowheads[0.01]];
  besselpara = 
   ParametricPlot3D[{t, 0, BesselJ[var1, var2*t]}, {t, 0, 10}, 
    PlotStyle -> {Black, Thickness[0.01]}, AxesLabel -> {x, y, z}];
  Show[besselpara, plot, Axes -> True, 
   PlotLabel -> Style["The Original Domain", Bold, 30], 
   AxesLabel -> {Style["Time Ordered Signal - Classical t", Bold, 24],
      Style["Continued axis - y", Bold, 16], 
     Style["Real value", Bold, 20]}, 
   PlotRange -> {{0, 10}, {-2, 2}, {-2, 2}}, Evaluate[viewops]]]
```

Here are the specific Mathematica instructions to create the animations.

```{r eval=FALSE}
# The original domain
anib = Table[MeijerGbessel[1, c], {c, 1, 6, 1}];
anibfb = Join[anib, Reverse[anib]];
Export["C:\\Users\\user\\project\\meijerg_besselfb.gif", anibfb, "DisplayDurations" -> 0.2, 
  "AnimationReptitions" -> 20, 
  "AnimationDirection" -> ForwardBackward, ImageSize -> 800];
```


```{r eval=FALSE}
# The transformed domain
gbtrans[n_, a_, s_] = (-s + Sqrt[a^2 + s^2])^n/(a^n*Sqrt[s^2 + a^2])
anitb = Table[
   Plot3D[Abs[gbtrans[1, c, a + b*I]], {a, -5, 5}, {b, -5, 5}, 
    PlotRange -> {{-5, 5}, {-5, 5}, {-5, 5}}, Mesh -> None, 
    PlotPoints -> 500, 
    PlotLabel -> Style["The Transformed Domain", Bold, 30], 
    AxesLabel -> {Style["Transformed x", Bold, 20], 
      Style["Transformed y", Bold, 20], Style["Intensity", Bold, 20]},
     ColorFunction -> 
     Function[{x, y, z}, Hue[Arg[gbtrans[1, c, x + I y]]]], 
    ColorFunctionScaling -> False, Axes -> True, 
    AxesStyle -> Arrowheads[0.01]], {c, 1, 6, 1}];
anitbfb = Join[anitb, Reverse[anitb]];
Export["C:\\Users\\user\\project\\meijerbesseltransformed_forback.gif", anitbfb, 
  "DisplayDurations" -> 0.2, "AnimationReptitions" -> 20, 
  "AnimationDirection" -> ForwardBackward, ImageSize -> 800];
```


![](meijerg_besselfb.gif){width=45%}  ![](meijerbesseltransformed_forback.gif){width=45%}


Here is the direct correspondence between the Bessel $\left (J_n(at)\right )$ and the Meijer $\left (G_{1,2}^{2,2}(\cdot | \cdot)\right )$ functions.
 
$$J_n(at) = G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
\frac{n}{2};-\frac{n}{2}
\end{array}\bigg|\frac{a^2t^2}{4}\right)\Bigg|_{Im(\cdot)=y=0}, \frac{-\pi}{2}\le arg(x)\equiv at \leq \frac{\pi}{2} \Longleftrightarrow \mathcal{L}{J_n(at)}(s)=G_{1,2}^{2,2}\left(\begin{array}{c}
0,\frac{1}{2};\\
\frac{n}{2};-\frac{n}{2}
\end{array}\bigg|\frac{a^2t^2}{s^2}\right)$$

Specifically, for $n=1$,

$$J_1(at) = G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
\frac{1}{2};-\frac{1}{2}
\end{array}\bigg|\frac{a^2t^2}{4}\right)\Bigg|_{Im(\cdot)=y=0}, \frac{-\pi}{2}\le arg(x)\equiv at \leq \frac{\pi}{2} \Longleftrightarrow \mathcal{L}{J_1(at)}(s)=G_{1,2}^{2,2}\left(\begin{array}{c}
0,\frac{1}{2};\\
\frac{1}{2};-\frac{1}{2}
\end{array}\bigg|\frac{a^2t^2}{s^2}\right)$$

Here is an example using a fixed $a=1$ and varying $n$ arguments.

```{r eval=FALSE}
# The original domain
ani2b = Table[MeijerGbessel[c, 1], {c, 1, 6, 1}];
ani2bfb = Join[ani2b, Reverse[ani2b]];
Export["C:\\Users\\user\\project\\besselaltfb.gif", ani2bfb, 
       "DisplayDurations" -> 0.2, 
       "AnimationReptitions" -> 20,
       "AnimationDirection" -> ForwardBackward, ImageSize -> 800];
```


```{r eval=FALSE}
# The transformed domain
anitb = Table[
   Plot3D[Abs[gbtrans[c, 1, a + b*I]], {a, -5, 5}, {b, -5, 5}, 
    PlotRange -> {{-5, 5}, {-5, 5}, {-5, 5}}, Mesh -> None, 
    PlotPoints -> 500, 
    PlotLabel -> Style["The Transformed Domain", Bold, 30], 
    AxesLabel -> {Style["Transformed x", Bold, 20], 
      Style["Transformed y", Bold, 20], Style["Intensity", Bold, 20]},
     ColorFunction -> 
     Function[{x, y, z}, Hue[Arg[gbtrans[c, 1, x + I y]]]], 
    ColorFunctionScaling -> False, Axes -> True, 
    AxesStyle -> Arrowheads[0.01]], {c, 1, 6, 1}];
anitbfb = Join[anitb, Reverse[anitb]];
Export["C:\\Users\\user\\project\\meijerbesseltransformedvaryn_forback.gif", anitbfb, 
  "DisplayDurations" -> 0.2, "AnimationReptitions" -> 20, 
  "AnimationDirection" -> ForwardBackward, ImageSize -> 800];
```



![](meijerg_besselaltfb.gif){width=45%}  ![](meijerbesseltransformedvaryn_forback.gif){width=45%}


The correspondence here is 

$$J_n(t) = G_{0,2}^{1,0}\left(\begin{array}{c}
;\\
\frac{n}{2};-\frac{n}{2}
\end{array}\bigg|\frac{t^2}{4}\right)\Bigg|_{Im(\cdot)=y=0}, \frac{-\pi}{2}\le arg(x)\equiv t \leq \frac{\pi}{2} \Longleftrightarrow \mathcal{L}{J_n(t)}(s)=G_{1,2}^{2,2}\left(\begin{array}{c}
0,\frac{1}{2};\\
\frac{n}{2};-\frac{n}{2}
\end{array}\bigg|\frac{t^2}{s^2}\right)$$

# Python implementation

We can use the python-implementation in the symbolic computing package `sympy` to demonstrate the *symbolic* and *numerical* computisng of the *Meijer-G* function.


```{r warning=F, message=F}
# install.packages("reticulate")
library(reticulate)
library(plotly)
# specify the path of the Python version that you want to use
#py_path = "C:/Users/Dinov/Anaconda3/"  # manual
py_path = Sys.which("python3")       # automated
# use_python(py_path, required = T)
Sys.setenv(RETICULATE_PYTHON = "C:/Users/Dinov/Anaconda3/")
sys <- import("sys", convert = TRUE)
```

Here is an example passing Meijer-G function parameters as four separate vectors.

```{python}
from sympy.functions import meijerg
from sympy.abc import x, a
from sympy.core.containers import Tuple
from sympy import pprint  # pretty print
import mpmath             # Meijer-G function
# import sympy
import math 

# Symbolic Meijer-G function representaiton
pprint(meijerg((1, 2), (a, 4), (5,), [], x), use_unicode=False)

# Retrieval of the Meijer-G function parameters
# Vectors of length zero and one also have to be passed as iterables. 
# The parameters need not be constants, but if they depend on the argument,
# then not much implemented functionality should be expected.
# All the subvectors of parameters are available:
g = meijerg([1], [2], [3], [4], x)

print("Meijer-G Function form: ")
pprint(g, use_unicode=False)
print("Meijer-G Function argument: an: ")
pprint(g.an, use_unicode=False)
print("Meijer-G Function argument: ap: ")
pprint(g.ap, use_unicode=False)
print("Meijer-G Function argument: aother: ")
pprint(g.aother, use_unicode=False)
print("Meijer-G Function argument: bm: ")
pprint(g.bm, use_unicode=False)
print("Meijer-G Function argument: bq: ")
pprint(g.bq, use_unicode=False)
print("Meijer-G Function argument: bother: ")
pprint(g.bother, use_unicode=False)

# Meijer-G function generalizes many other named functions.
# We can use 'expand_func' or 'hyperexpand' to rewrite the
# Meijer-G function as other special functions, e.g., 
from sympy import expand_func, S
from sympy.simplify.hyperexpand import hyperexpand

print("Let's expand a couple of Meijer-G Functions:\n")

print("Exponential function <== ==> Meijer-G([[],[]], [[0],[]], -x): ")
expand_func(meijerg([[],[]], [[0],[]], -x))              # exp(x)
print("Trigonometric (sine) function <== ==> Meijer-G([[],[]], [[S(1)/2],[0]], (x/2)**2)): ")
hyperexpand(meijerg([[],[]], [[S(1)/2],[0]], (x/2)**2))  # sin(x)/sqrt(pi)

# Numerical Meijer-G function evaluation
## Set parameters as 4 separate vectors
#####     mpmath.meijerg([[], [-1/(k-1)], [0, 0], []], -p/k2)
## Set parameters as a tensor, i.e., as two nested vectors
#####     meijerg([(1, 2), (3, 4)], ([5], Tuple()), x)
p = 1
k = 0.1
k2 = 2

a1 = 0
a2 = 0

b1 = 0
b2 = 0.5

meijerGFunctionValue = mpmath.meijerg([[],[]], [[b1],[b2]], (p/2)**2)
cosineFunctionValue = (math.cos(p)/math.sqrt(math.pi))
# print(mpmath.meijerg([[], [-1/(k-1)], [0, 0], []], -p/k2))
print("Meijer-G Function value: ", meijerGFunctionValue, " <== ? ==> Cosine function value: ", cosineFunctionValue)

# See other examples here:
# http://lidavidm.github.io/sympy/_modules/sympy/functions/special/hyper.html
```


```{python}
# import the necessary python packages and sub-packages
import sympy
import math 
import mpmath
from sympy import pprint

p = 1
k = 0.1
k2 = 2
print("Evaluating the Meijer-G Function (Complex number): ", sympy.functions.special.hyper.meijerg([], [-1/(k-1)], [0, 0], [], -p/k2).evalf())

# print(mpmath.meijerg([[], [-1/(k-1)], [0, 0], []], -p/k2))
print("Meijer-G Function value: ", mpmath.meijerg([[],[]], [[0],[0.5]], (1/2)**2), " <== ? ==> Cosine function value: ", (math.cos(1)/math.sqrt(math.pi)))
```




# References

[1] Alaa, Ahmed M. and van der Schaar,  Mihaela. (2019) "Demystifying black-box models with symbolic metamodels." Advances in Neural Information Processing Systems (NeurIPS 2019), 32(6036).

[2] Beals, Richard, and Jacek Szmigielski. "Meijer-G-functions: a gentle introduction." Notices of the AMS 60.7 (2013): 866-872.

[3] Olver, F.W.J., Lozier, D.W., Boisvert, R.F., Clark, C.W. (2010) NIST Handbook of Mathematical Functions, ISBN 9780521192255, Cambridge University Press.

[4] Coelho, C. A., & Arnold, B. C. (2019). Finite form representations for Meijer-G and fox H functions. Cham, Switzerland: Springer International Publishing.

[5] Dinov, ID and Velev, MV. (2021) Data Science: Time Complexity, Inferential Uncertainty, and Spacekime Analytics, De Gruyter, STEM Series, ISBN 978-3-11-069780-3, DOI 10.1515/9783110697827. 


<!--html_preserve-->
<div>
    	<footer><center>
			<a href="https://www.socr.umich.edu/">SOCR Resource</a>
				Visitor number <img class="statcounter" src="https://c.statcounter.com/5714596/0/038e9ac4/0/" alt="Web Analytics" align="middle" border="0">
				<script type="text/javascript">
					var d = new Date();
					document.write(" | " + d.getFullYear() + " | ");
				</script> 
				<a href="https://socr.umich.edu/img/SOCR_Email.png"><img alt="SOCR Email"
	 			title="SOCR Email" src="https://socr.umich.edu/img/SOCR_Email.png"
	 			style="border: 0px solid ;"></a>
	 		 </center>
	 	</footer>

	<!-- Start of StatCounter Code -->
		<script type="text/javascript">
			var sc_project=5714596; 
			var sc_invisible=1; 
			var sc_partition=71; 
			var sc_click_stat=1; 
			var sc_security="038e9ac4"; 
		</script>
		
		<script type="text/javascript" src="https://www.statcounter.com/counter/counter.js"></script>
	<!-- End of StatCounter Code -->
	
	<!-- GoogleAnalytics -->
		<script src="https://www.google-analytics.com/urchin.js" type="text/javascript"> </script>
		<script type="text/javascript"> _uacct = "UA-676559-1"; urchinTracker(); </script>
	<!-- End of GoogleAnalytics Code -->
</div>
<!--/html_preserve-->
