# How to build a circuit for simulation of a simple Hamiltonian?

Consider very simple Hamiltonian $$\mathcal{H} = Z = \begin{pmatrix}1 & 0 \\ 0 & -1\end{pmatrix}$$. It has eigenvalues 1 and -1 with coresponding eigenstates $$|0\rangle$$ and $$|1\rangle$$, respectively. Hence, a ground state is $$|1\rangle$$.

For Hamiltonian simulation we need to construct a gate $$U(t) = \mathrm{e}^{-i\mathcal{H} t}$$. For our $$\mathcal{H}$$, this gate is $$U(t) = Rz(-2t)$$ gate.

To simulate the Hamiltonian we apply gate $$U(\Delta t)$$ several times to get from state $$|\psi_0\rangle$$ to state $$|\psi_t\rangle$$ where number of steps (or application of the Hamiltonian) is $$t/\Delta t$$. This is called Trotter method.

Since our gate $$U$$ is $$z$$ rotation which is additive, i.e. $$Rz(\alpha)Rz(\beta) = Rz(\alpha+\beta)$$, we do not have to bother about steps $$\Delta t$$ and simply apply $$Rz(-2t)$$.

I tried to apply $$Rz$$ gate on some states generated by Hadamard gate and $$Ry$$ gate with different angle $$\theta$$ (to have states in different superpositions) and then measure the outcome. I would expect that measured state should be ground state of Hamiltonian. But this was not the case. Probably I am missing something.

So my question is how to build a circuit for finding the ground state of the Hamiltonian? I would appreciate if you could provide a circuit for finding ground state of $$\mathcal{H}=Z$$.

• "I would expect that measured state should be ground state of Hamiltonian." Why would you expect this? If you evolve under a unitary, the weight of initial and final states being in a particular eigenvector are equal. – DaftWullie May 13 '20 at 11:19

If two operators $$A$$ and $$B$$ commute then we can always write $$e^{i(A+B)t} = e^{iAt}e^{iBt}$$, so we don't need to worry about the Trotterization. Otherwise if $$A$$ and $$B$$ don't commute, then $$e^{i(A+B)t} \ne e^{iAt}e^{iBt}$$ and that's why we will need to apply the Trotterization procedure. Both (in)equalities can be proved with the Taylor series.

Now about how to obtain the ground state of the $$H=Z$$ Hamiltonian.

If we will apply $$e^{iHt} = R_z(-2t)$$ to an arbitrary state $$|\psi\rangle = \alpha |0\rangle + \beta |1\rangle$$ we will obtain only some relative phase (desregarding the global phase):

$$R_z(-2t) |\psi\rangle = \alpha |0\rangle + e^{-it}\beta |1\rangle$$

So, by just applying the $$R_z(-2t)$$ on some fixed state we will not succeed. One way for obtaining the ground state of the Hamiltonian is using the VQE algorithm. Here is the circuit that we will need:

With this circuit, one has a possibility to obtain all one-qubit states in the Bloch sphere, if the initial state is $$|0\rangle$$. For each given $$\theta_1$$ and $$\theta_2$$, the circuit will run $$N$$ times and we will measure the expectation value of the Hamiltonian $$\langle H \rangle = \langle Z \rangle = \frac{N_0 - N_1}{N}$$, where $$N_0$$ is the number of measured $$|0\rangle$$s and $$N_1$$ is the number of measured $$|1\rangle$$s. With some optimization method we will change $$\theta$$s in order to minimize $$\langle Z \rangle$$. After the optimization is over (we have found the state for which $$\langle Z \rangle$$ is minimal: in this case $$\langle Z \rangle = -1$$ is the minimal value), the circuit with the final $$\theta$$s can recreate the ground state of the Hamiltonian (the $$|1 \rangle$$ state, because $$\langle 1| Z |1 \rangle = -1$$). Note, that I haven't used the circuit for the Hamiltonian simulation $$e^{iHt}$$.

I hope and I am interested to see an answer that will use Adiabatic state preparation algorithm for the same job.

• Thanks for the answer. The circuit seems like to be an implementation of any single qubit gate (I also infred this from ...we can obtain all one-qubit states on Bloch sphere..). So, I am a little bit confused why you do not used the exponential of matrix $Z$. What about $Rz$ gate? Additionally, what about Hamiltonian $\mathcal{H} = X$? Is the circuit the same but we measure in Hadamard basis? – Martin Vesely May 14 '20 at 10:16
• Yes, we can just use only one $u3$ gate. For $H = X$ we can use the same circuit: in fact, we can use it for any $H = a I +bX + cZ + d Y$, like it was implemented in my tutorial with a similar circuit (I used $R_x R_y$). And yes we can do the measurements in $X$ basis for $H = X$, only one Hadamard will be added to the circuit. github.com/DavitKhach/quantum-algorithms-tutorials/blob/master/… – Davit Khachatryan May 14 '20 at 10:40
• For VQE we should have the decomposition of the Hamiltonian into Pauli terms because we are interested to find the expectation values of each Pauli $\langle H \rangle = a\langle I \rangle+b\langle X \rangle+c\langle Z \rangle+d\langle Y \rangle$. So, it is like we are doing tomography, but not for all possible Pauli terms (for those which are in the $H$'s decomposition), because it will not be efficient algo if you will need to do full tomography. – Davit Khachatryan May 14 '20 at 10:54
• So, we can avoid using the circuit for $e^{iHt}$, but also I guess (my guess is motivated from QAOA approach) for more complicated Hamiltonians it is possible that the $e^{iHt}$ will be helpful :) – Davit Khachatryan May 14 '20 at 10:58
• Thanks for help, understand now. – Martin Vesely May 14 '20 at 13:42