Skip to content

Commit bb3504f

Browse files
committed
ENH: use quadax.quadgk in Riemann sheet notebook
* FIX: set correct LaTeX syntax in equation
1 parent b2af146 commit bb3504f

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

docs/usage/dynamics/riemann-sheets.ipynb

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"source": [
4141
"import warnings\n",
4242
"\n",
43+
"import jax.numpy as jnp\n",
4344
"import matplotlib.pyplot as plt\n",
44-
"import numpy as np\n",
4545
"import sympy as sp\n",
4646
"from IPython.display import Math\n",
4747
"from matplotlib_inline.backend_inline import set_matplotlib_formats\n",
@@ -166,7 +166,11 @@
166166
"cell_type": "markdown",
167167
"metadata": {},
168168
"source": [
169-
"The general form of the Chew--Mandelstam dispersion integral is the following:"
169+
"The general form of the Chew--Mandelstam dispersion integral is the following:\n",
170+
"\n",
171+
":::{margin}\n",
172+
"We set the {attr}`.ChewMandelstamIntegral.algorithm` to {func}`quadax.quadgk` for fast numerical evaluation over the complex plane. For higher precision close the the physical axis (at the cost of performance), choose {func}`quadax.romberg` instead. See also {doc}`integration-algorithms`.\n",
173+
"::::"
170174
]
171175
},
172176
{
@@ -176,7 +180,9 @@
176180
"outputs": [],
177181
"source": [
178182
"s, m1, m2, L = sp.symbols(\"s, m1, m2, L\", nonnegative=True)\n",
179-
"integral_expr = ChewMandelstamIntegral(s, m1, m2, L)\n",
183+
"integral_expr = ChewMandelstamIntegral(\n",
184+
" s, m1, m2, L, algorithm=\"quadax.quadgk\", configuration={\"order\": 61}\n",
185+
")\n",
180186
"integral_expr.doit(deep=False)"
181187
]
182188
},
@@ -274,14 +280,14 @@
274280
"Depending on the centre-of-mass energy, different Riemann sheets connect smoothly to the physical one. Therefore, two cases are studied: one where the resonance mass is above the threshold of the second and first channel, and another where the resonance mass is between the threshold of the first and second channel. For the 2 channel one gets:\n",
275281
"\n",
276282
"$$\n",
277-
"\\begin{eqnarray}\n",
283+
"\\begin{aligned}\n",
278284
"\\operatorname{Disc}_{\\mathrm{I,II}} \\varSigma_\\ell(s)\n",
279-
"&=& 2 i\\left[\\begin{array}{rr}\\rho_1 n_{\\ell,1}^2(s) & 0 \\\\ 0 & 0 \\end{array}\\right], \\\\\n",
285+
"\\; &= \\; 2 i\\begin{pmatrix}\\rho_1(s) \\, n_{\\ell,1}^2(s) & 0 \\\\ 0 & 0 \\end{pmatrix}, \\\\\n",
280286
"\\operatorname{Disc}_{\\mathrm{I,III}} \\varSigma_\\ell(s)\n",
281-
"&=& 2 i\\left[\\begin{array}{rr}\\rho_1 n_{\\ell,1}^2(s) & 0 \\\\ 0 & \\rho_2 n_{\\ell,2}^2(s) \\end{array}\\right], \\\\\n",
287+
"\\; &= \\; 2 i\\begin{pmatrix}\\rho_1(s) \\, n_{\\ell,1}^2(s) & 0 \\\\ 0 & \\rho_2(s) \\, n_{\\ell,2}^2(s) \\end{pmatrix}, \\\\\n",
282288
"\\operatorname{Disc}_{\\mathrm{I,IV}} \\varSigma_\\ell(s)\n",
283-
"&=& 2 i\\left[\\begin{array}{rr}0 & 0 \\\\ 0& \\rho_2 n_{\\ell,2}^2(s) \\end{array}\\right].\n",
284-
"\\end{eqnarray}\n",
289+
"\\; &= \\; 2 i\\begin{pmatrix}0 & 0 \\\\ 0& \\rho_2(s) \\, n_{\\ell,2}^2(s) \\end{pmatrix}.\n",
290+
"\\end{aligned}\n",
285291
"$$"
286292
]
287293
},
@@ -431,6 +437,7 @@
431437
"integral_p_wave_func = sp.lambdify(\n",
432438
" [s, m1, m2, integral_expr.epsilon],\n",
433439
" integral_expr.subs(L, L_val).doit(),\n",
440+
" modules=\"jax\",\n",
434441
")"
435442
]
436443
},
@@ -477,9 +484,9 @@
477484
},
478485
"outputs": [],
479486
"source": [
480-
"x = np.linspace(0, 6, num=150)\n",
481-
"y = np.linspace(1e-3, 1, num=40)\n",
482-
"X, Y = np.meshgrid(x, y)\n",
487+
"x = jnp.linspace(0, 6, num=200)\n",
488+
"y = jnp.linspace(5e-3, 1, num=60)\n",
489+
"X, Y = jnp.meshgrid(x, y)\n",
483490
"Zn = X - Y * 1j\n",
484491
"Zp = X + Y * 1j"
485492
]
@@ -581,7 +588,7 @@
581588
},
582589
"outputs": [],
583590
"source": [
584-
"x = np.linspace(2.2, 8, num=100)\n",
591+
"x = jnp.linspace(2.2, 8, num=100)\n",
585592
"ε_offset = 1e-2\n",
586593
"cn = x - ε_offset * 1j\n",
587594
"cp = x + ε_offset * 1j\n",
@@ -619,15 +626,6 @@
619626
"plt.show()"
620627
]
621628
},
622-
{
623-
"cell_type": "markdown",
624-
"metadata": {},
625-
"source": [
626-
":::{caution}\n",
627-
"The integral does not appear to be numerically stable (see [ComPWA/ampform#487](https://github.com/ComPWA/ampform/issues/487)), as a significant imaginary offset from the real axis ($\\epsilon = 10^{-2}i$) is required to get rid of the instability fluctuations.\n",
628-
":::"
629-
]
630-
},
631629
{
632630
"cell_type": "markdown",
633631
"metadata": {},
@@ -655,7 +653,7 @@
655653
},
656654
"outputs": [],
657655
"source": [
658-
"y = np.linspace(1e-8, 1, num=100)\n",
656+
"y = jnp.linspace(1e-4, 1, num=80)\n",
659657
"for s_value in (3.1, 3.7):\n",
660658
" Jn = s_value - y * 1j\n",
661659
" Jp = s_value + y * 1j\n",

0 commit comments

Comments
 (0)