simplify

simplify(mapper_fn)

Wraps a mapper function so that it simplifies the operator it returns.

Simplifying merges duplicate Pauli terms and, as a side effect, sorts the terms into a canonical order. That order is worth asking for explicitly in two situations:

  1. The term order an unsimplified mapper produces is not guaranteed to be stable between runs, because the operators of the Rust core do not preserve the order their terms were added in. A product formula synthesizes the terms in the order it receives them, so an unsimplified mapper can yield a different (though equally valid) circuit each time. Simplifying pins it.

  2. It merges terms that map to the same Pauli string, which shortens the synthesized circuit when a mapper produces such duplicates.

Use it to wrap any MapperFunction:

MapperFnEvolutionSynthesis(simplify(jordan_wigner))
Parameters:

mapper_fn (Callable[[OperatorTrait, int], SparseObservable]) – the mapper function to wrap.

Returns:

A mapper function that simplifies whatever mapper_fn returns.

Return type:

Callable[[OperatorTrait, int], SparseObservable]