|q⟩ Bad Qubits

advanced · Programming · Quantum Annealing & Adiabatic Computing

Simulating a Small Anneal

A gate-model simulator like ours has no built-in "evolve under HH for time dtdt" command — but we can build one. The trick is Trotterization: approximate the continuous-time evolution of an annealing Hamiltonian by a sequence of small, simple gate steps.

The problem with sums of non-commuting terms

The evolution operator over a small time dtdt is U(dt)=eidtHU(dt) = e^{-i\,dt\,H} (setting =1\hbar = 1). When H=A+BH = A + B with [A,B]0[A, B] \neq 0 — as for our H(s)=(1s)XsZH(s) = -(1-s)X - sZ, since XX and ZZ anticommute — we cannot simply factor eidt(A+B)e^{-i\,dt(A+B)} into eidtAeidtBe^{-i\,dt A} e^{-i\,dt B}. The two are equal only when AA and BB commute.

The first-order Trotter formula

For small dtdt the Lie–Trotter formula gives a controlled approximation:

eidt(A+B)=eidtAeidtB+O(dt2).e^{-i\,dt\,(A + B)} = e^{-i\,dt\,A}\,e^{-i\,dt\,B} + O(dt^2).

The error per step is O(dt2)O(dt^2), set by the commutator [A,B][A, B]. Splitting a total time TT into N=T/dtN = T/dt steps gives total error O(Tdt)=O(T2/N)O(T\,dt) = O(T^2/N), which shrinks as you use more, smaller steps. This is exactly how Lloyd's universal quantum simulator turns any local Hamiltonian into a gate sequence.

One step of the single-qubit anneal

Take H(s)=(1s)XsZH(s) = -(1-s)X - sZ, so A=(1s)XA = -(1-s)X and B=sZB = -sZ. A single Trotter step is

eidtH(s)eidt(1s)X  eidtsZ.e^{-i\,dt\,H(s)} \approx e^{i\,dt(1-s)\,X}\;e^{i\,dt\,s\,Z}.

Now translate to gates. The simulator's rotations are

RX(ϕ)=eiϕX/2,RZ(ϕ)=eiϕZ/2.RX(\phi) = e^{-i\phi X/2}, \qquad RZ(\phi) = e^{-i\phi Z/2}.

Matching exponents, eidt(1s)X=RX(2dt(1s))e^{i\,dt(1-s)X} = RX\bigl(-2\,dt(1-s)\bigr) and eidtsZ=RZ(2dts)e^{i\,dt\,s\,Z} = RZ(-2\,dt\,s). Because the rightmost operator acts first on a ket, apply the ZZ rotation, then the XX rotation:

Ustep=RX(2dt(1s))RZ(2dts).U_{\text{step}} = RX\bigl(-2\,dt(1-s)\bigr)\,RZ(-2\,dt\,s).

Try it

Build one first-order Trotter step of eidtH(s)e^{-i\,dt\,H(s)} at s=0.5s = 0.5, dt=0.1dt = 0.1, using one RZRZ and one RXRX. The grader checks the resulting 2×22 \times 2 unitary.

Run your code to see the quantum state.

The two rotation angles are both 0.1-0.1 here (since s=1s=0.5s = 1-s = 0.5 and 2dt=0.22\,dt = 0.2 times each gives 0.1-0.1), producing a unitary very close to the identity for this small time step.

Sign in on the full site to ask questions and join the discussion.