|q⟩ Bad Qubits

beginner · Programming · Quantum Teleportation & Superdense Coding

Full Teleportation Circuit

Quantum teleportation is the protocol that transfers an unknown qubit state from one party to another using a pre-shared Bell pair and two classical bits. All the prerequisite pieces — Bell pair preparation, Bell-basis measurement, and classical corrections — are now in place. This lesson assembles them into a single three-qubit circuit and verifies the result by simulation.

The three-qubit layout

Three qubits take the following roles:

| Qubit | Party | Role | |-------|-------|------| | 0 | Alice | Message qubit to teleport | | 1 | Alice | Her half of the Bell pair | | 2 | Bob | His half of the Bell pair |

Before the protocol begins Alice and Bob have already shared the Bell pair Φ+=12(00+11)|\Phi^+\rangle = \tfrac{1}{\sqrt{2}}(|00\rangle + |11\rangle) on qubits 1 and 2. Alice wants to send the unknown state on qubit 0 without transmitting the qubit itself.

Five-step assembly

For this exercise the message qubit is prepared in +=12(0+1)|+\rangle = \tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle) so the simulator has a definite state to compare. The full circuit proceeds in five ordered steps.

Step 1 — Prepare the message. Apply HH to qubit 0. This puts the message in +|+\rangle, the state that will be teleported to Bob.

Step 2 — Create the Bell pair. Apply HH to qubit 1 and then CX(1,2)\text{CX}(1, 2). This entangles qubits 1 and 2 into Φ+|\Phi^+\rangle.

Step 3 — Bell-basis rotation. Apply CX(0,1)\text{CX}(0, 1) then H(0)H(0). Taken together these two gates rotate Alice's pair from the Bell basis back into the computational basis, exactly the reverse of the Bell-pair creation. This is the circuit implementation of a Bell measurement.

Step 4 — Deferred X correction. Apply CX(1,2)\text{CX}(1, 2). In a real device this gate would be applied only when a classical measurement of qubit 1 returned 1. By the deferred measurement principle (Nielsen & Chuang §4.4), replacing every classically-controlled gate with its quantum-controlled counterpart and delaying the measurements until the end of the circuit gives an identical result. The simulator uses this unitary form so the full state vector is available for grading.

Step 5 — Deferred Z correction. Apply CZ(0,2)\text{CZ}(0, 2). Analogously, this substitutes for the classically-controlled ZZ gate that would be applied when qubit 0 measured as 1.

After all five steps, qubit 2 carries the state +|+\rangle that qubit 0 started in, while qubits 0 and 1 are each in the uniform superposition 12(0+1)\tfrac{1}{\sqrt{2}}(|0\rangle + |1\rangle).

Why it works

Write the initial three-qubit state (before any gates) as 000|000\rangle. Tracking the state through each step and using linearity:

000H0+00H1,CX12+Φ+12|000\rangle \xrightarrow{H_0} |{+}00\rangle \xrightarrow{H_1, \text{CX}_{12}} |{+}\rangle \otimes |\Phi^+\rangle_{12} CX01,H012(00++01X++10Z++11XZ+)\xrightarrow{\text{CX}_{01}, H_0} \frac{1}{2}\bigl(|00\rangle|{+}\rangle + |01\rangle X|{+}\rangle + |10\rangle Z|{+}\rangle + |11\rangle XZ|{+}\rangle\bigr) CX12,CZ0212(00+01+10+11)+=+01+2.\xrightarrow{\text{CX}_{12}, \text{CZ}_{02}} \frac{1}{2}\bigl(|00\rangle + |01\rangle + |10\rangle + |11\rangle\bigr)\otimes|{+}\rangle = |{+}\rangle_{01} \otimes |{+}\rangle_2.

Each of the four Bell branches carries the same target state +|+\rangle on qubit 2, and the corrections undo the XX and ZZ operators that arose in the intermediate steps. The final state is a product: qubits 0 and 1 are in +01|+\rangle_{01} and qubit 2 holds +|+\rangle.

Try it

Build the five-step circuit below. The grader checks the full three-qubit state vector; every amplitude must match the reference solution.

Run your code to see the quantum state.

After running, inspect the Amplitudes panel. You should see all eight basis states — 000|000\rangle, 001|001\rangle, 010|010\rangle, 011|011\rangle, 100|100\rangle, 101|101\rangle, 110|110\rangle, 111|111\rangle — each with real amplitude +1220.354+\tfrac{1}{2\sqrt{2}} \approx 0.354. This is the product state +0+1+2|{+}\rangle_0 \otimes |{+}\rangle_1 \otimes |{+}\rangle_2, confirming that qubit 2 received the message qubit's state exactly.

Sign in on the full site to ask questions and join the discussion.