# Simulate hamiltonian evolution

I'm trying to figure out how to simulate the evolution of qubits under the interaction of Hamiltonians with terms written as a tensor product of Pauli matrices in a quantum computer. I have found the following trick in Nielsen and Chuang's book which is explained in this post for a Hamiltonian of the form

$$H = Z_1 \otimes Z_2 \otimes ... \otimes Z_n$$.

But it is not explained in detail how would the simulation for a Hamiltonian with terms including Pauli matrices $$X$$ or $$Y$$ would work. I understand that you can transform these Pauli's into Z's by considering that $$HZH = X$$ where $$H$$ is the Hadamard gate and also $$S^{\dagger}HZHS =Y$$ where $$S$$ is the phase $$i$$ gate. How exactly should I use this to implement for example $$H= X \otimes Y$$

What if now the Hamiltonian contains the sum of terms with Pauli matrices? For example

$$H = X_1 \otimes Y_2 + Z_2 \otimes Y_3$$

Let's say you have a Hamiltonian of the form $$H=\sigma_1\otimes\sigma_2\otimes\sigma_2\otimes\ldots\otimes\sigma_n$$ There's a straightforward circuit construction that lets you implement its time evolution $$e^{-iHt}$$. The trick is basically to decompose the state that you're evolving into the components that are in the $$\pm 1$$ eigenspaces of $$H$$. Then, you apply the phase $$e^{-it}$$ to the $$+1$$ eigenspace, and the phase $$e^{-it}$$ to the $$-1$$ eigenspace. The following circuit does that job (and uncomputes the decomposition at the end). I'm assuming the phase gate element in the middle to be applying the unitary $$\left(\begin{array}{cc} e^{it} & 0 \\ 0 & e^{-it} \end{array}\right).$$

In general, if you want to evolve some Hamiltonian $$H=H_1+H_2$$ where $$H_1$$ and $$H_2$$ are of the previous form, then by far the easiest is to decompose the evolution as $$e^{-iHt}\approx \left(e^{-iH_1t/M}e^{-iH_2t/M}\right)^M$$ for some large $$M$$ (although there are algorithms with much better scaling behaviour), and each of those small steps $$e^{-iH_1t/M}$$ can be implemented with the previous circuit.

That said, sometimes there are smarter things that you can do. Your extra example, $$H=X\otimes Y\otimes\mathbb{I}+Z\otimes\mathbb{I}\otimes Y$$ is one such case. I'd start by apply the unitary rotation $$U=\frac{Z+Y}{\sqrt{2}}$$ to qubits 2 and 3. This is the equivalent to the Hadamard gate, but converts $$Y$$ into $$Z$$ instead of $$X$$. Now stop for a moment and think. If qubits 2 and 3 are in 00, then we're applying $$(X+Z)$$ to qubit 1. For 01, it's $$(X-Z)$$, for 10 it's $$(Z-X)$$, and for 11 it's $$-(X+Z)$$. Next, let's apply controlled-not from qubit 2 to qubit 3. This just permutes the basis elements slightly. It now says that we have to apply the Hamiltonian $$(-1)^{x_2}(X+(-1)^{x_3}Z)$$ to the state of qubit 1, if qubits 2 and 3 are in the states $$x_2x_3$$. Next, remember that $$X+Z=\sqrt{2}H$$ (Hadamard, not Hamiltonian), and that $$X\sqrt{2}HX=X-Z$$. So, that gives us an easy way to convert between the two bits of Hamiltonian. We'll just replace those two $$X$$s with controlled-nots controlled by qubit 3. Similarly, we can use a circuit identity where this time we'll replace the $$X$$s with controlled-nots controlled off qubit 2.

Overall, I believe the simulation looks like It might look complicated, but there's none of the splitting up into little time steps that accumulate errors as you go along. It won't apply very often, but it's worth being aware of these sorts of possibilities.

• What does the square root factor in with a dot mean - a gate ? – Enrique Segura Feb 22 at 20:40
• @EnriqueSegura exactly the same as the other one you just asked about: a phase gate with the labeled angle of rotation. – DaftWullie Feb 24 at 12:17

The trick is that if we have a Hamiltonian $$H$$ with diagonalization $$H=UDU^\dagger$$, then $$e^{it H} = U e^{it D} U^\dagger$$.

In particular, if you have a Hamiltonian that is a product of Pauli's $$H = \sigma_1\otimes\cdots\otimes \sigma_n$$, (where for simplicity we assume $$\sigma_i \neq I$$ for all $$i$$) then we can diagonalise $$H$$ as

$$H = (\sigma'_1\otimes\cdots\otimes \sigma'_n) Z\otimes\cdot\otimes Z (\sigma'_1\otimes\cdots\otimes \sigma'_n)$$

As a result:

$$e^{it H} = (\sigma'_1\otimes\cdots\otimes \sigma'_n) e^{it Z\otimes\cdot\otimes Z} (\sigma'_1\otimes\cdots\otimes \sigma'_n)$$

Since Pauli matrices are easy to implement on a quantum computer, and we already know how to do $$e^{it Z\otimes Z}$$, we are then done.

If the Hamiltonian is a sum of Pauli products, then there is no general simple solution, but you can use the Lie product formula truncated to some large number of terms to reduce it to the above problem.

In general, this problem is not very simple, ultimately it comes down to taking a Hamiltonian as you've written and somehow forming the appropriate sequence of gates that implements $$e^{-\Delta t H}$$. From my understanding, this is usually accomplished by using the Trotter-Suzuki approximation and gate decompositions.