Time evolution builder ====================== The :class:`~qdk_chemistry.algorithms.TimeEvolutionBuilder` algorithm in QDK/Chemistry constructs quantum circuits that implement the Hamiltonian simulation unitary :math:`U(t) = e^{-iHt}`. Following QDK/Chemistry's :doc:`algorithm design principles <../design/index>`, it takes a :class:`~qdk_chemistry.data.QubitHamiltonian` and a time parameter as input and produces a :class:`~qdk_chemistry.data.TimeEvolutionUnitary` as output. Overview -------- Hamiltonian simulation — constructing the unitary :math:`U(t) = e^{-iHt}` — is a central subroutine in many quantum algorithms. The :class:`~qdk_chemistry.algorithms.TimeEvolutionBuilder` provides a unified interface for methods that construct this operator from a :class:`~qdk_chemistry.data.QubitHamiltonian`. QDK/Chemistry currently provides Trotter-Suzuki product formulas for this task. These decompose :math:`e^{-iHt}` into a sequence of elementary Pauli rotations :math:`e^{-i\theta P}` that can be directly implemented as quantum gates, with controllable approximation error via the Trotter order and number of time divisions :cite:`Suzuki1992`. The resulting :class:`~qdk_chemistry.data.TimeEvolutionUnitary` objects wrap a ``PauliProductFormulaContainer`` — a list of exponentiated Pauli terms with a repetition count. Using the TimeEvolutionBuilder ------------------------------ .. note:: This algorithm is currently available only in the Python API. This section demonstrates how to create, configure, and run a time evolution builder. The ``run`` method returns a :class:`~qdk_chemistry.data.TimeEvolutionUnitary` object that can be used by any algorithm that requires a Hamiltonian simulation unitary (e.g., :doc:`PhaseEstimation `). Input requirements ~~~~~~~~~~~~~~~~~~ The :class:`~qdk_chemistry.algorithms.TimeEvolutionBuilder` requires the following inputs: QubitHamiltonian A :class:`~qdk_chemistry.data.QubitHamiltonian` containing the Pauli-string representation of the Hamiltonian. This can be obtained from the :doc:`QubitMapper ` algorithm, constructed from a :doc:`model Hamiltonian <../model_hamiltonians>`, or built directly. Time A float specifying the evolution time :math:`t` in :math:`U(t) = e^{-iHt}`. .. rubric:: Creating a builder .. tab:: Python API .. literalinclude:: ../../../_static/examples/python/time_evolution_builder.py :language: python :start-after: # start-cell-create :end-before: # end-cell-create .. rubric:: Configuring settings Settings vary by implementation. See `Available implementations`_ below for implementation-specific options. .. tab:: Python API .. literalinclude:: ../../../_static/examples/python/time_evolution_builder.py :language: python :start-after: # start-cell-configure-trotter :end-before: # end-cell-configure-trotter .. rubric:: Running the builder .. tab:: Python API .. literalinclude:: ../../../_static/examples/python/time_evolution_builder.py :language: python :start-after: # start-cell-run :end-before: # end-cell-run Available implementations ------------------------- QDK/Chemistry's :class:`~qdk_chemistry.algorithms.TimeEvolutionBuilder` provides a unified interface for Hamiltonian simulation methods. You can discover available implementations programmatically: .. tab:: Python API .. literalinclude:: ../../../_static/examples/python/time_evolution_builder.py :language: python :start-after: # start-cell-list-implementations :end-before: # end-cell-list-implementations .. _trotter-builder: Trotter-Suzuki product formulas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. rubric:: Factory name: ``"trotter"`` The Trotter-Suzuki decomposition approximates the time-evolution operator as a product of individual Pauli exponentials. For a Hamiltonian :math:`H = \sum_j \alpha_j P_j`: **First-order Trotter** (:math:`p = 1`): .. math:: e^{-iHt} \approx \left[\prod_j e^{-i\alpha_j P_j t / N}\right]^N **Second-order Trotter** (Strang splitting, :math:`p = 2`): .. math:: e^{-iHt} \approx \left[\prod_{j=1}^{L-1} e^{-i\alpha_j P_j t / 2N} \cdot e^{-i\alpha_L P_L t / N} \cdot \prod_{j=L-1}^{1} e^{-i\alpha_j P_j t / 2N}\right]^N **Higher even orders** are constructed via the recursive Suzuki composition :cite:`Suzuki1992`: .. math:: S_{2k}(t) = S_{2k-2}(u_k t)^2 \, S_{2k-2}\!\bigl((1-4u_k) t\bigr) \, S_{2k-2}(u_k t)^2 where :math:`u_k = 1/(4 - 4^{1/(2k-1)})`. The number of Trotter steps :math:`N` can be specified directly (``num_divisions``) or computed automatically from a ``target_accuracy`` using one of two error bounds: Commutator bound (default) A tighter bound :cite:`Childs2021` based on nested commutators: :math:`N = \lceil \frac{t^{2}}{2\epsilon} \sum_{j`: One consumer of time-evolution unitaries Further reading --------------- - The above examples can be downloaded as a complete `Python <../../../_static/examples/python/time_evolution_builder.py>`_ script. - :doc:`PhaseEstimation `: Quantum phase estimation algorithms - :doc:`QubitMapper `: Map fermionic Hamiltonians to qubit operators - :doc:`Settings `: Configuration settings for algorithms - :doc:`Factory Pattern `: Understanding algorithm creation