Hands-on lab · 1 step
Build the SWAP test
Build the SWAP test on three qubits and read the fidelity of two one-qubit states from the ancilla alone: with and the overlap is , so the ancilla must return with probability .
Step 1: Ancilla, controlled swap, ancilla
The register has three qubits, all starting in ; qubit is the most significant bit, so has index .
- qubit is the ancilla;
- qubit holds , prepared by the locked first operation , which you must not edit or remove;
- qubit holds .
Append the SWAP test so that the probability of measuring the ancilla in equals
Allowed gates after the preparation: , (control first, then the two swapped qubits), and ; at most gates; no measurements (the grader reads the exact pre-measurement state).
p-ancilla: the marginal distribution of qubit must be within .
z-ancilla: the expectation value must be within ; it carries the same information as the marginal and is used for targeted feedback.