Skip to content

workbench_algorithms.utils.trotter_utils

Utility functions for Trotterization.

get_ppr_args_from_ham

get_ppr_args_from_ham(ham_term)

Convenience to set up PPR arguments from a term in a PauliSum.

Parameters:

Name Type Description Default
ham_term tuple

A single term in a PauliSum, where the tuple is (coefficient, PauliMask).

required

Returns:

Type Description
list

The arguments we need to pass. In particular: angle (float), x_mask (int), z_mask (int).

cmnrs_analytic_bound

cmnrs_analytic_bound(
    hamiltonian, trotter_error, trotter_order=2
)

Analytic bound for the Trotter error.

Implementation of the "analytic" Trotter error bound in 1711.10980 (see Eqs. 61, 70 therein), with the modification that \(L*\Lambda\) is replaced with the sum of the coefficients of the Hamiltonian.

Parameters:

Name Type Description Default
hamiltonian PauliSum

The Hamiltonian for which the number of Trotter steps is to be estimated.

required
trotter_error float

The allowable Trotter error.

required
trotter_order int

The order of the Trotterization.

2

Returns:

Type Description
int

An upper bound on the number of Trotter steps required to reach precision given by trotter_error.

cmnrs_minimized_bound

cmnrs_minimized_bound(
    hamiltonian,
    trotter_error,
    trotter_order=2,
    max_exponent=100,
)

Calculate the minimized Trotter error commutator bound.

Implementation of the "minimized" Trotter error bound in 1711.10980 (see Eq. 73, 74 therein), by performing binary search over the number of trotter_steps in _cmnrs_min_func_log.

Parameters:

Name Type Description Default
hamiltonian PauliSum

The Hamiltonian for which the number of Trotter steps is to be estimated.

required
trotter_error float

The allowable Trotter error.

required
trotter_order int

The order of the Trotterization. Defaults to trotter_order = 2.

2
max_exponent int

The maximum exponent over which binary search is to be performed; i.e. the maximum number of Trotter steps that is returned is bounded by 2^max_exponent. Defaults to max_exponent = 100.

100

Returns:

Type Description
int

An upper bound on the number of Trotter steps required to reach precision given by trotter_error.

cmnrs_commutator_1

cmnrs_commutator_1(
    hamiltonian,
    trotter_error,
    max_exponent=100,
    verbose=False,
    mc=False,
    num_trials=100,
)

Commutator bound for first order Trotterization.

Returns the first order commutator bound in 1711.10980, by performing binary search over the number of trotter_steps in _cmnrs_commutator_func.

Parameters:

Name Type Description Default
hamiltonian PauliSum

The Hamiltonian for which the number of Trotter steps is to be estimated.

required
trotter_error float

The allowable Trotter error.

required
max_exponent int

The maximum exponent over which binary search is to be performed; i.e. the maximum number of Trotter steps that is returned is bounded by 2^max_exponent. Defaults to max_exponent = 100.

100
verbose bool

Whether to output possibly useful debugging and timing data.

False
mc bool

If False, evaluates the bound explicitly; if True, attempts a Monte Carlo estimate. Defaults to mc = False.

False
num_trials int

The number of trials to run if mc = True. Defaults to num_trials = 100.

100

Returns:

Type Description
int

An upper bound on the number of Trotter steps required to reach precision given by trotter_error.

Note

This bound is only applicable to first order Trotterization.

bounded_num_trotter_steps

bounded_num_trotter_steps(
    hamiltonian, trotter_error, verbose=False
)

Calculates Google's second order commutator bound for Trotterization.

Calculates Eq. (6) from 1902.10673; i.e. returns an upper bound on the number of Trotter steps needed to reach an allowable error given by trotter_error.

Parameters:

Name Type Description Default
hamiltonian PauliSum

The Hamiltonian for which the number of Trotter steps is to be estimated.

required
trotter_error float

The allowable Trotter error.

required
verbose bool

Whether to output possibly useful debugging and timing data.

False

Returns:

Type Description
int

An upper bound on the number of Trotter steps required to reach precision given by trotter_error.

Note

This bound is only applicable to second order Trotterization.