0% found this document useful (0 votes)
21 views30 pages

Unit - 2 (Quantum Computing)

The document outlines fundamental principles of quantum mechanics, including Dirac's Razor, the Principle of Superposition, and the Principle of Indeterminacy. It discusses the no cloning theorem, which prohibits the creation of identical copies of an unknown quantum state, and its implications for quantum computing and cryptography. Additionally, it describes the quantum teleportation protocol, where Alice can send quantum information to Bob using entangled qubits and classical communication, without copying the quantum state.

Uploaded by

SRIKANTH KETHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views30 pages

Unit - 2 (Quantum Computing)

The document outlines fundamental principles of quantum mechanics, including Dirac's Razor, the Principle of Superposition, and the Principle of Indeterminacy. It discusses the no cloning theorem, which prohibits the creation of identical copies of an unknown quantum state, and its implications for quantum computing and cryptography. Additionally, it describes the quantum teleportation protocol, where Alice can send quantum information to Bob using entangled qubits and classical communication, without copying the quantum state.

Uploaded by

SRIKANTH KETHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

[QUANTUM COMPUTING]

2 QUANTUM BASICS AND


PRINCIPLES
UNIT
QUANTUM BASICS AND PRINCIPLES
There is nothing special about the transmission and absorption of photons
through a polarizing film. Exactly the same conclusions as those outlined above
are obtained by studying other simple experiments, such as the interference of
photons (see Dirac, Section I.3), and the Stern-Gerlach experiment (see Sakurai,
Chapter 1; Feynman, Chapter 5). The study of these simple experiments leads us
to formulate the following fundamental principles of quantum mechanics:

1. Dirac's Razor. Quantum mechanics can only answer questions regarding


the outcome of possible experiments. Any other questions lie beyond the
realms of physics.
2. Principle of the Superposition of States. Any microscopic system (i.e., an
atom, molecule, or particle) in a given state can be regarded as being
partly in each of two or more other states. In other words, any state can
be regarded as a superposition of two or more other states. Such
superpositions can be performed in an infinite number of different ways.
3. Principle of Indeterminacy. An observation made on a microscopic system
causes it to jump into one or more particular states (which are related to
the type of observation). It is impossible to predict into which final state
a particular system will jump. However, the probability of a given system
jumping into a given final state can be predicted.

The first of these principles was formulated by quantum physicists (such as


Dirac) in the 1920's to fend off awkward questions such as ``How can a system
suddenly jump from one state into another?'', or ``How does a system decide
which state to jump into?''. As we shall see, the second principle is the basis for
the mathematical formulation of quantum mechanics. The final principle is still
rather vague. We need to extend it so that we can predict which possible states
a system can jump into after a particular type of observation, as well as the
probability of the system making a particular jump.

UNIT - II 1
[QUANTUM COMPUTING]

NO CLONING THEOREM
The no cloning theorem is a result of quantum mechanics which forbids the
creation of identical copies of an arbitrary unknown quantum state. It was stated
by Wootters, Zurek, and Dieks in 1982, and has profound implications
in quantum computing and related fields. The theorem follows from the fact
that all quantum operations must be unitary linear transformation on the state
(and potentially an ancilla) .

Proof

Suppose the state of a quantum system A is a qubit, which we wish to copy. The
state can be written (see bra-ket notation) as

∣ψ⟩A = a∣0⟩A + b∣1⟩A

The complex coefficients a and b are unknown to us. In order to make a copy,
we take a system B with an identical Hilbert space and initial state ∣e⟩B (which
must be independent of ∣ψ⟩A, of which we have no prior knowledge). The
composite system is then described by the tensor product, and its state is

∣ψ⟩A∣e⟩B

There are only two ways to manipulate the composite system. We could
perform an observation, which irreversibly collapses the system into
some eigenstate of the observable, corrupting the information contained in the
qubit. This is obviously not what we want. Alternatively, we could control
the Hamiltonian of the system, and thus the time evolution operator U(Δt),
which is linear. We must fix a time interval Δt, again independent of ∣ψ⟩A. Then
U(Δt) acts as a copier provided

:{| |U(Δt)∣ψ⟩A∣e⟩B | = ∣ψ⟩A∣ψ⟩B |- | | = (a∣0⟩A + b∣1⟩A)(a∣0⟩B + b∣1⟩B) |- |


| = a2∣0⟩A∣0⟩B + ab∣0⟩A∣1⟩B + ba∣1⟩A∣0⟩B + b2∣1⟩A∣1⟩B |}

for all ψ. This must then be true for the basis states as well, so

U(Δt)∣0⟩A∣e⟩B = ∣0⟩A∣0⟩B

UNIT - II 2
[QUANTUM COMPUTING]

U(Δt)∣1⟩A∣e⟩B = ∣1⟩A∣1⟩B

Then the linearity of U(Δt) implies

:{| |U(Δt)∣ψ⟩A∣e⟩B | = U(Δt)(a∣0⟩A + b∣1⟩A)∣e⟩B |- | | = a∣0⟩A∣0⟩B + b∣1⟩A∣1⟩B |- |


| ≠ a2∣0⟩A∣0⟩B + ab∣0⟩A∣1⟩B + ba∣1⟩A∣0⟩B + b2∣1⟩A∣1⟩B |}.

Thus, U(Δt)∣ψ⟩A∣e⟩B is generally not equal to ∣ψ⟩A∣ψ⟩B, as may be verified by


plugging in a = b = 2-1/2, so U(Δt) cannot act as a general copier. Q.E.D.

Consequences

The no cloning theorem prevents us from using classical error


correction techniques on quantum states. For example, we cannot create
backup copies of a state in the middle of a quantum computation, and use them
to correct subsequent errors. Error correction is vital for practical quantum
computing, and for some time this was thought to be a fatal limitation.
In 1995, Shor and Steane revived the prospects of quantum computing by
independently devising the first quantum error correcting codes, which
circumvent the no cloning theorem.

In contrast, the no cloning theorem is a vital ingredient in quantum


cryptography, as it forbids eavesdroppers from creating copies of a transmitted
quantum cryptographic key.

Fundamentally, the no-cloning theorem protects the uncertainty


principle in quantum mechanics. If one could clone an unknown state, then one
could make as many copies of it as one wished, and measure each dynamical
variable with arbitrary precision, thereby bypassing the uncertainty principle.
This is prevented by the non-cloning theorem.

More fundamentally, the no cloning theorem prevents superluminal


communication via quantum entanglement. Consider the EPR thought
experiment, and suppose quantum states could be cloned. Alice could send bits
to Bob in the following way:

If Alice wishes to transmit a "0", she measures the spin of her electron in
the z direction, collapsing Bob's state to either ∣z + ⟩B or ∣z − ⟩B. Bob creates
many copies of his electron's state, and measures the spin of each copy in
UNIT - II 3
[QUANTUM COMPUTING]

the z direction. Bob will know that Alice has transmitted a "0" if all his
measurements will produce the same result; otherwise, his measurements will
be split evenly between +1/2 and -1/2. This would allow Alice and Bob to
communicate across space-like separations, potentially violating causality.

QUANTUM TELEPORTATION
Alice wants to send quantum information to Bob. Specifically, suppose she
wants to send the qubit state |ψ⟩=α|0⟩+β|1⟩. This entails passing on
information about α and β to Bob.
There exists a theorem in quantum mechanics which states that you cannot
simply make an exact copy of an unknown quantum state. This is known as the
no-cloning theorem. As a result of this we can see that Alice can't simply
generate a copy of |ψ⟩ and give the copy to Bob. We can only copy classical
states (not superpositions).
However, by taking advantage of two classical bits and an entangled qubit pair,
Alice can transfer her state |ψ⟩ to Bob. We call this teleportation because, at
the end, Bob will have |ψ⟩ and Alice won't anymore.

2. The Quantum Teleportation Protocol


To transfer a quantum bit, Alice and Bob must use a third party (Telamon) to
send them an entangled qubit pair. Alice then performs some operations on her
qubit, sends the results to Bob over a classical communication channel, and Bob
then performs some operations on his end to receive Alice’s qubit.

UNIT - II 4
[QUANTUM COMPUTING]

We will describe the steps on a quantum circuit below. Here, no qubits are
actually ‘sent’, you’ll just have to imagine that part!

First we set up our session:

# Do the necessary imports

import numpy as np

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister

from qiskit import IBMQ, Aer, transpile, assemble

UNIT - II 5
[QUANTUM COMPUTING]

from qiskit.visualization import plot_histogram, plot_bloch_multivector,


array_to_latex

from qiskit.extensions import Initialize

from qiskit.ignis.verification import marginal_counts

from qiskit.quantum_info import random_statevector

try
and create our quantum circuit:

## SETUP

# Protocol uses 3 qubits and 2 classical bits in 2 different registers

qr = QuantumRegister(3, name="q") # Protocol uses 3 qubits

crz = ClassicalRegister(1, name="crz") # and 2 classical bits

crx = ClassicalRegister(1, name="crx") # in 2 different registers

teleportation_circuit = QuantumCircuit(qr, crz, crx)

try

Step 1
A third party, Telamon, creates an entangled pair of qubits and gives one to Bob
and one to Alice.

UNIT - II 6
[QUANTUM COMPUTING]

The pair Telamon creates is a special pair called a Bell pair. In quantum circuit
language, the way to create a Bell pair between two qubits is to first transfer
one of them to the X-basis (|+⟩|+⟩ and |−⟩|−⟩) using a Hadamard gate, and then
to apply a CNOT gate onto the other qubit controlled by the one in the X-basis.

def create_bell_pair(qc, a, b):

"""Creates a bell pair in qc using qubits a & b"""

qc.h(a) # Put qubit a into state |+>

qc.cx(a,b) # CNOT with a as control and b as target

try

## SETUP

# Protocol uses 3 qubits and 2 classical bits in 2 different registers

qr = QuantumRegister(3, name="q")

crz, crx = ClassicalRegister(1, name="crz"), ClassicalRegister(1, name="crx")

teleportation_circuit = QuantumCircuit(qr, crz, crx)

## STEP 1

# In our case, Telamon entangles qubits q1 and q2

# Let's apply this to our circuit:

create_bell_pair(teleportation_circuit, 1, 2)

# And view the circuit so far:

UNIT - II 7
[QUANTUM COMPUTING]

teleportation_circuit.draw()

try
Let's say Alice owns q1 and Bob owns q2after they part ways.

Step 2
Alice applies a CNOT gate to q1, controlled by |ψ⟩ (the qubit she is trying to send
Bob). Then Alice applies a Hadamard gate to |ψ⟩. In our quantum circuit, the
qubit (|ψ⟩ Alice is trying to send is q0:

def alice_gates(qc, psi, a):

qc.cx(psi, a)

qc.h(psi)

try

## SETUP

# Protocol uses 3 qubits and 2 classical bits in 2 different registers

qr = QuantumRegister(3, name="q")

crz, crx = ClassicalRegister(1, name="crz"), ClassicalRegister(1, name="crx")

teleportation_circuit = QuantumCircuit(qr, crz, crx)

## STEP 1

create_bell_pair(teleportation_circuit, 1, 2)

UNIT - II 8
[QUANTUM COMPUTING]

## STEP 2

teleportation_circuit.barrier() # Use barrier to separate steps

alice_gates(teleportation_circuit, 0, 1)

teleportation_circuit.draw()

try

Step 3
Next, Alice applies a measurement to both qubits that she owns, q1and |ψ⟩, and
stores this result in two classical bits. She then sends these two bits to Bob.

def measure_and_send(qc, a, b):

"""Measures qubits a & b and 'sends' the results to Bob"""

qc.barrier()

qc.measure(a,0)

qc.measure(b,1)

try

## SETUP

# Protocol uses 3 qubits and 2 classical bits in 2 different registers

qr = QuantumRegister(3, name="q")

UNIT - II 9
[QUANTUM COMPUTING]

crz, crx = ClassicalRegister(1, name="crz"), ClassicalRegister(1, name="crx")

teleportation_circuit = QuantumCircuit(qr, crz, crx)

## STEP 1

create_bell_pair(teleportation_circuit, 1, 2)

## STEP 2

teleportation_circuit.barrier() # Use barrier to separate steps

alice_gates(teleportation_circuit, 0, 1)

## STEP 3

measure_and_send(teleportation_circuit, 0 ,1)

teleportation_circuit.draw()

try

Step 4
Bob, who already has the qubit q2, then applies the following gates depending
on the state of the classical bits:
00 →→ Do nothing
01 →→ Apply X gate
10 →→ Apply Z gate
11 →→ Apply ZX gate
(Note that this transfer of information is purely classical.)

UNIT - II 10
[QUANTUM COMPUTING]

# This function takes a QuantumCircuit (qc), integer (qubit)

# and ClassicalRegisters (crz & crx) to decide which gates to apply

def bob_gates(qc, qubit, crz, crx):

# Here we use c_if to control our gates with a classical

# bit instead of a qubit

qc.x(qubit).c_if(crx, 1) # Apply gates if the registers

qc.z(qubit).c_if(crz, 1) # are in the state '1'

try

## SETUP

# Protocol uses 3 qubits and 2 classical bits in 2 different registers

qr = QuantumRegister(3, name="q")

crz, crx = ClassicalRegister(1, name="crz"), ClassicalRegister(1, name="crx")

teleportation_circuit = QuantumCircuit(qr, crz, crx)

## STEP 1

create_bell_pair(teleportation_circuit, 1, 2)

## STEP 2

UNIT - II 11
[QUANTUM COMPUTING]

teleportation_circuit.barrier() # Use barrier to separate steps

alice_gates(teleportation_circuit, 0, 1)

## STEP 3

measure_and_send(teleportation_circuit, 0, 1)

## STEP 4

teleportation_circuit.barrier() # Use barrier to separate steps

bob_gates(teleportation_circuit, 2, crz, crx)

teleportation_circuit.draw()

try
And voila! At the end of this protocol, Alice's qubit has now teleported to Bob.

3. Simulating the Teleportation Protocol

3.1 How Will We Test the Protocol on a Quantum Computer?


In this notebook, we will initialize Alice's qubit in a random state |ψ⟩ (psi). This
state will be created using an Initialize gate on |q0⟩. In this chapter we use the
function random_statevector to choose psi for us, but feel free to set psi to any
qubit state you want.

# Create random 1-qubit state

psi = random_statevector(2)

UNIT - II 12
[QUANTUM COMPUTING]

# Display it nicely

display(array_to_latex(psi, prefix="|\\psi\\rangle ="))

# Show it on a Bloch sphere

plot_bloch_multivector(psi)

try
|ψ⟩=[−0.38591−0.11057i−0.31966+0.85829i]
Let's create our initialization instruction to create |ψ⟩ from the state |0⟩|0⟩:

init_gate = Initialize(psi)

init_gate.label = "init"

try
(Initialize is technically not a gate since it contains a reset operation, and so is
not reversible. We call it an 'instruction' instead). If the quantum teleportation
circuit works, then at the end of the circuit the qubit |q2⟩ will be in this state.
We will check this using the statevector simulator.

3.2 Using the Simulated Statevector


We can use the Aer simulator to verify our qubit has been teleported.

## SETUP

qr = QuantumRegister(3, name="q") # Protocol uses 3 qubits

crz = ClassicalRegister(1, name="crz") # and 2 classical registers


UNIT - II 13
[QUANTUM COMPUTING]

crx = ClassicalRegister(1, name="crx")

qc = QuantumCircuit(qr, crz, crx)

## STEP 0

# First, let's initialize Alice's q0

qc.append(init_gate, [0])

qc.barrier()

## STEP 1

# Now begins the teleportation protocol

create_bell_pair(qc, 1, 2)

qc.barrier()

## STEP 2

# Send q1 to Alice and q2 to Bob

alice_gates(qc, 0, 1)

## STEP 3

# Alice then sends her classical bits to Bob

measure_and_send(qc, 0, 1)

UNIT - II 14
[QUANTUM COMPUTING]

## STEP 4

# Bob decodes qubits

bob_gates(qc, 2, crz, crx)

# Display the circuit

qc.draw()

try
We can see below, using the statevector obtained from the aer simulator, that
the state of |q2⟩ is the same as the state |ψ⟩ we created above, while the states
of |q0⟩ and |q1⟩ have been collapsed to either |0⟩|0⟩ or |1⟩|1⟩. The
state |ψ⟩ has been teleported from qubit 0 to qubit 2.

sim = Aer.get_backend('aer_simulator')

qc.save_statevector()

out_vector = sim.run(qc).result().get_statevector()

plot_bloch_multivector(out_vector)

try
You can run this cell a few times to make sure. You may notice that the qubits 0
& 1 change states, but qubit 2 is always in the state |ψ⟩.

UNIT - II 15
[QUANTUM COMPUTING]

3.3 Using the Simulated Counts


Quantum teleportation is designed to send qubits between two parties. We do
not have the hardware to demonstrate this, but we can demonstrate that the
gates perform the correct transformations on a single quantum chip. Here we
again use the aer simulator to simulate how we might test our protocol.

On a real quantum computer, we would not be able to sample the statevector,


so if we wanted to check our teleportation circuit is working, we need to do
things slightly differently. The Initialize instruction first performs a reset, setting
our qubit to the state |0⟩|0⟩. It then applies gates to turn our |0⟩|0⟩ qubit into
the state |ψ⟩:
|0⟩Initialize gates−−−−−−−−→|ψ⟩|0⟩→Initialize gates
Since all quantum gates are reversible, we can find the inverse of these gates
using:

inverse_init_gate = init_gate.gates_to_uncompute()

try
This operation has the property:

|ψ⟩Inverse Initialize gates−−−−−−−−−−−−−→|0⟩→Inverse Initialize gates|0⟩


To prove the qubit |q0⟩ has been teleported to |q2⟩, if we do this inverse
initialization on |q2⟩, we expect to measure |0⟩|0⟩ with certainty. We do this in
the circuit below:

## SETUP

qr = QuantumRegister(3, name="q") # Protocol uses 3 qubits

crz = ClassicalRegister(1, name="crz") # and 2 classical registers

crx = ClassicalRegister(1, name="crx")

qc = QuantumCircuit(qr, crz, crx)

UNIT - II 16
[QUANTUM COMPUTING]

## STEP 0

# First, let's initialize Alice's q0

qc.append(init_gate, [0])

qc.barrier()

## STEP 1

# Now begins the teleportation protocol

create_bell_pair(qc, 1, 2)

qc.barrier()

## STEP 2

# Send q1 to Alice and q2 to Bob

alice_gates(qc, 0, 1)

## STEP 3

# Alice then sends her classical bits to Bob

measure_and_send(qc, 0, 1)

## STEP 4

UNIT - II 17
[QUANTUM COMPUTING]

# Bob decodes qubits

bob_gates(qc, 2, crz, crx)

## STEP 5

# reverse the initialization process

qc.append(inverse_init_gate, [2])

# Display the circuit

qc.draw()

try
We can see the inverse_init_gate appearing, labelled 'disentangler' on the
circuit diagram. Finally, we measure the third qubit and store the result in the
third classical bit:

# Need to add a new ClassicalRegister

# to see the result

cr_result = ClassicalRegister(1)

qc.add_register(cr_result)

qc.measure(2,2)

qc.draw()

UNIT - II 18
[QUANTUM COMPUTING]

try
and we run our experiment:

t_qc = transpile(qc, sim)

t_qc.save_statevector()

counts = sim.run(t_qc).result().get_counts()

qubit_counts = [marginal_counts(counts, [qubit]) for qubit in range(3)]

plot_histogram(qubit_counts)

try
We can see we have a 100% chance of measuring q2 (the purple bar in the
histogram) in the state |0⟩|0⟩. This is the expected result, and indicates the
teleportation protocol has worked properly.

4. Understanding Quantum Teleportation


As you have worked with the Quantum Teleportation's implementation, it is
time to understand the mathematics behind the protocol.

Step 1
Quantum Teleportation begins with the fact that Alice needs to
transmit |ψ⟩=α|0⟩+β|1⟩ (a random qubit) to Bob. She doesn't know the state of
the qubit. For this, Alice and Bob take the help of a third party (Telamon).
Telamon prepares a pair of entangled qubits for Alice and Bob. The entangled
qubits could be written in Dirac Notation as:
|e⟩=1√ 2 (|00⟩+|11⟩)

Alice and Bob each possess one qubit of the entangled pair (denoted as A and B
respectively),

UNIT - II 19
[QUANTUM COMPUTING]

|e⟩=1√ 2 (|0⟩A|0⟩B+|1⟩A|1⟩B)

This creates a three qubit quantum system where Alice has the first two qubits
and Bob the last one.

|ψ⟩⊗|e⟩=1√ 2 (α|0⟩⊗(|00⟩+|11⟩)+β|1⟩⊗(|00⟩+|11⟩))=1√ 2 (α|000⟩+α|011⟩+


β|100⟩+β|111⟩)

Step 2
Now according to the protocol Alice applies CNOT gate on her two qubits
followed by Hadamard gate on the first qubit. This results in the state:

(H⊗I⊗I)(CNOT⊗I)(|ψ⟩⊗|e⟩)=(H⊗I⊗I)(CNOT⊗I)1√ 2 (α|000⟩+α|011⟩+β|10
0⟩+β|111⟩)=(H⊗I⊗I)1√ 2 (α|000⟩+α|011⟩+β|110⟩+β|101⟩)=12(α(|000⟩+|011⟩
+|100⟩+|111⟩)+β(|010⟩+|001⟩−|110⟩−|101⟩))
Which can then be separated and written as:

=12(|00⟩(α|0⟩+β|1⟩)+|01⟩(α|1⟩+β|0⟩)+|10⟩(α|0⟩−β|1⟩)+|11⟩(α|1⟩−β|0⟩))=

Step 3
Alice measures the first two qubit (which she owns) and sends them as two
classical bits to Bob. The result she obtains is always one of the four standard
basis states |00⟩,|01⟩,|10⟩,|00⟩,|01⟩,|10⟩, and |11⟩|11⟩ with equal
probability.
On the basis of her measurement, Bob's state will be projected
to,|00⟩→(α|0⟩+β|1⟩)|01⟩→(α|1⟩+β|0⟩)|10⟩→(α|0⟩−β|1⟩)|11⟩→(α|1⟩−β|0⟩)

Step 4
Bob, on receiving the bits from Alice, knows he can obtain the original
state |ψ⟩ by applying appropriate transformations on his qubit that was once
part of the entangled pair.
The transformations he needs to apply are:

Bob's StateBits ReceivedGate


Applied(α|0⟩+β|1⟩)00I(α|1⟩+β|0⟩)01X(α|0⟩−β|1⟩)10Z(α|1⟩−β|0⟩)11ZXBob's

UNIT - II 20
[QUANTUM COMPUTING]

After this step Bob will have successfully reconstructed Alice's state.

5. Teleportation on a Real Quantum Computer

5.1 IBM hardware and Deferred Measurement


The IBM quantum computers currently do not support instructions after
measurements, meaning we cannot run the quantum teleportation in its current
form on real hardware. Fortunately, this does not limit our ability to perform
any computations due to the deferred measurement principle discussed in
chapter 4.4 of [1]. The principle states that any measurement can be postponed
until the end of the circuit, i.e. we can move all the measurements to the end,
and we should see the same results.

Any benefits of measuring early are hardware related: If we can measure early,
we may be able to reuse qubits, or reduce the amount of time our qubits are in
their fragile superposition. In this example, the early measurement in quantum
teleportation would have allowed us to transmit a qubit state without a direct
quantum communication channel.

While moving the gates allows us to demonstrate the "teleportation" circuit on


real hardware, it should be noted that the benefit of the teleportation process
(transferring quantum states via classical channels) is lost.

Let us re-write the bob_gates function to new_bob_gates:

def new_bob_gates(qc, a, b, c):

qc.cx(b, c)

qc.cz(a, c)

try

UNIT - II 21
[QUANTUM COMPUTING]

And create our new circuit:

qc = QuantumCircuit(3,1)

# First, let's initialize Alice's q0

qc.append(init_gate, [0])

qc.barrier()

# Now begins the teleportation protocol

create_bell_pair(qc, 1, 2)

qc.barrier()

# Send q1 to Alice and q2 to Bob

alice_gates(qc, 0, 1)

qc.barrier()

# Alice sends classical bits to Bob

new_bob_gates(qc, 0, 1, 2)

# We undo the initialization process

qc.append(inverse_init_gate, [2])

UNIT - II 22
[QUANTUM COMPUTING]

# See the results, we only care about the state of qubit 2

qc.measure(2,0)

# View the results:

qc.draw()

try

5.2 Executing

# First, see what devices we are allowed to use by loading our saved accounts

IBMQ.load_account()

provider = IBMQ.get_provider(hub='ibm-q')

try

# get the least-busy backend at IBM and run the quantum circuit there

from qiskit.providers.ibmq import least_busy

from qiskit.tools.monitor import job_monitor

backend = least_busy(provider.backends(filters=lambda b:
b.configuration().n_qubits >= 3 and

not b.configuration().simulator and


b.status().operational==True))

UNIT - II 23
[QUANTUM COMPUTING]

t_qc = transpile(qc, backend, optimization_level=3)

job = backend.run(t_qc)

job_monitor(job) # displays job status under cell

try
Job Status: job has successfully run

# Get the results and display them

exp_result = job.result()

exp_counts = exp_result.get_counts(qc)

print(exp_counts)

plot_histogram(exp_counts)

try
{'0': 894, '1': 130}

As we see here, there are a few results in which we measured |1⟩|1⟩. These
arise due to errors in the gates and the qubits. In contrast, our simulator in the
earlier part of the notebook had zero errors in its gates, and allowed error-free
teleportation.

print(f"The experimental error rate :


{exp_counts['1']*100/sum(exp_counts.values()):.3f}%")

UNIT - II 24
[QUANTUM COMPUTING]

try
The experimental error rate : 12.695%

BELL’S INEQUALITY AND ITS IMPLICATIONS


The theorem is named after John Stewart Bell. Hidden variables are the
microscopic properties of particles that are difficult to observe with the existing
microscope. However, according to the Heisenberg Uncertainty Principle, these
variables do not exist outside the context of observation.

Bell’s Theorem Formula


According to the theorem if X, Y and Z are the photon measurement variables
then,

P (X = Y) + P (Y = Z) + P (Z = X) ≥ 1

where P(X=Y) is the probability of X = Y, which is mathematically relevant.

What is Bell’s Inequality?


Bell’s inequality can be best explained with the help of quantum mechanics. In
quantum mechanics, it is believed that when electrons are sent across the
magnetic field, half of the electrons get deflected towards the right and the
other half to the left. The right half of the electrons are again sent across another
magnetic field perpendicular to the first; then they split into half so that few go
up and the other few go down. This is known as the randomness of the electron,
which is studied using Bell’s theorem.

What is Local Realism?


Local realism is a concept that is formalized to state and prove Bell’s theorem
with Alice and Bob (the outcome of random sampling). Alice and Bob observed
two observed values with detector settings: A(a,λ), and b is B(b,λ), respectively.

Above is the expression of local realism.

UNIT - II 25
[QUANTUM COMPUTING]

Example of Bell’s Theorem


Photon polarisation: Polarisation of light is the example that explains Bell’s
theorem and Bell’s inequality as it involves the study of particles.

QUANTUM ALGORITHMS & CIRCUITS


A quantum computer is a machine that can manipulate the quantum state of
many qubits in a controlled way. The output of the computation is the
measurement of all qubits at the end of this transformation. Because quantum
mechanics is a probabilistic theory, many such runs (called shots) are necessary
to average the outcomes and compute the probabilities to measure certain
states.

A single shot can be described as follows:

|Ψinitial⟩=|0…0⟩⏟Initialization→Quantum algorithm|Ψfinal⟩→Measure all


qubis{|0…0⟩?|0…1⟩?⋮|1…1⟩?⏟OutputThere are three crucial steps to perform a
shot:

1. Initialization of all qubits in the state |Ψinitial⟩=|0…0⟩.


2. Transformation of the initial quantum state by applying a sequence
of quantum gates according to a prescribed “quantum program”
or quantum algorithm. This produces the final state |Ψfinal⟩.
3. Measurement of all qubits and output of the result | 1⟩ with ∈{0,1}.
These steps are then repeated many times to approximate the probabilities for
the observed qubit states by averaging the results of all shots.

The crucial step is of course the application of the transformation .


“Programming a quantum computer” simply means to specify which should be
applied. To make the specification of easier, a set of primitive gates that act
either on one, two, or three qubits is provided by the quantum computing
platform. The job of the “quantum programmer” is to combine these primitive
gates to implement specific sequence of primitve gates is called a quantum
algorithm. In the notation above, primitive gates are applied from right to left,
i.e., starting with 1 and ending wth is the total number of applied gates, it
determines the runtime of the quantum algorithm.

A quantum circuit is a graphical representation of a quantum algorithm where


qubits are represented by horizontal lines and time flows from left to right:
UNIT - II 26
[QUANTUM COMPUTING]

The primitive gates are represented by boxes that cover the lines of the qubits
that the gates operate on. Gates that act on a single qubit are represented by
squares, gates that act on two adjacent qubits by rectangles etc. The left
boundary of the circuit corresponds to the initial state |Ψinitial⟩=|0…0⟩, the
right boundary to the final state |Ψfinal⟩ and the subsequent measurement of
all qubits. Gates that operate on different qubits (= disjoint boxes) can be
applied in parallel so that the circuit above can be compactified as follows:

However, it is crucial that the sequence of gates matters (they do not commute).
So the following circuits are not equivalent in general and produce different final
states (and measurement outcomes):

UNIT - II 27
[QUANTUM COMPUTING]

The Quantum Circuit Simulator

A quantum circuit simulator is a tool that allows you to construct and simulate
simple quantum circuits graphically, i.e., without actually writing code. Every
primitive gate is represented by a unique symbol that covers one, two, or three
qubits, depending on the gate. The symbols can be dragged with the mouse and
dropped onto the quantum circuit to construct a quantum algorithm. Our
quantum circuit simulator then translates this graphical representation into an
equivalent textual representation, a programming language known
as OpenQASM. This code is sent to and run by our servers that simulate a
quantum computer. The measurement results are then sent back to your
browser and displayed by the quantum circuit simulator.

Our quantum circuit simulator is an interactive web application to write and


simulate simple quantum algorithms without having to sign up for an account.
It can be embedded into webpages like this:

Beware:
The quantum circuit representation is only useful for simple quantum algorithms
(with few qubits and gates). However, it can be very helpful to illustrate the
operation of a quantum computer and to develop new algorithms. To
implement “real” algorithms on hundreds or thousands of qubits, one would
write OpenQASM code directly.

Here we describe how our quantum circuit simulator works step by step:

UNIT - II 28
[QUANTUM COMPUTING]

Step I
Use the + and - buttons in the Quantum circuit box to set the number of qubits
(1–10 qubits are possible). The qubits are labeled as q[i] with index i=0,1,...,N-
1 for N qubits (in informatics, indices typically start from 0 and not 1).

Step II
Use your mouse to drag quantum gates from the Gates box into the Quantum
circuit box. Drop the gate on the horizontal line that corresponds to the qubit
that the gate should be applied to. You can insert gates before other gates by
“squeezing” them in gaps between gates. To delete gates, grab them and pull
them out of the quantum circuit.

Step III
Whenever you change the quantum circuit, the quantum circuit simulator
automatically translates the circuit into an equivalent OpenQASM code
representation (shown in the QASM code box).

Step IV
After the OpenQASM code has been updated, it is automatically sent to our
QRydDemo API at the University of Stuttgart and queued in the job list of our
classical simulator. You can also manually submit a new job by clicking
the Manual submit button. This is useful to observe the statistical fluctuations
of the measurement outcomes.

UNIT - II 29
[QUANTUM COMPUTING]

Step V

Our simulator of a quantum computer executes your quantum circuit 200 times
and accumulates the measurement outcomes. The simulator runs on dedicated
graphics cards to accelerate the computations. When our quantum computer is
up and running, this simulation can be replaced by a quantum computation on
a real quantum computer.

Note: To simulate quantum algorithms on up to 10 qubits, it is not necessary to


use dedicated hardware like graphics cards. These simulations could be
performed by your local computer (even in your browser). However, we use this
simulation pipeline & hardware also productively to simulate up to 32 qubits
and optimize our gate protocols. It was then straightforward to connect the
quantum circuit simulator to this pipeline, so that you automatically profit from
improvements of our simulators.

Step VI

The accumulated measurement results are sent back to the quantum circuit
simulator in your browser.

Step VII

The results are displayed in the Histogram box of the quantum circuit simulator.
The y-axis shows the number of shots that resulted in a specific qubit
configuration after measurement (all bars therefore add up to 200). On the x-
axis the 2 possible measurement outcomes are shown (for qubits). For
example, the label 0010=q[3]q[2]q[1]q[0] corresponds to the measured
state |0⟩=|0010⟩.

UNIT - II 30

You might also like