JAX-native Lyapunov exponent computation for ODEs and DDEs.
Project description
lyapax
JAX-native Lyapunov exponent computation for ODEs and DDEs, via the
Benettin/QR method with jax.jvp/jax.vmap tangent propagation.
Install
pip install lyapax
For development (running the test suite or examples), install from a clone instead:
pip install -e ".[dev]" # core + pytest/scipy for the test suite
pip install -e ".[examples]" # + matplotlib, to run examples/
Requires jax>=0.10, Python >=3.10.
Enable float64 before anything else. Lyapunov exponents are averages of
log-growth rates accumulated over many steps; JAX's default float32
silently degrades long-horizon estimates. Do this first, before creating
any jax.numpy arrays:
import jax
jax.config.update("jax_enable_x64", True)
lyapunov_spectrum/lyapunov_spectrum_dde warn if called with a float32
state0 and x64 is off.
Minimal example
import jax
jax.config.update("jax_enable_x64", True)
import jax.numpy as jnp
from lyapax import lyapunov_spectrum, rk4_step
from lyapax import systems
rhs = systems.lorenz(sigma=10.0, rho=28.0, beta=8.0 / 3.0)
step = rk4_step(rhs, dt=1e-2)
result = lyapunov_spectrum(
step, state0=jnp.array([1.0, 1.0, 1.0]),
dt=1e-2, n_steps=50_000, renorm_every=10, t_transient=100.0,
)
print(result.exponents) # ~ [0.906, 0.0, -14.57]
result.history gives the running per-column estimate at each
renormalization point, for checking convergence.
Method and scope
lyapunov_spectrum propagates a (d, k) matrix of tangent vectors
alongside the trajectory via jax.jvp (one forward-mode pass per tracked
column, batched with jax.vmap), QR-decomposes it every renorm_every
steps, accumulates log|diag(R)|, and divides by elapsed time
(Benettin's method). k defaults to the full spectrum (k = d); cost
scales with k, not d, so partial spectra of high-dimensional systems
are cheap.
lyapunov_spectrum_dde generalizes this to fixed-delay DDEs by
differentiating through an augmented (state, ring_buffer) carry.
What this does not do:
- No adaptive/stiff ODE solvers.
step_fnis whatever fixed-step map you hand it (rk4_step/euler_stepinlyapax.integrators, or Euler/ Heun vialyapax.simulator). Exponents are for the numerical time-dtmap, not an exact flow — checkdt-convergence for anything you report. - DDE delays are integer-step only. A physical delay
tauis rounded to the nearest multiple ofdt(lyapax.dde.resolve_tau_steps); there is no sub-step interpolation. Uselyapax.dde.tau_effto see the delay actually used, and shrinkdtto converge it towardtau. historycolumns are ordered once, by the final row. Near- degenerate exponents can swap order over the run — seeLyapunovResult.history's docstring.
Examples
Runnable, sphinx-gallery-formatted demos in examples/ (pip install -e ".[examples]", then python examples/plot_01_linear_ode.py):
| File | Task |
|---|---|
plot_00_time_series_sanity_check.py |
Inspecting the raw simulated time series before computing exponents |
plot_01_linear_ode.py |
Exact-eigenvalue sanity check for the QR engine |
plot_02_chaotic_maps.py |
1D/2D maps with closed-form exponents |
plot_03_chaotic_flows.py |
Lorenz/Rössler, the standard chaotic-ODE benchmarks |
plot_04_linear_network.py |
Coupled network vs. exact Jacobian eigenvalues |
plot_05_kuramoto_sync.py |
Kuramoto network synchronization transition |
plot_06_custom_coupling.py |
Writing a custom coupling function |
plot_07_speed_and_accuracy.py |
Cost/accuracy tradeoffs across settings |
plot_08_delayed_coupling.py |
Two-node linear DDE network vs. delay |
plot_09_kuramoto_delayed_network.py |
Effect of transmission delay on a Kuramoto network |
plot_10_matrix_free_scaling.py |
Dense jacfwd vs. jvp/vmap, and why it matters for partial spectra |
plot_11_vmap_parameter_sweep.py |
Batched parameter sweeps via jax.vmap |
Further reading
notes/milestones.md— design history and open risks.notes/validation_systems.md— the correctness tests this package is held to (exact values, structural invariants, literature figures).notes/benchmark_report.md— comparison againstjitcode/jitcddeandChaosTools.jl.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lyapax-0.1.0.tar.gz.
File metadata
- Download URL: lyapax-0.1.0.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c7a25db2a47808da62757f7a8f10ce60cded652aef67228f8ad61c7b1f81c89
|
|
| MD5 |
a67ce49fdab330c5150ad7e517ed821b
|
|
| BLAKE2b-256 |
7c0d7a7a88e71c99f5b4ce527d6c4e103b4cf36017326e8355896a437460ad05
|
Provenance
The following attestation bundles were made for lyapax-0.1.0.tar.gz:
Publisher:
publish.yml on Ziaeemehr/lyapax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lyapax-0.1.0.tar.gz -
Subject digest:
5c7a25db2a47808da62757f7a8f10ce60cded652aef67228f8ad61c7b1f81c89 - Sigstore transparency entry: 2059208286
- Sigstore integration time:
-
Permalink:
Ziaeemehr/lyapax@b6774619d62af170f0ee39f4aa107ef9c65e6a5b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Ziaeemehr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6774619d62af170f0ee39f4aa107ef9c65e6a5b -
Trigger Event:
release
-
Statement type:
File details
Details for the file lyapax-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lyapax-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
450a446f1c3b6121fdb65a827d8aab8303a63ffbde254dc35fd4c022905d742c
|
|
| MD5 |
dc3303b0eed541308a61c25556fe36bf
|
|
| BLAKE2b-256 |
3d26daf6b951f669be5d5f9edf92c25834262dd30a7f68fddcfcba6ed9099668
|
Provenance
The following attestation bundles were made for lyapax-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Ziaeemehr/lyapax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lyapax-0.1.0-py3-none-any.whl -
Subject digest:
450a446f1c3b6121fdb65a827d8aab8303a63ffbde254dc35fd4c022905d742c - Sigstore transparency entry: 2059208565
- Sigstore integration time:
-
Permalink:
Ziaeemehr/lyapax@b6774619d62af170f0ee39f4aa107ef9c65e6a5b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Ziaeemehr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6774619d62af170f0ee39f4aa107ef9c65e6a5b -
Trigger Event:
release
-
Statement type: