qml.labs.trotter_error.Fragment

class Fragment[source]

Bases: ABC

Abstract class used to define a fragment object for product formula error estimation.

A Fragment is an object that has a well-defined notion of a commutator. To ensure the existence of commutators, the implementation requires the following arithmetic dunder methods:

  • __add__(): implements addition

  • __mul__(): implements multiplication

  • __matmul__(): implements matrix multiplication

In addition to the arithmetic operators, a norm method should be defined. The norm is required to compute error estimates of Trotter error operators.

apply(state)

Apply the Fragment to a state on the right.

expectation(left, right)

Return the expectation value of a state.

norm(params)

Compute the norm of the fragment.

abstract apply(state)[source]

Apply the Fragment to a state on the right. The type of state is determined by each class inheriting from Fragment.

Parameters:

state (AbstractState) – an object representing a quantum state

Returns:

the result of applying the Fragment to state

Return type:

AbstractState

expectation(left, right)[source]

Return the expectation value of a state. The type of state is determined by each class inheriting from Fragment.

Parameters:
  • left (AbstractState) – the state to be multiplied on the left of the Fragment

  • right (AbstractState) – the state to be multiplied on the right of the Fragment

Returns:

the expectation value obtained by applying Fragment to the given states

Return type:

float

abstract norm(params)[source]

Compute the norm of the fragment.

Parameters:

params (Dict) – A dictionary of parameters needed to compute the norm. It should be specified for each class inheriting from Fragment.

Returns:

the norm of the Fragment

Return type:

float