QuantumCore

Hands-on lab · 1 step

Build the three-qubit QFT

Build the quantum Fourier transform on three qubits, F∣j⟩=18∑k=07e2πijk/8∣k⟩F\lvert j\rangle=\tfrac1{\sqrt8}\sum_{k=0}^{7}e^{2\pi ijk/8}\lvert k\rangle, from Hadamard gates, controlled-phase gates CP(φ)=diag(1,1,1,eiφ)\mathrm{CP}(\varphi)=\mathrm{diag}(1,1,1,e^{i\varphi}) and one SWAP, using at most seven gates.

0/1 step passedBest score 0/100

Step 1: QFT on three qubits

Build a three-qubit circuit whose 8×88\times8 unitary is Fjk=18e2πijk/8F_{jk}=\tfrac1{\sqrt8}e^{2\pi ijk/8} for j,k∈{0,…,7}j,k\in\{0,\dots,7\}, using only HH, CP(φ)\mathrm{CP}(\varphi) and SWAP\mathrm{SWAP}, at most 77 gates and no measurements. Qubit 00 is the most significant bit: the input ∣j⟩=∣j1j2j3⟩\lvert j\rangle=\lvert j_1j_2j_3\rangle has j1j_1 on qubit 00 and j=4j1+2j2+j3j=4j_1+2j_2+j_3. The grader computes the unitary UU of your circuit and the process fidelity FU=∣Tr(F†U)∣/8F_U=\lvert\mathrm{Tr}(F^\dagger U)\rvert/8, which equals 11 exactly when U=eiγFU=e^{i\gamma}F. The target is the product state F∣j⟩=18(∣0⟩+e2πi 0.j3∣1⟩)⊗(∣0⟩+e2πi 0.j2j3∣1⟩)⊗(∣0⟩+e2πi 0.j1j2j3∣1⟩)F\lvert j\rangle=\tfrac1{\sqrt8}\big(\lvert0\rangle+e^{2\pi i\,0.j_3}\lvert1\rangle\big)\otimes\big(\lvert0\rangle+e^{2\pi i\,0.j_2j_3}\lvert1\rangle\big)\otimes\big(\lvert0\rangle+e^{2\pi i\,0.j_1j_2j_3}\lvert1\rangle\big).

  • 3 qubits
  • allowed gates: H, CP, SWAP
  • at most 7 gates
  • no measurements

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).

Circuit diagram of your answerEmpty circuitq0q1q2
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|000⟩1
1.0000
0
100.00%
7 basis states with zero amplitude hidden