# Is the cost Hamiltonian unitary in QAOA?

I am trying to implement QAOA and there are things I don't understand at all.

The expansion of $$H$$ into Pauli $$Z$$ operators can be obtained from the canonical expansion of the cost-function $$C$$ by substituting for every binary variable $$x_i ∈ {0,1}$$ the operator $$x_i \rightarrow (1−Z_i)/2$$. (according to Qiskit tutorial).

But this operator looks like $$[[1, 0], [0, 0]]$$ which is not unitary.

I am optimizing a complicated QUBO function and the mapped Hamiltonian does not to seem unitary either.

How do I apply $$H$$ to $$|\beta, \gamma\rangle$$ to get $$\langle\beta, \gamma| H |\beta, \gamma\rangle$$?

• Hamiltonian should be Hermitian operator. The time evolution operator, that is $e^{-iHt/\hbar }$, is the unitary. Jun 5, 2021 at 19:44

In QAOA you do not implement Hamiltonian $$H$$ itself but gate defined as $$U = \mathrm{e}^{iHt}$$. Since Hamiltonian $$H$$ is always Hermitian, operator $$U$$ is always unitary. You can see proof of this here. Concerning implementation of QAOA circuits, I would recommed this article. It contains discussion how to convert QUBO to Hamiltonian and in the appendix, there is a implementation of a circuit for the Hamiltonian simulation.
• @HimeraEphemera: Actually, we implement the Hamiltonian, it is hidden in matrix $U$. The resulting binary string should be the ground state of the Hamiltonian for given $\beta$ and $\gamma$. Once you have the string (or rather the ground state), you put it into $\langle x|H|x\rangle$. Then you change parameters $\beta$ and $\gamma$ and run the simulation again and again until you find actual ground state of the Hamiltonian. Note that finding new values of $\beta$ and $\gamma$ is done classically. Jun 7, 2021 at 14:22
• @HimeraEphemera: Also note that calculation of $\langle x|H|x\rangle$ is rather complex but in case of Ising Hamiltonians you can exploit its special structure (only two-body interactions) and use a sampling advised in the paper (I did not dive into details of the sampling, so I cannot provide more in this regard). Jun 7, 2021 at 14:24