QuantumCore

Hands-on lab · 1 step

Three-bit phase estimation of a phase gate

Complete a three-qubit phase-estimation circuit around the controlled powers C-UC\text{-}U, C-U2C\text{-}U^2, C-U4C\text{-}U^4 of a black-box phase gate U=P(2πφ)=diag(1,e2πiφ)U=P(2\pi\varphi)=\mathrm{diag}(1,e^{2\pi i\varphi}), whose eigenvector is ∣1⟩\lvert1\rangle with eigenvalue e2πiφe^{2\pi i\varphi}. For U=TU=T the phase is φ=1/8\varphi=1/8. The grader substitutes φ=1/8\varphi=1/8, 3/83/8, 5/85/8 and 1/21/2 and requires the counting register to read ∣m⟩\lvert m\rangle with φ=m/8\varphi=m/8 with certainty.

0/1 step passedBest score 0/100

Step 1: Read the eigenphase in three bits

The register has four qubits, all starting in ∣0⟩\lvert0\rangle. Qubits 0,1,20,1,2 form the counting register ∣k⟩=∣k0k1k2⟩\lvert k\rangle=\lvert k_0k_1k_2\rangle with qubit 00 the most significant bit, k=4k0+2k1+k2k=4k_0+2k_1+k_2; qubit 33 is the target.

The circuit already contains three controlled placeholders acting on qubit 33: U1 controlled by qubit 22 (weight 202^0), U2 controlled by qubit 11 (weight 212^1) and U4 controlled by qubit 00 (weight 222^2). Keep each exactly once and add gates from {H,X,CP,SWAP}\{H,X,\mathrm{CP},\mathrm{SWAP}\}, at most 1616 operations in total including the three placeholders, and no measurements.

The grader runs four cases, substituting U2j=P(2πφ⋅2j)U^{2^j}=P(2\pi\varphi\cdot2^j):

  • phase-1-8: φ=1/8\varphi=1/8 (U=TU=T) must give the counting distribution P(001)=1P(001)=1;
  • phase-3-8: φ=3/8\varphi=3/8 must give P(011)=1P(011)=1;
  • phase-5-8: φ=5/8\varphi=5/8 must give P(101)=1P(101)=1;
  • phase-4-8: φ=1/2\varphi=1/2 (U=ZU=Z) must give P(100)=1P(100)=1.

Each check compares the full vector (p000,…,p111)(p_{000},\dots,p_{111}) of the counting qubits, summed over qubit 33, within 10−610^{-6}. After the controlled powers the counting register holds 18∑k=07e2πiφk∣k⟩=QFT8∣m⟩\tfrac1{\sqrt8}\sum_{k=0}^{7}e^{2\pi i\varphi k}\lvert k\rangle=\mathrm{QFT}_8\lvert m\rangle when φ=m/8\varphi=m/8, so the last stage must undo the Fourier transform.

  • 4 qubits
  • allowed gates: H, X, CP, SWAP
  • at most 16 gates
  • no measurements
  • use U1 at least 1×
  • use U2 at least 1×
  • use U4 at least 1×

One gate per line or separated by ;, e.g. H(0); CNOT(0,1); RY(1, pi/3); measure(1 -> 0). Qubit 0 is the top wire (most significant bit); controls come first. # starts a comment.

Measure into a classical bit with measure(q -> c); apply a gate only when a bit is set with X(2) if c1==1 (several bits, first = most significant: if c[0,1]==3). Placeholders: U1, U2, U4 — write the name on its own (e.g. U1); it acts on the qubits fixed by the step.

Circuit diagram of your answerU1 on q3 controlled by q2; U2 on q3 controlled by q1; U4 on q3 controlled by q0q0q1q2q3U1U2U4
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|0000⟩1
1.0000
0
100.00%
15 basis states with zero amplitude hidden