A Python package, published on PyPI, that computes the Lyapunov spectrum of a dynamical system described by differential equations or discrete maps.

Stack: Python, NumPy, Numba, SciPy, Sphinx.

Why

To tell whether a system is chaotic you look at its Lyapunov exponents, which measure how fast two nearby trajectories drift apart. Computing them in plain Python is slow. I wrote the package during my physics studies in Pisa, between July 2021 and August 2022, and published it in case it helps other students.

Trajectory of the Lorenz system, used as an example

How it works

  1. 01

    The method

    Benettin's method, as described by Sandri (1996), using the variational matrix.

  2. 02

    The interface

    You call computeLE with the function, its Jacobian and the initial condition. For continuous time it uses fourth-order Runge-Kutta, for maps the step of the function; a transient phase is optional. It returns the spectrum over time and the solution.

  3. 03

    A Numba version

    Next to the Python one there is a version compiled with Numba. The repository has no benchmark, so I give no figures.

  • What I did

    The whole package, on my own: about 300 lines of Python, 50 commits, Sphinx documentation on Read the Docs, an example notebook and automated tests on Travis CI.

  • Status

    Finished in August 2022. Public on GitHub, with 5 stars. I know of no real users besides myself.