Skip to main content

jaxbessel

Differentiable Bessel functions of the first kind in JAX: cylindrical $J_n(x)$, spherical $j_n(x)$, and $J_\nu(x)/x^\nu$ for real orders $-1/2 < \nu \le 12$. It depends only on jax and numpy.

pip install jaxbessel
from jaxbessel import bessel_jn, bessel_jv_over_xv, j0, j1, spherical_bessel_jn

bessel_jn(4, x)               # J_0(x) ... J_4(x), stacked along the first axis
spherical_bessel_jn(4, x)     # j_0(x) ... j_4(x), likewise
bessel_jv_over_xv(1.25, x)    # J_{5/4}(x) / x^{5/4}, regular at x = 0
  • j0 and j1 follow the CEPHES rational approximations.
  • bessel_jn(n, x) returns every order up to n. It uses upward recurrence where that is stable ($|x| \ge n + 2$) and a folded trapezoidal sum of Bessel's integral (arXiv:2206.05334) below that.
  • spherical_bessel_jn(n, x) does the same for $j_n$, with Gauss-Legendre quadrature of $j_m(x) = \frac{(-i)^m}{2}\int_{-1}^{1} e^{ixt} P_m(t),dt$ below the switch.
  • Both agree with scipy.special to about 1e-14 in float64.
  • bessel_jv_over_xv(nu, x) is the kernel of the visibility of a stellar disk whose brightness is a power of $\mu$ (Quirrenbach et al. 1996, A&A 312, 160, eq. 3), needed for orders such as $5/4$ in the square-root limb-darkening law. It uses Gauss-Gegenbauer quadrature of Poisson's integral for $|x| < 14$ and Hankel's asymptotic expansion above, and agrees with scipy.special.jv(nu, x) / x**nu to about 1e-11 of its envelope in float64 for $-1/2 < \nu \le 12$; higher orders are refused, as the fixed switch is too low for the asymptotic expansion there. Its derivative is $-x,J_{\nu+1}(x)/x^{\nu+1}$.
  • Derivatives use custom JVP rules from the recurrence identities ($J_m' = (J_{m-1} - J_{m+1})/2$, $j_m' = (m,j_{m-1} - (m+1),j_{m+1})/(2m+1)$ and the one above), so jax.grad, jax.jacfwd, jax.jacrev and jax.hessian work to any order and are finite everywhere, including at $x = 0$.
  • Works with and without jax_enable_x64: outputs follow the argument's dtype.

Used by virgil and harmonix. The JAX translation of CEPHES j0/j1, and the original spherical Bessel functions this package replaces, come from Shashank Dholakia's harmonix.

Tests

pip install -e ".[dev]"
pytest

Licence

BSD 3-Clause; see LICENSE.

Metadata

Release files for jaxbessel 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jaxbessel 0.2.0
File Size Uploaded
jaxbessel-0.2.0.tar.gz 16.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jaxbessel 0.2.0
File Interpreter ABI Platform
jaxbessel-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.7 kB

Release files / jaxbessel-0.2.0.tar.gz

Download URL jaxbessel-0.2.0.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9dac8aa5a6b25ba0ac754f5a70dbc1b87100ea9104364e11639cea98b222bbd0
BLAKE2b-256 checksum
How to use checksums
f4758aa41197e0cbcf99fca5316b82e276f2e26255eeacbde6a439ca9915091f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / jaxbessel-0.2.0-py3-none-any.whl

Download URL jaxbessel-0.2.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90774297d2040ac0553c0d25827a906a39946f88a6df0c21d7ae786a3bda8b61
BLAKE2b-256 checksum
How to use checksums
5c8f710e35de1866bd0561214dd49a35c0c11c5b4ebfe1a4be9a23764448f803
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page