{ "schema": "wai.quantum.exercise/1", "id": "qft", "translations": { "zh-CN": "machine-assisted: to be reviewed by a fluent reader before it is advertised" }, "title": { "en": "The quantum Fourier transform, and back", "zh-CN": "量子傅里叶变换,以及它的逆" }, "task": { "en": "The program applies the three-qubit quantum Fourier transform. After it, write the inverse transform, so that the whole program is the same circuit as doing nothing. Keep the transform's gates as they are.", "zh-CN": "这个程序作用了三量子比特的量子傅里叶变换。在它之后写出逆变换,使整个程序与什么也不做是同一条线路。保持变换本身的门不变。" }, "starter": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "// the quantum Fourier transform", "h q[0];", "cp(pi/2) q[1], q[0];", "cp(pi/4) q[2], q[0];", "h q[1];", "cp(pi/2) q[2], q[1];", "h q[2];", "swap q[0], q[2];", "// its inverse: your gates here" ], "intent": { "equivalent": "OPENQASM 3.0;\ninclude \"stdgates.inc\";\nqubit[3] q;\n" }, "constraints": { "allow": ["h", "cp", "swap"], "counts": { "h": { "min": 6, "max": 6 }, "cp": { "min": 6, "max": 6 }, "swap": { "min": 2, "max": 2 } } }, "hints": { "en": [ "The inverse of a sequence of gates is the inverses of the gates, in the reverse order.", "h and swap are their own inverses. The inverse of cp(θ) is cp(−θ) on the same qubits." ], "zh-CN": [ "一串门的逆,就是把每个门换成它的逆,再把顺序倒过来。", "h 和 swap 都是自己的逆。cp(θ) 的逆是作用在同样量子比特上的 cp(−θ)。" ] }, "reference": [ "OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "h q[0];", "cp(pi/2) q[1], q[0];", "cp(pi/4) q[2], q[0];", "h q[1];", "cp(pi/2) q[2], q[1];", "h q[2];", "swap q[0], q[2];", "swap q[0], q[2];", "h q[2];", "cp(-pi/2) q[2], q[1];", "h q[1];", "cp(-pi/4) q[2], q[0];", "cp(-pi/2) q[1], q[0];", "h q[0];" ], "wrong": [ { "fails": "intent", "note": "the gates reversed but the angles not negated", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;", "h q[0];", "cp(pi/2) q[1], q[0];", "cp(pi/4) q[2], q[0];", "h q[1];", "cp(pi/2) q[2], q[1];", "h q[2];", "swap q[0], q[2];", "swap q[0], q[2];", "h q[2];", "cp(pi/2) q[2], q[1];", "h q[1];", "cp(pi/4) q[2], q[0];", "cp(pi/2) q[1], q[0];", "h q[0];"] }, { "fails": "constraint", "note": "deleting the transform does nothing too, but the exercise keeps its gates", "qasm": ["OPENQASM 3.0;", "include \"stdgates.inc\";", "qubit[3] q;"] } ] }