Is there a (qiskit) method to give the generator $H$ in terms of Paulis of some gate $U=e^{iH}$ defined in qiskit. For example, it would take CNOT as input and give a representation of $\pi /4 (I_1 - Z_1)(I_2 - X_2)$ as output. Somewhat the 'inverse' of PauliEvolutionGate that can be used to define a gate $U(t)=e^{-iHt}$ via the Pauli terms $H$.


1 Answer 1


In general, multiple Hamiltonians can generate the same unitary.

A simple way to get a Hamiltonian is to take the logarithm of the unitary matrix using scipy.linalg.logm then use SparsePauliOp.from_operator to get the Pauli basis representation

from qiskit.circuit.library import CXGate
from qiskit.quantum_info import SparsePauliOp
from scipy.linalg import logm

op = SparsePauliOp.from_operator(-1j * logm(CXGate().to_matrix()))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.