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[0] which is psi(1) # Alice has q[0] and q[1] # Bob has q[2] qc.u3(0.3, 0.2, 0.1, q[0])

Next I made quantum circuit. The circuit is made with hadamard gate, controlled not gate, and pauli x, z gate.

qc.h(q[1]) qc.cx(q[1],q[2]) qc.barrier(q) qc.cx(q[0], q[1]) qc.h(q[0]) qc.barrier(q) qc.measure(q[0], c0[0]) qc.measure(q[1], c1[0]) qc.z(q[2]).c_if(c0, 1) qc.x(q[2]).c_if(c1, 1) qc.measure(q[2], c2[0]) qc.draw(output='mpl')

What does mean the circuit? OK calculate it.

First step is q[0] passed unitary gate and q[1] passed hadamard gate.

q[0] will be

q[1] will be

So after U3 and H gate, circuit state will be…

=

Then q[1] passed cx gate. Then qubit will be below.

Then q[0] passed cx gate. qubit will be.

=>

Now q[2] can not separate it is entangle state.

Then, q[0] passed hadamard gate….

=>

=>

Now entangle state is solved.

Bob can get Alices information by applying pauli x, z gate combination depends on q[0], q[1] measurements.

If q[0], q[1] = 00, q[2] is , no operation is required.

If q[0], q[1] = 01, q[1] is , it is required Pauli x gate.

If q[0], q[1] = 10, q[1] is , it is required Pauli z gate.

Finally, q[0], q[1] = 11, q[1] is , it is required Pauli z gate.

Alice need to tell Bob her measurements of q[0], q[1], 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[2] is top of the 3 bit numbers. Most of c[2] 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[0] 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[2] will be only0.

I do not fully understand quantum teleportation now. So I’m reading some papers about it.

Today’s code is below.

https://nbviewer.jupyter.org/github/iwatobipen/playground/blob/master/tereportation.ipynb