qp.labs.trotter_error.bch_expansion

bch_expansion(product_formula, max_order)[source]

Return the Baker–Campbell–Hausdorff (BCH) expansion of a product formula.

Computes the single-exponential generator equivalent to the given product formula, expanded in the Hall basis and truncated at max_order.

Parameters:
  • product_formula (ProductFormula) – the product formula to expand. May be a flat formula or a recursive composition of sub-formulas.

  • max_order (int) – the maximum commutator order (nesting depth) to retain in the expansion.

Returns:

a mapping from each retained Hall-basis commutator to its (nonzero) coefficient.

Return type:

dict[ASTNode, float]