This library implements Levin's method for integrals containing products of up to three spherical or cylindrical Bessel functions.
The installation has been tested on linux-based systems as well as Mac OS. For windows users, one would need to modify the setupy.py file accordingly.
The library is available via PyPi installation, so you can just install it using
pip install pylevinwhich installs the levin package and you are ready to go. Note that you need certain packages which you have to install via conda-forge, in particular you will need the GSL, BOOST and GXX (on some linux servers) to be installed. You can grab them all via
conda install -c conda-forge gsl
conda install -c conda-forge gxx_linux-64
conda install conda-forge::boostif they are not installed already.
Alternatively you first clone the directory via:
git clone git@github.com:rreischke/levin_bessel.gitThen navigate to the cloned directory
cd levin_bessel
conda env create -f conda_env.yaml
conda activate levin_env
pip install .On some Linux servers you will have to install gxx_linux-64 by hand and the installation will not work. This usually shows the following error message in the terminal:
gcc: fatal error: cannot execute 'cc1plus': execvp: No such file or directory
If this is the case just install it by typing
conda install -c conda-forge gxx_linux-64and redo the pip installation.
You can run pytest to test the installation.
Feel free to watch my recording for Cosmology from Home 2025 on YouTube for a brief tutorial and a general explanation of the method and summary of the corresponding paper.

There is a detailed documentation of the code on levin-bessel.readthedocs.io. For a tutorial, there is a detailed python notebook in the tutorial directory
If you want other types of oscillatory integrals implemented in pylevin, I am very happy to help navigating the code. Note that these integrals need to satisfy some kind recursion relation for their derivatives (Eq. 9 in the arxiv version of the paper). This relation can technically be numerical but requires very stable derivatives.
If you encounter any issue or need help with the code you can either open an issue directly on github, or drop me a mail to reischke@posteo.net.
If you use this code please cite the implementation described in 2502.12142. You can find references to the original method therein.