|q⟩ Bad Qubits

advanced · Programming · Fault-Tolerant Gate Synthesis

Approximating Rotations with Clifford+T

A universal gate set lets us approximate any unitary, but it does not hand us a recipe. Gate synthesis is the algorithmic problem of turning a target rotation into a concrete word over Clifford+TT. This lesson covers the principle and works a case that comes out exactly, so you can see the machinery before precision and cost enter.

The target: single-qubit rotations

Up to global phase, every single-qubit unitary is a product of rotations about two axes, e.g.

U=Rz(α)Rx(β)Rz(γ),U = R_z(\alpha)\, R_x(\beta)\, R_z(\gamma) ,

where Rz(θ)=eiθZ/2=diag(eiθ/2,eiθ/2)R_z(\theta) = e^{-i\theta Z/2} = \mathrm{diag}(e^{-i\theta/2}, e^{i\theta/2}) and similarly for RxR_x. So synthesizing arbitrary single-qubit gates reduces to synthesizing zz-rotations; xx-rotations follow by conjugation with Hadamards, since HZH=XH Z H = X implies

Rx(θ)=HRz(θ)H.R_x(\theta) = H\, R_z(\theta)\, H .

Exactly-synthesizable angles

The TT gate is a zz-rotation: up to a global phase,

T=diag(1,eiπ/4)    Rz(π/4).T = \mathrm{diag}(1, e^{i\pi/4}) \;\equiv\; R_z(\pi/4) .

Therefore any rotation by an integer multiple of π/4\pi/4 is realizable exactly with SS, TT, and ZZ (and HH for the xx-axis):

Rz(π/4)T,Rz(π/2)S,Rz(3π/4)ST,Rz(π)Z.R_z(\pi/4) \equiv T, \qquad R_z(\pi/2) \equiv S, \qquad R_z(3\pi/4) \equiv S\,T, \qquad R_z(\pi) \equiv Z .

The exercise builds one such case on the xx-axis: Rx(π/4)=HTHR_x(\pi/4) = H\, T\, H.

Generic angles: approximation

Most useful angles are not multiples of π/4\pi/4 (think of the rotations in quantum phase estimation or chemistry simulation). For these the Clifford+TT set cannot hit the target exactly — it is a finite set, so it only reaches a discrete (but dense) collection of rotations. We must settle for an approximation within some operator-norm error ε\varepsilon:

UtargetUsynthε.\| U_{\text{target}} - U_{\text{synth}} \| \le \varepsilon .

Two results govern the cost:

The synthesis workflow

  1. Decompose the target unitary into zz- and xx-rotations (Euler angles).
  2. Turn each xx-rotation into a Hadamard-conjugated zz-rotation.
  3. For each zz-rotation, either emit an exact S/T/ZS/T/Z word (if the angle is a multiple of π/4\pi/4) or call an ε\varepsilon-approximate synthesizer (Ross–Selinger / Solovay–Kitaev).
  4. Concatenate, and optionally optimize the resulting word to reduce TT-count.

Try it

Synthesize Rx(π/4)R_x(\pi/4) exactly as the Clifford+TT word HTHH\,T\,H. The grader compares the resulting unitary (up to global phase) against Rx(π/4)R_x(\pi/4).

Run your code to see the quantum state.

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