jaxbessel
Differentiable Bessel functions of the first kind in JAX: cylindrical $J_n(x)$
and spherical $j_n(x)$. It depends only on jax and numpy.
pip install jaxbessel
from jaxbessel import bessel_jn, 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
j0andj1follow the CEPHES rational approximations.bessel_jn(n, x)returns every order up ton. 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.specialto about 1e-14 in float64. - Derivatives use custom JVP rules from the recurrence identities
($J_m' = (J_{m-1} - J_{m+1})/2$ and
$j_m' = (m,j_{m-1} - (m+1),j_{m+1})/(2m+1)$), so
jax.grad,jax.jacfwd,jax.jacrevandjax.hessianwork 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 drpangloss 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.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jaxbessel-0.1.0.tar.gz | 13.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jaxbessel-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.7 kB
Release files / jaxbessel-0.1.0.tar.gz
| Download URL | jaxbessel-0.1.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b679acc2f82299b4f4a29c05ec1639c6a31b09422dcb79bfa390e41c969dc68
|
|
BLAKE2b-256 checksum How to use checksums |
4b2f1d8fb3dbf567bbb3c518292dee6147d1243c36febf56bea336526d54cacd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / jaxbessel-0.1.0-py3-none-any.whl
| Download URL | jaxbessel-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11f6bbf36e1b7eb79872dd764249f943619b1807b49a435ade0e874a72fb2a12
|
|
BLAKE2b-256 checksum How to use checksums |
dd86cf561d3bcddc52e17f10801ca1a9668f1ce1e0fd23860adc3a8d70130b49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|