# Practical implementation of Hamiltonian Evolution

Following from this question, I tried to look at the cited article in order to simulate and solve that same problem... without success. Mainly, I still fail to understand how the authors managed to simulate the Hamiltonian evolution through the circuit shown at the bottom of Fig.4. Even exponentiating classically the matrix I do not get values of the gates shown in the Quirk circuit that @Blue linked along his question.

I tried to look at the paper in which the Group Leader Optimization algorithm is explained, but I still have troubles understanding how do they assign the rotation angles to the different gates.

• Good question! Some of those rotation angle values are definitely wrong. @Nelimee tried them out in his program. Have a look at optim_hamil.py. A practical way to get the correct rotation angle values/coefficients is to use some sort of multivariate optimization algorithm. Nelimee used the scipy.optimize module for that purpose. However, I would like to personally understand the Group Leader Optimization Algorithm properly too. The paper: arxiv.org/abs/1004.2242 is too vague! – Sanchayan Dutta Jul 20 '18 at 12:19
• The point is that from what I understood they are using genetic algorithms to find the optimal configuration to represent a given quantum subroutine, which already strikes me as odd honestly. – FSic Jul 20 '18 at 12:26
• You can recover the matrices exponentials with this script. And you understood correctly, they use a genetic algorithm (which is a kind of optimisation algorithm) to find a good (and not the optimal) gate decomposition that implements a unitary matrix that is close to the one we want. – Nelimee Jul 20 '18 at 12:30
• Thanks for the script! However, with this you obtain directly the values of the exponentiated matrix, which can be directly implemented in Quirk, I was rather trying to understan how they manage to simulate such matrix with the gates they provided in the figure, because I also tried to compute the circuit to see the final matrix, but I end up having something totally different. I do not exclude to have made some miscalculations though. – FSic Jul 20 '18 at 12:52

I don't know why/how the authors of that paper do what they do. However, here's how I'd go about it for this special case (and it is a very special case):

You can write the Hamiltonian as a Pauli decomposition $$A=15\mathbb{I}\otimes\mathbb{I}+9Z\otimes X+5X\otimes Z-3Y\otimes Y.$$ Update: It should be $$+3Y\otimes Y$$. But I don't want to redraw all my diagrams etc., so I'll leave the negative sign.

Now, it is interesting to note that every one of these terms commutes. So, that means that $$e^{iA\theta}=e^{15i\theta}e^{9i\theta Z\otimes X}e^{5i\theta X\otimes Z}e^{-3i\theta Y\otimes Y}.$$ You could work out how to simulate each of these steps individually, but let me make one further observation first: these commuting terms are the stabilizers of the 2-qubit cluster state. That may or may not mean anything to you, but it tells me that a smart thing to do is apply a controlled-phase gate. $$CP\cdot A\cdot CP=15\mathbb{I}\otimes\mathbb{I}+9\mathbb{I}\otimes X+5X\otimes \mathbb{I}-3X\otimes X.$$ (You may want to check the sign of the last term. I didn't compute it carefully.) So, if we start and end our sequence with controlled-phase gates, then 2 of the terms are easy to get right: we rotate the first qubit about the $$x$$ axis by an angle $$5\theta$$, and the second qubit about the $$x$$ axis by an angle $$9\theta$$.

The only thing we are left to get right is the $$X\otimes X$$ rotation. If you think about the structure of $$e^{-3i\theta X\otimes X}$$, this is like an $$x$$ rotation on the basis states $$\{|00\rangle,|11\rangle\}$$, and another one on $$\{|01\rangle,|10\rangle\}$$. A controlled-not converts these bases into the single-qubit bases controlled off the target qubit. But since both implement the same controlled-rotation but controlled off opposite values, we can just remove the control. Thus, the overall circuit is: This simplifies slightly by combining the two controlled-gates at the end: Note that I have not included the global phase term here because that's not the sensible way to do it. When you make controlled-($$e^{iA\theta}$$), you apply the "global phase" as a $$z$$ rotation on the control qubit.

• Hi, do you know any textbook or any paper which discusses the general algorithm for decomposing the Hamiltonian into Pauli gates? I only found this website, but it doesn't explain the logic behind the decomposition nor the general algorithm for larger matrices (if it exists). – Sanchayan Dutta Oct 19 '18 at 6:30
• @Blue The simplest method is based on a Trotter-Suzuki decomposition. Those key words should hopefully provide a fruitful search. However, there are newer, much more efficient, algorithms. I'll need to dig out a reference... – DaftWullie Oct 19 '18 at 6:46
• @Blue Here's a talk that gives a fair introduction+overview, and contains links to some of the relevant papers: bristol.ac.uk/media-library/sites/maths/events/2015/… – DaftWullie Oct 19 '18 at 6:50
• I was a bit confused by the second Pauli decomposition and asked a question regarding that here. If you get time, do please consider answering it! – Sanchayan Dutta Oct 19 '18 at 11:45