mlx-airy
GPU-accelerated Airy functions for Apple Silicon using MLX.
Neither MLX nor JAX currently provide Airy functions (see JAX issue #25244). This package fills that gap for the MLX ecosystem.
What are Airy functions?
Airy functions Ai(x) and Bi(x) are the two linearly independent solutions to the Airy differential equation:
y'' - x y = 0
They appear throughout physics and engineering:
- Quantum mechanics -- WKB connection formulas, tunneling through linear potentials
- Optics -- diffraction near caustics, rainbow scattering
- Fluid dynamics -- boundary layers, Stokes phenomena
- Astrophysics -- gravitational lensing near fold caustics
Installation
pip install -e ".[test,benchmark]"
Requires Python >= 3.10 and Apple Silicon (MLX).
Usage
import mlx.core as mx
from mlx_airy import airy
x = mx.linspace(-15.0, 15.0, 10000)
ai, aip, bi, bip = airy(x) # Ai(x), Ai'(x), Bi(x), Bi'(x)
All four functions are returned in a single call, matching the
scipy.special.airy convention.
Implementation
| Region | Method | Reference |
|---|---|---|
| |x| < 5 | Taylor series (50 terms, Horner) | DLMF 9.4 |
| x >= 5 | Asymptotic expansion | DLMF 9.7.5--9.7.8 |
| x <= -5 | Oscillatory asymptotic | DLMF 9.7.9--9.7.12 |
Computation is float32 throughout, running entirely on the Apple GPU.
Tests
pytest tests/ -v
Benchmark
python -m mlx_airy.benchmark
Compares accuracy and throughput against scipy.special.airy.
Measured on Apple M1 Max (MLX 0.31.1, SciPy 1.16.2, float32),
x in [-15, 15], all four outputs (Ai, Ai', Bi, Bi'):
| N | scipy (ms) | mlx (ms) | Speedup |
|---|---|---|---|
| 1,000 | 3.30 | 32.07 | 0.1x |
| 10,000 | 15.76 | 31.65 | 0.5x |
| 100,000 | 147.69 | 35.55 | 4.2x |
| 1,000,000 | 1393.08 | 209.09 | 6.7x |
mlx-airy wins above ~30-50k points, where the Metal dispatch cost is
amortised; below that, scipy's vectorised C path is faster. Worst-case
float32 relative error is ~3e-4. Full numbers in
benchmark_results.md.
Author
Sheng-Kai Huang (akai@fawstudio.com)
License
MIT
Metadata
Release files for mlx-airy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mlx_airy-0.1.1.tar.gz | 21.5 kB | Without provenance | Details for mlx_airy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mlx_airy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for mlx_airy-0.1.1-py3-none-any.whl |
Total release size: 40.4 kB
Release files / mlx_airy-0.1.1.tar.gz
| Download URL | mlx_airy-0.1.1.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ace8a3a2b597e081b0ef3e82925cf5a30d82bf1bf609d4fd979fcdae367b3cc
|
|
BLAKE2b-256 checksum How to use checksums |
d28d6757fcbed4b148cf578577b5b16731b8c6718a10af65d2fa0d91eac1ced6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / mlx_airy-0.1.1-py3-none-any.whl
| Download URL | mlx_airy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
491de84214f17a0d362ca74056450db0a937eb060d2c48066439206c96309db1
|
|
BLAKE2b-256 checksum How to use checksums |
047d69841570a2639b38f4f9f10096da1d0f231a7291338aa2ba032954568fec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for mlx-airy 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.