|q⟩ Bad Qubits

intermediate · Programming · QAOA & Combinatorial Optimization

The Mixing Hamiltonian

QAOA alternates two unitaries: a cost unitary that encodes the objective, and a mixer unitary that drives the system away from a fixed point so it can explore the full solution space. Without the mixer, the optimizer would stay trapped in whatever initial state it started in.

The standard mixer Hamiltonian

Farhi, Goldstone, and Gutmann (2014) defined the mixing Hamiltonian as the sum of Pauli-XX operators over all nn qubits:

B=i=0n1Xi.B = \sum_{i=0}^{n-1} X_i.

Because XX acting on qubit ii commutes with XX acting on any other qubit jij \neq i, the time evolution factorizes into independent single-qubit rotations:

UB(β)=eiβB=i=0n1eiβXi=i=0n1RX(2β),U_B(\beta) = e^{-i\beta B} = \prod_{i=0}^{n-1} e^{-i\beta X_i} = \bigotimes_{i=0}^{n-1} R_X(2\beta),

where RX(θ)=eiθX/2R_X(\theta) = e^{-i\theta X/2} is the standard XX-axis rotation. The factor of 2 enters because the convention is RX(θ)=eiθX/2R_X(\theta) = e^{-i\theta X/2}, so matching eiβXe^{-i\beta X} requires the argument θ=2β\theta = 2\beta.

Why X is the right choice

The Pauli-XX operator generates rotations that mix 0|0\rangle and 1|1\rangle without preferred direction. An RX(π)R_X(\pi) gate is just the XX gate — a full bit-flip. At intermediate angles it creates genuine superpositions. This means the mixer, parametrized by β\beta, can continuously tune how aggressively the quantum state tunnels between different bit-string configurations.

More formally, the mixer must not commute with the cost Hamiltonian CC, otherwise [eiγC,eiβB]=0[e^{-i\gamma C}, e^{-i\beta B}] = 0 and the two unitaries could be absorbed into one, removing any quantum advantage. The standard XX-mixer satisfies this whenever the cost function is diagonal in the ZZ basis.

The circuit for two qubits

For n=2n = 2 qubits and mixing angle β\beta, the mixer layer is simply

UB(β)=RX(2β)RX(2β).U_B(\beta) = R_X(2\beta) \otimes R_X(2\beta).

No two-qubit gates are needed: the XiX_i terms in BB each act on a single qubit, so the whole mixer decomposes into parallel single-qubit rotations.

Try it

Build the 2-qubit mixer unitary UB(β)U_B(\beta) for β=π/4\beta = \pi/4. The grader checks the full unitary matrix, so returning an empty circuit will fail.

Run your code to see the quantum state.

At β=π/4\beta = \pi/4 each qubit undergoes RX(π/2)R_X(\pi/2), a 90-degree rotation about the xx-axis. The resulting unitary is

\otimes \frac{1}{\sqrt{2}}\begin{pmatrix}1 & -i \\ -i & 1\end{pmatrix}.$$ In a QAOA circuit you would choose $\beta$ as a free variational parameter and tune it classically; here we fix $\beta = \pi/4$ simply to make the expected unitary well-defined for the grader.

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