|q⟩ Bad Qubits

advanced · Programming · Advanced Hamiltonian Simulation

Time-Dependent Hamiltonians

So far every Hamiltonian in this module was constant in time. Many real systems are not: a driven qubit, an adiabatic sweep, an annealing schedule, or a laser pulse all have a Hamiltonian H(t)H(t) that changes as the experiment runs. This lesson shows how to simulate that.

Why time-dependence is harder

For a constant HH, evolution is simply U(t)=eiHtU(t) = e^{-iHt}. When H=H(t)H = H(t) varies, the propagator is the time-ordered exponential

U(t)=Texp ⁣(i0tH(t)dt),U(t) = \mathcal{T}\exp\!\left(-i\int_0^t H(t')\,dt'\right),

where T\mathcal{T} orders later times to the left. You cannot simply write U(t)=exp(i0tHdt)U(t) = \exp(-i\int_0^t H\,dt') in general, because H(t1)H(t_1) and H(t2)H(t_2) need not commute at different times — the order of application matters. The time-ordering symbol T\mathcal{T} is precisely what keeps track of that order.

Slicing time

The fix mirrors Trotterization in time rather than in operator structure. Chop [0,t][0, t] into rr thin slices of width Δt=t/r\Delta t = t/r. Over a slice short enough that HH barely changes, treat it as constant and use the frozen propagator

Ukexp ⁣(iH(tk)Δt),U_k \approx \exp\!\bigl(-i\, H(t_k)\,\Delta t\bigr),

then compose the slices in time order, latest last:

U(t)Ur1Ur2U1U0.U(t) \approx U_{r-1}\,U_{r-2}\cdots U_1\,U_0.

Each slice can itself be Trotterized if H(tk)H(t_k) has multiple non-commuting terms. Evaluating HH at the slice midpoint tk=(k+12)Δtt_k = (k + \tfrac12)\Delta t (rather than an endpoint) is a midpoint rule that gives second-order accuracy in Δt\Delta t for free — a cheap and worthwhile upgrade.

A driven single qubit

Take the time-dependent Hamiltonian H(t)=g(t)XH(t) = g(t)\,X with a linear ramp g(t)=tg(t) = t, evolving from 00 to T=1T = 1. Each frozen slice is a single-qubit XX-rotation:

exp ⁣(igXΔt)=RX(2gΔt),\exp\!\bigl(-i\,g\,X\,\Delta t\bigr) = R_X\bigl(2\,g\,\Delta t\bigr),

using RX(θ)=eiθX/2R_X(\theta) = e^{-i\theta X/2}. With two slices (Δt=0.5\Delta t = 0.5) and midpoint evaluation, slice 0 freezes g=0.25g = 0.25 (angle 0.250.25) and slice 1 freezes g=0.75g = 0.75 (angle 0.750.75). Because all the slice propagators commute here (they are all XX-rotations), they compose to a single RX(1.0)R_X(1.0) — which equals the exact answer 01tdt=12\int_0^1 t\,dt = \tfrac12 doubled into the rotation angle. This commuting case is a sanity check; the slicing method is essential precisely when the slices do not commute.

Accuracy

Each frozen-slice approximation has error O(Δt2)O(\Delta t^2) (with the midpoint rule), so the total error over rr slices is O(Δt2r)=O(tΔt)=O(t2/r)O(\Delta t^2 \cdot r) = O(t\,\Delta t) = O(t^2/r) — the same 1/r1/r convergence as first-order Trotter. Finer slices track a faster-changing H(t)H(t) more faithfully, at the cost of more gates.

Try it

Simulate H(t)=g(t)XH(t) = g(t)\,X with the ramp g(t)=tg(t) = t from 00 to T=1T = 1, using 2 slices and midpoint evaluation. Apply one RX(2gΔt)R_X(2\,g\,\Delta t) per slice. The grader checks the final state vector.

Run your code to see the quantum state.

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