|q⟩ Bad Qubits

intermediate · Programming · Hamiltonian Simulation & Trotterization

Simulating the Transverse-Field Ising Model

The Transverse-Field Ising Model (TFIM) is one of the simplest many-body Hamiltonians that exhibits a quantum phase transition. It is a canonical test case for Hamiltonian simulation because its two terms — a nearest-neighbour ZZZZ interaction and a single-qubit XX field — do not commute, so Trotterisation introduces a non-trivial approximation error that can be measured and reduced.

The Hamiltonian

For nn qubits with open boundary conditions (couplings only between neighbours ii and i+1i+1), the TFIM Hamiltonian is

H=−J∑i=0n−2ZiZi+1−h∑i=0n−1Xi,H = -J \sum_{i=0}^{n-2} Z_i Z_{i+1} - h \sum_{i=0}^{n-1} X_i,

where JJ is the Ising coupling strength and hh is the transverse-field amplitude. For n=2n=2 there is exactly one ZZ coupling (between qubits 0 and 1) and two single-qubit XX terms:

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

When J≫hJ \gg h the ground state is a ferromagnetic phase with spins aligned along ZZ; when h≫Jh \gg J the ground state is a paramagnetic phase with spins aligned along XX. The quantum phase transition occurs at the critical point J=hJ = h.

Trotter decomposition

Because [ZZ,X⊗I]≠0[ZZ, X \otimes I] \neq 0, we cannot exponentiate HH exactly in closed form with simple two-local gates. Instead we split the Hamiltonian as H=HZZ+HXH = H_{ZZ} + H_X and apply the first-order Trotter formula over a step dtdt:

e−iH dt≈e−iHZZ dt e−iHX dt+O(dt2).e^{-iH\,dt} \approx e^{-iH_{ZZ}\,dt}\,e^{-iH_X\,dt} + O(dt^2).

Each factor is itself a product of commuting terms, so it factorises exactly.

The ZZ factor

HZZ=−J Z0Z1H_{ZZ} = -J\,Z_0 Z_1. The Trotter factor is

e−i(−J) dt Z0Z1=e+iJ dt Z0Z1.e^{-i(-J)\,dt\,Z_0 Z_1} = e^{+iJ\,dt\,Z_0 Z_1}.

Writing this as e−iθ ZZe^{-i\theta\,ZZ} with θ=−J dt\theta = -J\,dt, and recalling the standard decomposition from the previous lesson,

e−iθ ZZ=CNOT0→1 (I⊗Rz(2θ)) CNOT0→1,e^{-i\theta\,ZZ} = \mathrm{CNOT}_{0\to1}\,\bigl(I \otimes R_z(2\theta)\bigr)\,\mathrm{CNOT}_{0\to1},

the three-gate circuit is cx(0,1), rz(2*theta, 1), cx(0,1) with θ=−J dt\theta = -J\,dt.

The X factor

HX=−h(X0+X1)H_X = -h(X_0 + X_1). The two terms commute (X0X_0 and X1X_1 act on different qubits), so

e−i(−h) dt (X0+X1)=e+ih dt X0 e+ih dt X1.e^{-i(-h)\,dt\,(X_0 + X_1)} = e^{+ih\,dt\,X_0}\,e^{+ih\,dt\,X_1}.

Each factor is e−iθXqe^{-i\theta X_q} with θ=−h dt\theta = -h\,dt, which equals Rx(2θ)=Rx(−2h dt)R_x(2\theta) = R_x(-2h\,dt) on qubit qq.

Circuit for J=h=1J=h=1, dt=π/8dt = \pi/8

With J=h=1J = h = 1 and dt=π/8dt = \pi/8, the angles simplify to θZZ=−J dt=−π/8\theta_{ZZ} = -J\,dt = -\pi/8 and θX=−h dt=−π/8\theta_X = -h\,dt = -\pi/8. The corresponding gate angles are

2θZZ=−π4,2θX=−π4.2\theta_{ZZ} = -\frac{\pi}{4}, \qquad 2\theta_X = -\frac{\pi}{4}.

The complete first-order Trotter step is thus the five-gate sequence

CNOT01  Rz ⁣(−π4)1  CNOT01⏟e+iJ dt ZZ  Rx ⁣(−π4)0  Rx ⁣(−π4)1⏟e+ih dt (X0+X1).\underbrace{\mathrm{CNOT}_{01}\;R_z\!\bigl(-\tfrac{\pi}{4}\bigr)_1\;\mathrm{CNOT}_{01}}_{e^{+iJ\,dt\,ZZ}} \;\underbrace{R_x\!\bigl(-\tfrac{\pi}{4}\bigr)_0\;R_x\!\bigl(-\tfrac{\pi}{4}\bigr)_1}_{e^{+ih\,dt\,(X_0+X_1)}}.

Try it

Implement one first-order Trotter step for the 2-qubit TFIM with J=h=1J = h = 1 and dt=π/8dt = \pi/8. The grader checks the full unitary matrix, so an empty circuit will not pass. Use the hints if you need a reminder of the gate patterns.

Run your code to see the quantum state.

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