Polynomial Module
The polynomial module provides comprehensive tools for manipulating multivariate polynomials in the 6D phase space of the circular restricted three-body problem.
Polynomial Representation
The polynomial representation uses a compressed monomial ordering scheme that stores multivariate polynomials as homogeneous components:
where each component \(p^{(i)}\) is represented by a dense coefficient array containing terms of degree \(i\). Polynomials are initialised for a given degree and are stored in lists containing the homogeneous terms up to the desired degree. For degree \(i\), the coefficient array has a size determined by the number of ways to choose from \(i\) items with replacement from a set of 6 variables:
For example, a degree 2 polynomial has \(\binom{2+5}{5} = 21\) terms.
The representation uses a bit-packing scheme where each multi-index, representing the exponents of a monomial, is encoded into a compact 32-bit integer. This encoding allocates six bits for each of five variables (\(q_2, q_3, p_1, p_2, p_3\)), with the sixth variable’s exponent (\(q_1\)) determined implicitly by the total degree constraint. This approach provides a memory-efficient representation while maintaining fast access patterns for polynomial operations.
The architecture of the polynomial system is built around three core components: the index table generation, the encoding and decoding mechanisms, and the algebraic operation kernels. The encoding system employs a dictionary-based lookup mechanism that provides constant-time access to coefficient positions, while the decoding system uses bitwise operations to extract individual exponents from the packed representation.
The index tables are precomputed combinatorial structures that map between the packed multi-index representation and the coefficient array positions. These tables consist of a combination count matrix that tracks the number of monomials for each degree and variable count, and a packed multi-index list that stores all valid exponent combinations for each degree. The tables are precomputed at initialisation.
The combinatorial (psi) table is a 2D array containing the monomial count per degree:
Where \(d\) is the degree of the monomial and \(i\) is the number of variables. The number of monomials increases significantly for higher degrees for the case \(i=6\).
The indices (clmo) table contains the packed multi-indices, where clmo[D] is the array of packed multi-indices for degree D, while an encode dictionary maps the packed indices to their array position.
The algebraic operations are implemented as Numba-accelerated kernels that operate directly on the coefficient arrays. The multiplication algorithm employs a parallel convolution-style approach where each thread accumulates partial results in private scratch arrays before a final reduction step combines the results. This design eliminates race conditions while maximizing parallel efficiency. The differentiation and integration operations leverage the packed multi-index representation to efficiently compute coefficient updates, while the Poisson bracket computation combines differentiation and multiplication operations in a specialized kernel that maintains the canonical structure of Hamiltonian systems.
The module is organized into several submodules:
- Polynomial Base Functions
- Polynomial Algebra Functions
- Polynomial Operations
- _polynomial_zero_list()
- _polynomial_variable()
- _polynomial_variables_list()
- _polynomial_add_inplace()
- _polynomial_multiply()
- _polynomial_power()
- _polynomial_poisson_bracket()
- _polynomial_clean()
- _polynomial_degree()
- _polynomial_total_degree()
- _polynomial_differentiate()
- _polynomial_jacobian()
- _polynomial_evaluate()
- _polynomial_integrate()
- _linear_variable_polys()
- _substitute_linear()
- _linear_affine_variable_polys()
- _substitute_affine()
- Polynomial Conversion Functions
- Polynomial Coordinate Functions