Recently I am learning quantum computing and qiskit coding.
Learning new things is very fun for me.
Today I tried to code quantum teleportation with qiskit.
’Teleportation’ sounds attractive for me I watched many SF movies when I was child ;) BTW, definition of teleportation is ‘the ability to transport a person or object instantly from one place to another ‘.(from wikipedia)
It is not magic.
What is quantum teleportation?
Quantum teleportation is a process by which quantum information (e.g. the exact state of an atom or photon) can be transmitted (exactly, in principle) from one location to another. The method transport information not object.
It seems useful for information transfer.
OK let’s write code. Following circuit uses 3 qubits. Alice has two qubits and Bob has one qubit. Alice would like to transfer her one qubit information Psi is defined as .
Bob would like to know alpha and beta.
At first import packages and generate with unitary gate.
from qiskit import QuantumCircuit from qiskit import QuantumRegister from qiskit import ClassicalRegister from qiskit import visualization from qiskit import BasicAer from qiskit.aqua import run_algorithm from qiskit.visualization import plot_histogram from qiskit import execute backend = BasicAer.get_backend('qasm_simulator') q = QuantumRegister(3) c0 = ClassicalRegister(1,'c0') c1 = ClassicalRegister(1,'c1') c2 = ClassicalRegister(1,'c2') qc = QuantumCircuit(q, c0,c1,c2) # set first state of q which is psi(1) # Alice has q and q # Bob has q qc.u3(0.3, 0.2, 0.1, q)
Next I made quantum circuit. The circuit is made with hadamard gate, controlled not gate, and pauli x, z gate.
qc.h(q) qc.cx(q,q) qc.barrier(q) qc.cx(q, q) qc.h(q) qc.barrier(q) qc.measure(q, c0) qc.measure(q, c1) qc.z(q).c_if(c0, 1) qc.x(q).c_if(c1, 1) qc.measure(q, c2) qc.draw(output='mpl')
What does mean the circuit? OK calculate it.
First step is q passed unitary gate and q passed hadamard gate.
q will be
q will be
So after U3 and H gate, circuit state will be…
Then q passed cx gate. Then qubit will be below.
Then q passed cx gate. qubit will be.
Now q can not separate it is entangle state.
Then, q passed hadamard gate….
Now entangle state is solved.
Bob can get Alices information by applying pauli x, z gate combination depends on q, q measurements.
If q, q = 00, q is , no operation is required.
If q, q = 01, q is , it is required Pauli x gate.
If q, q = 10, q is , it is required Pauli z gate.
Finally, q, q = 11, q is , it is required Pauli z gate.
Alice need to tell Bob her measurements of q, q, so Bob can not information faster than light.
Let’s run the circuit
res = execute(qc, backend, shots=1024) plot_histogram(res.result().get_counts(qc))
c is top of the 3 bit numbers. Most of c is 0. And how about alpha and beta?
Alpha = 0.245+0.258+0.219+0.256 = 0.978
Beta = 0.007+0.005+0.005+0.006 = 0.023
Check q first state.
q1 = QuantumRegister(1) c5 = ClassicalRegister(1) qc2 = QuantumCircuit(q1,c5) qc2.u3(0.3, 0.2, 0.1, q1) qc2.measure(q1, c5) qc2.draw(output='mpl')
j = execute(qc2, backend, shots=1024) plot_histogram(j.result().get_counts(qc2))
Probability is almost same. If the code run without U3gate, c will be only0.
I do not fully understand quantum teleportation now. So I’m reading some papers about it.
Today’s code is below.