qpe_toolbox.hamiltonian.trotterization

Trotter-Suzuki decompositions of Hamiltonian time evolution, as MPOs or gate sequences.

Functions

exp_Pauli_string_as_MPO(term, dt, n_qubits)

Construct the MPO representation of the unitary exponential of a Pauli string.

trotter1_approx_as_MPO(hamiltonian, dt, *[, cutoff, ...])

Construct the first-order Trotter-Suzuki approximation as a Matrix Product Operator (MPO).

trotter2_approx_as_MPO(hamiltonian, dt, *[, cutoff, ...])

Construct the second-order symmetric Trotter-Suzuki approximation as an MPO.

trotter4_approx_as_MPO(hamiltonian, dt, *[, cutoff, ...])

Construct the fourth-order Trotter-Suzuki approximation as an MPO.

trotter_approx_as_MPO(hamiltonian, dt, *[, ...])

Construct a Trotter-Suzuki approximation of a Hamiltonian evolution operator as an MPO.

rotation_gates(term, dt, qubit_reg)

Generate a gate sequence for exponentiating a Pauli-string term.

Module Contents

qpe_toolbox.hamiltonian.trotterization.exp_Pauli_string_as_MPO(term, dt, n_qubits)[source]

Construct the MPO representation of the unitary exponential of a Pauli string.

Given a Hamiltonian term of the form:

H = c * P

where c is a scalar coefficient and P is a tensor product of Pauli operators acting on a subset of qubits, this function builds the Matrix Product Operator (MPO) corresponding to:

exp(-i * dt * c * P)

using the identity:

exp(-i α P) = cos(α) I - i sin(α) P

where P^2 = I.

The Pauli string is expanded to the full system size by inserting identity operators on inactive qubits.

Parameters:
  • term (tuple) –

    A tuple (coeff, pauli_string, active_qubits) where:

    • coeff (float): Scalar coefficient multiplying the Pauli string.

    • pauli_string (str): String of Pauli operators (e.g. "ZYXXZ").

    • active_qubits (list[int]): Indices of qubits where the Pauli operators act. The length must match pauli_string.

  • dt (float) – Evolution time.

  • n_qubits (int) – Total number of qubits in the system.

Returns:

MPO, in 'lrud' order, representing the operator:

exp(-i * dt * coeff * P)

where P is the full Pauli string embedded in the n_qubits system.

Return type:

MatrixProductOperator

Raises:

ValueError – If the length of pauli_string does not match the number of active_qubits, or if active_qubits contains a repeated or out-of-range qubit.

qpe_toolbox.hamiltonian.trotterization.trotter1_approx_as_MPO(hamiltonian, dt, *, cutoff=1e-10, max_bond=None, reverse_order=False)[source]

Construct the first-order Trotter-Suzuki approximation as a Matrix Product Operator (MPO).

This function builds an MPO representation of the first-order product formula for the time-evolution operator

\[U(dt) \approx \prod_j e^{-i dt \, H_j},\]

where hamiltonian.terms = [H_0, H_1, ..., H_{m-1}] is a decomposition of the Hamiltonian into terms that can each be exponentiated individually as MPOs.

Parameters:
  • hamiltonian (Hamiltonian) – Includes Pauli strings, positions and couplings.

  • dt (float) – Time step used in the Trotter approximation.

  • cutoff (float, optional) – Singular value truncation threshold used during MPO compression. Default is 1e-10.

  • max_bond (int, optional) – Maximum allowed bond dimension during MPO compression. Default is None (no limit).

  • reverse_order (bool, optional) – If False (default), terms are applied in forward order. If True, terms are applied in reverse index order.

Returns:

MPO representation of the first-order Trotter approximation.

Return type:

MatrixProductOperator

qpe_toolbox.hamiltonian.trotterization.trotter2_approx_as_MPO(hamiltonian, dt, *, cutoff=1e-10, max_bond=None, verbosity=0)[source]

Construct the second-order symmetric Trotter-Suzuki approximation as an MPO.

This function builds the second-order product formula

\[U(dt) \approx U_1(dt/2)\,U_1^{\mathrm{rev}}(dt/2),\]

where \(U_1\) is the first-order Trotter approximation and \(U_1^{\mathrm{rev}}\) uses the reverse operator ordering.

Parameters:
  • hamiltonian (Hamiltonian) – Includes Pauli strings, positions and couplings.

  • dt (float or complex) – Time step used in the Trotter approximation.

  • cutoff (float, optional) – Singular value truncation threshold used during MPO compression. Default is 1e-10.

  • max_bond (int, optional) – Maximum allowed bond dimension during MPO compression. Default is None (no limit).

  • verbosity (int, default 0) – Verbosity level. If >= 1, print progress.

Returns:

MPO representation of the second-order Trotter approximation.

Return type:

MatrixProductOperator

qpe_toolbox.hamiltonian.trotterization.trotter4_approx_as_MPO(hamiltonian, dt, *, cutoff=1e-10, max_bond=None, verbosity=0)[source]

Construct the fourth-order Trotter-Suzuki approximation as an MPO.

This function implements the standard symmetric fourth-order composition

\[U_4(dt) = U_2(s\,dt)\, U_2((1 - 2s)\,dt)\, U_2(s\,dt),\]

where \(U_2\) is the second-order Trotter approximation and

\[s = \frac{1}{2 - 2^{1/3}}\]

is the symmetry factor.

Parameters:
  • hamiltonian (Hamiltonian) – Includes Pauli strings, positions and couplings.

  • dt (float) – Time step used in the Trotter approximation.

  • cutoff (float, optional) – Singular value truncation threshold used during MPO compression. Default is 1e-10.

  • max_bond (int, optional) – Maximum allowed bond dimension during MPO compression. Default is None (no limit).

  • verbosity (int, default 0) – Verbosity level. If >= 1, print progress.

Returns:

MPO representation of the fourth-order Trotter approximation.

Return type:

MatrixProductOperator

qpe_toolbox.hamiltonian.trotterization.trotter_approx_as_MPO(hamiltonian, dt, *, trotter_order=1, cutoff=1e-10, max_bond=None, verbosity=0)[source]

Construct a Trotter-Suzuki approximation of a Hamiltonian evolution operator as an MPO.

This function dispatches to a specific Trotter-Suzuki decomposition according to the requested approximation order. The Hamiltonian is assumed to provide a decomposition into elementary terms through hamiltonian.terms.

Depending on trotter_order, the approximation is built using:

\[\begin{split}U(dt) \approx \begin{cases} \text{1st-order product formula}, & \text{if trotter\_order} = 1, \\ \text{2nd-order symmetric formula}, & \text{if trotter\_order} = 2, \\ \text{4th-order Suzuki formula}, & \text{if trotter\_order} = 4. \end{cases}\end{split}\]
Parameters:
  • hamiltonian (Hamiltonian) – Includes Pauli strings, positions and couplings.

  • dt (float) – Time step used in the Trotter approximation.

  • trotter_order ({1, 2, 4}, optional) – Order of the Trotter-Suzuki decomposition. Default is 1.

  • cutoff (float, optional) – Singular value truncation threshold used during MPO compression. Default is 1e-10.

  • max_bond (int, optional) – Maximum allowed MPO bond dimension during compression. Default is None (no limit).

  • verbosity (int, default 0) – Verbosity level. If >= 1, print progress.

Returns:

Compressed MPO representation of the Trotterized time-evolution operator.

Return type:

MatrixProductOperator

Raises:

ValueError – If the requested trotter_order is not implemented.

qpe_toolbox.hamiltonian.trotterization.rotation_gates(term, dt, qubit_reg)[source]

Generate a gate sequence for exponentiating a Pauli-string term.

Implements

\[e^{-i dt \theta P}\]

where \(P\) is a tensor product of Pauli operators and \(\theta\) is the associated coefficient in the term. The implementation uses basis rotations, CNOT chains, and a single RZ rotation.

Parameters:
  • term (tuple) – Hamiltonian term (theta, pauli_string, qubits).

  • dt (float) – Time step or Trotter slice.

  • qubit_reg (sequence of int) – Mapping from logical qubit indices to circuit qubits.

Returns:

Abstract quantum gate instructions suitable for circuit construction.

Return type:

list