# What is the difference between HamiltonianGate and PauliEvolutionGate in qiskit?

The PauliEvolutionGate implements $$U = exp(-itH)$$ for an operator $$H$$ consisting of Pauli terms. Since qiskit 1.0 there is also HamiltonianGate which implements $$U = exp(-itH)$$. What is the difference (if $$H$$ consists of Pauli terms)?

More concretely, why does HamiltonianGateimplement the gate directly corresponding to the Hadamard gate, while PauliEvolutionGateseems to result in a different operator in the following example:

import qiskit
print('Qiskit Version: ', qiskit.__version__)
from qiskit.circuit.library import HGate, PauliEvolutionGate, HamiltonianGate
from qiskit.quantum_info import SparsePauliOp, Operator

h = SparsePauliOp(['I', 'X', 'Z'], coeffs=[ 1.57079633+0.j, -1.11072073+0.j, -1.11072073+0.j])

u_pauli = Operator(PauliEvolutionGate(h, time=1))
print(u_pauli)

u_hamil = Operator(HamiltonianGate(h, time=1))
print(u_hamil)

print('Equivalence:')
print('Pauli and Hamiltonian evolution:')
print(u_pauli.equiv(u_hamil, atol=1e-2))

->
Qiskit Version:  1.1.0
Operator([[ 0.3978466 -0.19715007j,  0.39784661+0.80284993j],
[ 0.3978466 -0.80284993j, -0.3978466 -0.19715007j]],
input_dims=(2,), output_dims=(2,))
Operator([[ 0.70710678-8.68630257e-09j,  0.70710678-2.26635039e-09j],
[ 0.70710678-2.26635039e-09j, -0.70710678-4.15360180e-09j]],
input_dims=(2,), output_dims=(2,))
Equivalence:
Pauli and Hamiltonian evolution:
False
False
True
$$$$


If you read the documentation for the PauliEvolutionGate, the synthesis of the gate defaults to Lie-Trotter product formula with a single repetition; therefore, you need to perform repeated products of the PauliEvolutionGate some number of times to get the correct approximation.

If you replace your code for something like this:

u_pauli = Operator(PauliEvolutionGate(h/100, time=1))
for i in range(99):
u_pauli = Operator(PauliEvolutionGate(h/100, time=1)) @ u_pauli


you will get the right result.

Alternatively, you can define an LieTrotter object with an increased number of repetitions:

from qiskit.synthesis.evolution import LieTrotter

n_lietrotter = LieTrotter()
n_lietrotter.reps = 100
u_pauli = Operator(PauliEvolutionGate(h, time=1, synthesis=n_lietrotter))
`