{ "schema": "wai.quantum.exercise/1", "id": "phase-estimation", "translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" }, "title": { "en": "Phase estimation", "zh-CN": "相位估计" }, "task": { "en": "The T gate multiplies |1⟩ by e^{2πi/8}: its phase is 1/8. Three counting qubits have picked up that phase, written as Σₓ e^{2πi·x/8}|x⟩, with q[2] the highest bit. Finish with the inverse quantum Fourier transform so that the counting register reads 001, that is 8 × 1/8, every time.", "zh-CN": "T 门把 |1⟩ 乘以 e^{2πi/8}:它的相位是 1/8。三个计数量子比特已经获得了这个相位,写作 Σₓ e^{2πi·x/8}|x⟩,其中 q[2] 是最高位。最后加上逆量子傅里叶变换,使计数寄存器每次都读出 001,即 8 × 1/8。" }, "starter": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[4] q;", "bit[3] c;", "// the eigenstate |1⟩ of the T gate, on q[3]", "x q[3];", "// the counting register", "h q[0];", "h q[1];", "h q[2];", "// controlled T to the powers 1, 2 and 4", "cp(pi/4) q[0], q[3];", "cp(pi/2) q[1], q[3];", "cp(pi) q[2], q[3];", "// the inverse quantum Fourier transform: your gates here", "c[0] = measure q[0];", "c[1] = measure q[1];", "c[2] = measure q[2];" ], "intent": { "distribution": { "001": 1.0 } }, "constraints": { "allow": ["h", "x", "cp", "swap"], "counts": { "x": { "max": 1 }, "cp": { "min": 6, "max": 6 }, "h": { "min": 6, "max": 6 } } }, "hints": { "en": [ "The previous lesson's inverse transform is close, but it was written for q[0] as the highest bit. Here q[2] is.", "Undo the order first: a swap of the outer qubits, then a Hadamard on each qubit from q[0] up, each preceded by cp(−π/2ᵏ) from the qubits already done." ], "zh-CN": [ "上一课的逆变换已经很接近了,但它是以 q[0] 为最高位写的。这里最高位是 q[2]。", "先把顺序倒回来:交换最外侧的两个量子比特;然后从 q[0] 开始依次对每个量子比特作用 Hadamard 门,在每个 Hadamard 之前,从已经处理过的量子比特作用 cp(−π/2ᵏ)。" ] }, "reference": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[4] q;", "bit[3] c;", "x q[3];", "h q[0];", "h q[1];", "h q[2];", "cp(pi/4) q[0], q[3];", "cp(pi/2) q[1], q[3];", "cp(pi) q[2], q[3];", "swap q[0], q[2];", "h q[0];", "cp(-pi/2) q[1], q[0];", "h q[1];", "cp(-pi/4) q[2], q[0];", "cp(-pi/2) q[2], q[1];", "h q[2];", "c[0] = measure q[0];", "c[1] = measure q[1];", "c[2] = measure q[2];" ], "wrong": [ { "fails": "intent", "note": "Hadamards alone do not read a phase of 1/8", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[4] q;", "bit[3] c;", "x q[3];", "h q[0];", "h q[1];", "h q[2];", "cp(pi/4) q[0], q[3];", "cp(pi/2) q[1], q[3];", "cp(pi) q[2], q[3];", "h q[0];", "h q[1];", "h q[2];", "c[0] = measure q[0];", "c[1] = measure q[1];", "c[2] = measure q[2];"] } ] }