B-Series
This module allows for the symbolic manipulation and evaluation of truncated B-Series on unlabelled trees, for an ODE of the form
Given a weights function \(\varphi\), the associated truncated B-Series is
where the sum runs over all trees of order at most \(n\), \(\sigma(t)\) is the symmetry factor of a tree, and \(F(t)(y_0)\) are the elementary differentials, defined recursively on trees by:
The main objective of this module is to evaluate existing B-series. For more complicated operations, it is recommended to work with the underlying character (or elementary weights function) and then construct a B-series from the result. For example, take the following B-series corresponding to the Euler and RK4 schemes:
import kauri as kr
y1 = sp.symbols('y1')
y = sp.Matrix([y1])
f = sp.Matrix([y1 ** 2])
bs1 = kr.BSeries(y, f, kr.euler.elementary_weights_map(), 5)
bs2 = kr.BSeries(y, f, kr.rk4.elementary_weights_map(), 5)
At the level of the underlying characters, the composition of two B-series is given by the BCK product of the characters, so one can get the composition by doing
bs_composition = kr.BSeries(y, f, bs2.weights * bs1.weights, 5)
Similarly the inverse B-series for the Euler scheme is given by
bs_inverse = kr.BSeries(y, f, bs1.weights ** (-1), 5)
and the symmetric-adjoint method is given by
bs_adjoint = kr.BSeries(y, f, bs1.weights ** (-1) & kr.sign, 5)
where kr.sign is the Map sending t to (-1)^|t| * t.
- elementary_differential(tree: Tree, f: sp.Matrix, y: sp.Matrix) sp.Matrix[source]
Returns the elementary differential of a vector field. These are defined recursively on trees by:
\[F(\emptyset) = y,\]\[F(\bullet) = f(y),\]\[F([t_1, t_2, \ldots, t_k])(y) = f^{(k)}(y)(F(t_1)(y), F(t_2)(y), \ldots, F(t_k)(y)).\]- Parameters:
tree (Tree) – Unlabelled tree corresponding to the elementary differential
f (sympy.Matrix) – Vector field
y (sympy.Matrix) – Symbolic variables y
Example usage:
- class BSeries(y, f, weights: Map, order: int)[source]
This class allows for the symbolic manipulation and evaluation of truncated B-Series on unlabelled trees, for a given vector field f. Given a weights function \(\varphi\), the associated truncated B-Series is
\[B_h(\varphi, y_0) := \sum_{|t| \leq n} \frac{h^{|t|}}{\sigma(t)} \varphi(t) F(t)(y_0),\]where the sum runs over all trees of order at most \(n\).
- Parameters:
y (sympy.Matrix) – Symbolic variables y
f (sympy.Matrix) – Vector field
weights (kauri.Map) – The weights function \(\varphi\) corresponding to the B-Series.
order (int) – The truncation order of the B-Series
Example usage:
- __call__(y: list, h: int | float) list[source]
Evaluates the B-series at the given values for y and h.
- Parameters:
y (list) – List of values to substitute for y
h (int | float) – Value to substitute for the step size h
- Returns:
Value of the B-series evaluated for the given values of y and h
- Return type:
list