You are on page 1of 26

ABV-IIITM

Quantum computing
Lab Assignment

Lokesh K – 2015IPG-039

Avinath K- 2015-IPG-040

Pavan Praneeth – 2015IPG-043

Sanjeev K – 2015IPG-046

Anurag V – 2015IPG-109
1. Study of Various quantum logic gates
In quantum computing and specifically the quantum circuit model of computation,
a quantum logic gate (or simply quantum gate) is a basic quantum
circuit operating on a small number of qubits. They are the building blocks of
quantum circuits, like classical logic gates are for conventional digital circuits.
Unlike many classical logic gates, quantum logic gates are reversible. However, it
is possible to perform classical computing using only reversible gates. For
example, the reversible Toffoli gate can implement all Boolean functions, often at
the cost of having to use ancillary bits. The Toffoli gate has a direct quantum
equivalent, showing that quantum circuits can perform all operations performed by
classical circuits.

Representation

Quantum logic gates are represented by unitary matrices. The number of qubits in the
input and output of the gate must be equal; a gate which acts on qubits is represented
by a unitary matrix. The quantum states that the gates act upon are vectors in complex
dimensions. The base vectors are the possible outcomes if measured, and a quantum
state is a linear combination of these outcomes. The most common quantum gates
operate on spaces of one or two qubits, just like the common classical logic gates
operate on one or two bits.
HADAMARD GATE
Qcad Functionalities:
GUI Environment to design quantum circuits
QCAD enables you to design quantum circuits easily with full GUI (graphical user
interface) environment.
Exportable EPS and BMP
QCAD can export the designed circuits as Encapsulated PostScript (EPS) in order to
include in LaTeX files.
Built-in Simulator
QCAD can simulate the designed circuit and show results (states of qubits).
Basic view of QCAD:
Representation of various gates
2. Implementation of XOR/ swapping quantum
gates
OUTPUTS :
Swap gates using C-NOT gates
3. Implement full adder and half adder using quantum gates.

There are two types of single bit adder - the half-adder and the full adder. The half-adder takes the
inputs A and B and outputs the 'sum' (XOR operation) S=A⊕B and the 'carry' (AND operation)

C=A⋅B. A full adder also has the 'carry in' Cin input and the 'carry out' output Cout, replacing C.
This returns S=A⊕B⊕Cin and Cout=Cin⋅(A+B)+A⋅B
4. Implement Grover’s Algorithm using quantum gates.

Grover's algorithm is a quantum algorithm that finds with high probability the unique

input to a black box function that produces a particular output value, using just
evaluations of the function, where is the size of the function's domain. It was devised
by Lov Grover in 1996.
The analogous problem in classical computation cannot be solved in fewer
than evaluations (because, in the worst case, the -th member of the domain might be
the correct member). At roughly the same time that Grover published his algorithm,
Bennett, Bernstein, Brassard, and Vazirani proved that any quantum solution to the
problem needs to evaluate the function times, so Grover's algorithm is asymptotically
optimal. It has been shown that a non-local hidden variable quantum computer could

implement a search of an item database in at most steps. This is faster than the
steps taken by Grover's algorithm. Neither search method will allow quantum computers
to solve NP-Complete problems in polynomial time.
Unlike other quantum algorithms, which may provide exponential speedup over their
classical counterparts, Grover's algorithm provides only a quadratic speedup. However,
even quadratic speedup is considerable when is large. Grover's algorithm could brute-
force a 128-bit symmetric cryptographic key in roughly 264 iterations, or a 256-bit key in
roughly 2128 iterations. As a result, it is sometimes suggested that symmetric key
lengths be doubled to protect against future quantum attacks.
5. Implement Shor’s Algorithm using quantum gates.
Shor's algorithm is a quantum algorithm for factoring a number N in O((log N)3) time and O(log N)
space, named after Peter Shor.
The algorithm is significant because it implies that public key cryptography might be easily broken,
given a sufficiently large quantum computer. RSA, for example, uses a public key N which is the
product of two large prime numbers. One way to crack RSA encryption is by factoring N, but with
classical algorithms, factoring becomes increasingly time-consuming as N grows large; more
specifically, no classical algorithm is known that can factor in time O((log N)k) for any k. By contrast,
Shor's algorithm can crack RSA in polynomial time. It has also been extended to attack many other
public key cryptosystems.
Like all quantum computer algorithms, Shor's algorithm is probabilistic: it gives the correct answer
with high probability, and the probability of failure can be decreased by repeating the algorithm.
Shor's algorithm was demonstrated in 2001 by a group at IBM, which factored 15 into 3 and 5, using
a quantum computer with 7 qubits.

Procedure
The problem we are trying to solve is that, given an integer N, we try to find another
integer p between 1 and N that divides N.
Shor's algorithm consists of two parts:
1. A reduction of the factoring problem to the problem of order-finding, which can be done on a
classical computer.
2. A quantum algorithm to solve the order-finding problem.

Quantum part: Period-finding subroutine:

1. Start with a pair of input and output qubit registers with log2N qubits each, and initialize them
to

N − 1/2∑x∣x⟩∣0⟩
where x runs from 0 to N - 1.

2. Construct f(x) as a quantum function and apply it to the above state, to obtain

N − 1/2∑x∣x⟩∣f(x)⟩

3. Apply the quantum Fourier transform on the input register. The quantum Fourier transform
on N points is defined by:

UQFT∣x⟩ = N − 1/2∑ye2πixy/N∣y⟩
This leaves us in the following state:
N − 1∑x∑ye2πixy/N∣y⟩∣f(x)⟩

4. Perform a measurement. We obtain some outcome y in the input register and f(x0) in the
output register. Since f is periodic, the probability to measure some y is given by

N − 1∣∑x :  f(x) = f(x0)e2πixy/N∣2 = N − 1∣∑be2πi(x0 + rb)y/N∣2


Analysis now shows that this probability is higher, the closer yr/N is to an integer.

5. Turn y/N into an irreducible fraction, and extract the denominator r′, which is a candidate
for r.
6. Check if f(x) = f(x + r′). If so, we are done.
7. Otherwise, obtain more candidates for r by using values near y, or multiples of r′. If any
candidate works, we are done.
8. Otherwise, go back to step 1 of the subroutine.

You might also like