Skip to content

Commit c678e4f

Browse files
committed
quantum teleportation added
1 parent 94e70de commit c678e4f

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,20 @@ Scheme for `n=3`:
4444

4545
> Task. Transmit two bits of classical information between Alice and Bob using only one qubit.
4646
47-
![Superdense Coding](./circuit_diagrams/e1_superdense_coding.png)
47+
![Superdense Coding](./circuit_diagrams/e1_superdense_coding.png)
48+
49+
### Quantum Teleportation
50+
51+
> Task. Alice would like to send Bob a qubit that is in some unknown state.
52+
53+
![Quantum Teleportation](./circuit_diagrams/e2_quantum_teleportation.png)
54+
55+
## References
56+
57+
* [Jonahtan Hui, Quantum Computing Series, Medium](https://medium.com/@jonathan_hui/qc-quantum-computing-series-10ddd7977abd)
58+
59+
* [Qiskit, Medium](https://medium.com/qiskit)
60+
61+
* [Qiskit, GitHub](https://github.com/Qiskit/qiskit-terra)
62+
63+
* [An Introduction to Quantum Computing, Kaye, ‎Laflamme, Mosca](https://books.google.com.tr/books/about/An_Introduction_to_Quantum_Computing.html?id=8jwVDAAAQBAJ&source=kp_book_description&redir_esc=y)
19.5 KB
Loading

e2_quantum_teleportation.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'''
2+
Quantum Teleportation
3+
4+
Task. Alice would like to send Bob a qubit that is in some unknown state.
5+
6+
'''
7+
from qiskit import IBMQ, BasicAer
8+
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute
9+
10+
qr = QuantumRegister(3) # Initialize qubits
11+
cr0 = ClassicalRegister(1)
12+
cr1 = ClassicalRegister(1)
13+
cr2 = ClassicalRegister(1)
14+
circuit = QuantumCircuit(qr, cr0, cr1, cr2)
15+
16+
# Prepare the initial state which we want to transfer
17+
circuit.x(qr[0])
18+
19+
# Prepare the Bell pair
20+
circuit.h(qr[1])
21+
circuit.cx(qr[1], qr[2])
22+
23+
circuit.barrier()
24+
25+
# Measure in the Bell basis
26+
circuit.cx(qr[0], qr[1])
27+
circuit.h(qr[0])
28+
circuit.measure(qr[0], cr0[0])
29+
circuit.measure(qr[1], cr1[0])
30+
31+
circuit.barrier()
32+
33+
# Apply a correction
34+
circuit.z(qr[2]).c_if(cr0, 1)
35+
circuit.x(qr[2]).c_if(cr1, 1)
36+
circuit.measure(qr[2], cr2[0])
37+
38+
# Run our circuit with local simulator
39+
backend = BasicAer.get_backend('qasm_simulator')
40+
shots = 1024
41+
results = execute(circuit, backend=backend, shots=shots).result()
42+
answer = results.get_counts()
43+
print(answer)

0 commit comments

Comments
 (0)