Skip to main content

Hopf algebras, B-series, and Runge-Kutta methods on rooted trees

Project description

Logo

PyPI - Version PyPI - Downloads CI - Test Read the Docs License

Kauri is a Python package for symbolic and algebraic manipulation of rooted trees, with applications to B-series, Runge-Kutta methods, and backward error analysis. It implements multiple Hopf algebraic structures on both non-planar and planar rooted trees, and provides tools for symbolic computation, visualization, and numerical integration.

Installation

pip install kauri

The base install is lightweight (pure Python, no external dependencies) and provides tree algebra, enumeration, indexing, and Hopf algebraic operations.

For visualization, Runge-Kutta analysis, and B-series (requires matplotlib, numpy, scipy, sympy, tqdm):

pip install kauri[full]

Documentation

Full documentation is available at https://kauri.readthedocs.io

Features

Hopf algebras

Algebra Non-planar Planar
Butcher-Connes-Kreimer (BCK) kauri.bck kauri.nck
Grossman-Larson (GL) kauri.gl kauri.pgl
Calaque-Ebrahimi-Fard-Manchon (CEM) kauri.cem --
Munthe-Kaas-Wright (MKW) -- kauri.mkw

Each algebra provides: coproduct, counit, antipode, map_product, map_power. Additionally, kauri.gl and kauri.pgl provide product, and kauri.mkw provides shuffle_product.

Tree types

Non-planar (commutative) Planar (noncommutative)
Tree PlanarTree
Forest OrderedForest
ForestSum ForestSum
TensorProductSum TensorProductSum

Additional modules

  • B-series (BSeries) -- symbolic and numerical manipulation of truncated B-series
  • Runge-Kutta methods (RK) -- 15+ predefined methods with order verification, composition, and numerical integration
  • Commutator-free methods (CFMethod) -- Lie group integrators with planar order theory
  • Odd-even decomposition (oddeven, planar_oddeven) -- symmetric splitting of characters
  • Map algebra (Map) -- BCK/CEM convolution products, composition, exp/log
  • Tree generation -- enumeration of non-planar, planar, and coloured trees
  • SVG display -- inline visualization in Jupyter notebooks

Examples

BCK coproduct

import kauri as kr
import kauri.bck as bck

t = kr.Tree([[], [[]]])
cp = bck.coproduct(t)
kr.display(cp)
BCK coproduct example

Labelled BCK antipode

t = kr.Tree([[[3],2],[1],0])
s = bck.antipode(t)
kr.display(s)
BCK antipode example

Grossman-Larson coproduct

import kauri.gl as gl

t = kr.Tree([[], [[]]])
cp = gl.coproduct(t)
kr.display(cp)
GL coproduct example

CEM coproduct

import kauri.cem as cem

t = kr.Tree([[], [[]]])
cp = cem.coproduct(t)
kr.display(cp)
CEM coproduct example

NCK coproduct

import kauri.nck as nck

pt = kr.PlanarTree([[], [[]]])
cp = nck.coproduct(pt)
kr.display(cp)
NCK coproduct example

PGL product

import kauri.pgl as pgl

t1 = kr.PlanarTree([[]])
t2 = kr.PlanarTree([[], []])
p = pgl.product(t1, t2)
kr.display(p)
PGL product example

MKW coproduct

import kauri.mkw as mkw

pt = kr.PlanarTree([[], [[]]])
cp = mkw.coproduct(pt)
kr.display(cp)
MKW coproduct example

Trees of order 4

for t in kr.trees_of_order(4):
    kr.display(t)
Trees of order 4

Runge-Kutta order conditions

t = kr.Tree([[],[]])
print(kr.rk_order_cond(t, s=3, explicit=True))
a10**2*b1 + b2*(a20 + a21)**2 - 1/3

Truncated B-series of RK4

import sympy as sp

y1 = sp.symbols('y1')
y = sp.Matrix([y1])
f = sp.Matrix([y1 ** 2])

m = kr.rk4.elementary_weights_map()
bs = kr.BSeries(y, f, weights=m, order=5)
print(bs.series())

Odd-even decomposition

import kauri.oddeven as oddeven

# The square root of the identity in BCK convolution
sqrt_id = oddeven.id_sqrt

# Verify: sqrt_id * sqrt_id == identity
t = kr.Tree([[],[]])
print((sqrt_id * sqrt_id)(t))  # Same as kr.ident(t)

Modified equations and preprocessing

# Modified equation of a B-series method
phi = kr.rk4.elementary_weights_map()
mod_eq = phi.modified_equation()

# Preprocessed integrator
preprocessed = phi.preprocessed_integrator()

Citation

If you found this library useful in your research, please consider citing:

@misc{shmelev2025ees,
  title={Explicit and Effectively Symmetric Runge-Kutta Methods},
  author={Shmelev, Daniil and Ebrahimi-Fard, Kurusch and Tapia, Nikolas and Salvi, Cristopher},
  journal={arXiv:2507.21006},
  year={2025}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kauri-2.1.0.tar.gz (70.7 kB view details)

Uploaded Source

File details

Details for the file kauri-2.1.0.tar.gz.

File metadata

  • Download URL: kauri-2.1.0.tar.gz
  • Upload date:
  • Size: 70.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for kauri-2.1.0.tar.gz
Algorithm Hash digest
SHA256 6c27390b18305434dafe0e5c5830a2bc7c63bc3274b25e6c5edee1c1a335a065
MD5 a28101c3f580f155934e1eac363557d3
BLAKE2b-256 8782351768687c6287951ee21bc6008a5f2000eda475b8e37b53dd5d35dceb5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page