|q⟩ Bad Qubits

advanced · Programming · Capstone Projects

Project: Hamiltonian Simulation Study

Simulating quantum dynamics — evolving a state under eiHte^{-iHt} — was the original motivation for quantum computers. There is no single best method: product formulas (Trotter), linear combination of unitaries, qubitization, and classical tensor networks each win in different regimes. This capstone implements the workhorse Trotter step on a concrete model so you can study the accuracy–cost trade-off that distinguishes the methods.

The model

We simulate the two-site transverse-field Ising model

H=JZ0Z1+h(X0+X1).H = J\,Z_0 Z_1 + h\,(X_0 + X_1).

The two pieces HZZ=JZ0Z1H_{ZZ} = J Z_0 Z_1 and HX=h(X0+X1)H_X = h(X_0 + X_1) do not commute, so eiHteiHZZteiHXte^{-iHt} \neq e^{-iH_{ZZ}t}e^{-iH_X t} in general — which is exactly why a method is needed.

First-order Trotter

The Lie–Trotter formula splits the evolution into a product of the individually-easy exponentials:

eiHt=(eiHZZt/neiHXt/n)n+O ⁣(t2n).e^{-iHt} = \Big(e^{-iH_{ZZ}\,t/n}\,e^{-iH_X\,t/n}\Big)^n + \mathcal{O}\!\Big(\frac{t^2}{n}\Big).

Each step of size δt=t/n\delta t = t/n is a short circuit. The ZZZZ factor compiles to CX; RZ(2Jδt); CX\texttt{CX};\ \texttt{RZ}(2J\delta t);\ \texttt{CX} and the field factor to two RX(2hδt)\texttt{RX}(2h\delta t) rotations, using RZ(θ)=eiθZ/2R_Z(\theta) = e^{-i\theta Z/2} (hence the factor of 22).

Comparing methods

The first-order error per step scales as O(δt2)\mathcal{O}(\delta t^2), so total error is O(t2/n)\mathcal{O}(t^2/n) — halving the step size halves the error but doubles the gate count. A second-order (symmetric) Trotter step costs roughly 1.5×1.5\times as many gates but cuts the error to O(t3/n2)\mathcal{O}(t^3/n^2), usually a better deal. Post-Trotter methods (qubitization, LCU) reach error ε\varepsilon with cost scaling as log(1/ε)\log(1/\varepsilon) instead of poly(1/ε)\text{poly}(1/\varepsilon) — asymptotically far better, but with larger constant overhead. Studying which wins for a given (t,ε)(t, \varepsilon) on a given HH is precisely a "Hamiltonian simulation study."

Try it

Build one first-order Trotter step for J=1J = 1, h=0.5h = 0.5, δt=0.3\delta t = 0.3 starting from 00|00\rangle. The grader checks the resulting statevector.

Run your code to see the quantum state.

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