|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=Ji=0n2ZiZi+1hi=0n1Xi,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=JZ0Z1h(X0+X1).H = -J\, Z_0 Z_1 - h\,(X_0 + X_1).

When JhJ \gg h the ground state is a ferromagnetic phase with spins aligned along ZZ; when hJh \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,XI]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:

eiHdteiHZZdteiHXdt+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=JZ0Z1H_{ZZ} = -J\,Z_0 Z_1. The Trotter factor is

ei(J)dtZ0Z1=e+iJdtZ0Z1.e^{-i(-J)\,dt\,Z_0 Z_1} = e^{+iJ\,dt\,Z_0 Z_1}.

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

eiθZZ=CNOT01(IRz(2θ))CNOT01,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 θ=Jdt\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

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

Each factor is eiθXqe^{-i\theta X_q} with θ=hdt\theta = -h\,dt, which equals Rx(2θ)=Rx(2hdt)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=Jdt=π/8\theta_{ZZ} = -J\,dt = -\pi/8 and θX=hdt=π/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  CNOT01e+iJdtZZ  Rx ⁣(π4)0  Rx ⁣(π4)1e+ihdt(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.