Quantum Algorithm PDF
Quantum Algorithm PDF
Bowei Zhao
October 20, 2014
Proposition (Deutsch 1985) Let U be unitary matrix on a d-dimensional
space. Then the action of U can be written as a product of 2d
2
d unitary
matrices, each of which acts within a two-dimensional subspace dened by
a xed set of d basis vectors. Thus any unitary transformation on n qubits
can be realized by a sequence of unitary operations, each of which aects no
more than two qubits.
Proof : Let u
1
, ...u
d
denote d orthonormal eigenvectors of U, where
1
, ...
d
are the eigenvalues.
u
1
= (x
1
, ..., x
d
), then
A
12
= (
1
|x
1
|
2
+|x
2
|
2
x
1
x
2
x
2
x
1
, I
3,...,n
)
operates as a 2x2 matrix on the rst two coordinates and maps u
1
to
(t
2
, 0, x
3
, ...x
d
), where t
2
= sort|x
1
|
2
+|x
2
|
2
. a goal of d-1 such maps A
1k
will produce (1,0,...,0).
Multiply this by the eigenvalue
1
= e
i
1
and apply the inverses of A
1k
s
in reverse order has the eect of multiplying the rst eigenvector u
1
by the
rst eigenvalue
1
in 2d-1 one- and two- dimensional unitary operations.
Since these vectors are orthogonal, the other eigenvectors are mapped to
and then from a vector with a zero in the rst component and are thus
unaected by the procedure. Repeat for each eigenvector, and U can be
thus unitarily factored.
A logic gate is a computing machine whose input and output consist of
xed numbers of bits and which prefers a xed computation in a xed time
that is independent of the input.
Quantum gate is, an analog of a logic gate in a classical computer, which
are basic units of quantum algorithms.
A quantum gate has to be implemented unitary and must be reversible.
The Tooli gate:
1
000 001 010 011 100 101 110111
1 0 0 0 0 0 0 0 000
0 1 0 0 0 0 0 0 001
0 0 1 0 0 0 0 0 010
0 0 0 1 0 0 0 0 011
0 0 0 0 1 0 0 0 100
0 0 0 0 0 1 0 0 101
0 0 0 0 0 0 0 1 110
0 0 0 0 0 0 1 0 111
It applies a NOT to the third bit if the rst two bits are in 11, but
otherwise does nothing. It is known to be universal for reversible Boolean
logic.
Two-bit gates are not sucient for reversible Boolean logic. Two-bits
NAD gate cannot be made reversible without the introduction of a third
bit. If we are to retain one of the input bits in the output, and produce the
NAND of the two inputs in the second output bit, it will give the following
truth table:
a
1
a
2
a
1
a
1
a
2
0 0 0 1
0 1 0 1
1 0 1 1
1 1 1 0
The gate is still irreversible since two dierent inputs can be taken to
the same output. To make it reversible, we have to use both of the input
bits, and a third bit to save the output, as what is done in the Tooli gate.
The Tooli gate cannot be classically decomposed into two two-bit C-
NOTs or XORs, but a quantum decomposition is possible.
Quantum Logic
A quit is a quantum state, and as such can be in a superposition state
also. That is, in addition to |0 and |1, a quantum qubit can exist more
generally in the sate c
0
|0 + c
1
|1, where c
0
and c
1
are complex coecients
normalized to 1. So though it has discrete eigenstates, it can take on a
continuous range of superposition states.
The measurement collapse also applies, as measurement will always nd
a quit in one of its two eigenstates, |0 or |1.
Unlike classical bits, two or more qubits can interfere with one another,
forming a coherent superposition, of the form c
00
|00 + c
01
|01 + c
10
|10 +
2
c
11
|11. Generally n qubits will have 2
n
product eigenstates, or dimensions,
in their Hilbert spaces.
While a classical nat is able to represent products of a superposition
state of two qubits, of the form [c
0
|0
1
+ c
1
|1
1
][c
0
|0
2
+ c
1
|1
2
], it cannot
fully represent entangled states like
1
2
[|01 +|10].
Now we have the basic memory unit of a quantum computer, we can
study what makes the quantum computation itself. In classical reversible
computing, the types of function computed are reversible Boolean functions,
where number of inputs and outputs are always equal. A quantum compu-
tation has to be unitary. A prototypical example is quantum time evolution,
where the Hamiltonian describing the quantum system is exponentiated to
produce a unitary operator: U(t
f
, t
i
) = exp[i
t
i
t
f
H(t)dt]
Since U
= U
1
, quantum computing is reversible. All Boolean functions
are special cases of unitary transformations. We can do so by taking the
transpose or hermitian adjoint of the unitary matrix.
The read-out process is quantum mechanical measurement that collapses
the system to an eigenstate. This process is irreversible. Therefore a quan-
tum algorithm with classical inputs has to nd a way to evolve these inputs
into near-classical outputs again for ecient read-out, even thought the in-
termediate sate of the system would be unclassical (See Shors algorithm).
Quantum Gates
Quantum gates must be unitary: The transformation of inputs of outputs
must be unitary because the circuit must cause the quantum state to evolve
in accordance with Schr odinger
s equation.
U
not
=
0 1
1 0
U
XOR
=
1 0 0 0 |00
0 1 0 0 |01
0 0 0 1 |10
0 0 1 0 |11
Unlike the classical logic gates, these quantum gates are also able to
transform superposition states.
The Walsh-Hadamaard transform
U
WH
=
1
1 1
1 1
1
2
[|0 |1]
3
The Deutsch gate operates on three qubits at a time,
D() =
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 i cos sin
0 0 0 0 0 0 sin() i cos
) = iD( +
), so can be xed as an
irrational multiple of . D(/2) = T
3
.
The Deutsch gate is universal for quantum logic in the sense that any
unitary transform on an arbitrary number of qubits can be simulated by
repeated application of D() on three qubits at a time.
But Deutsch gate is not elementary, since it is later discovered that
Deutsch gate can be further decomposed into two-qubit gates.
The Tooli gate, which cannot be constructed from two-bit XOR gates,
can be simulated using only two-qubit gates.
A general way of writing a 2-dimensional unitary matrix, except for an
overall-phase factor, is
y(, , ) =
cos e
iv
sin
e
i()
sin e
i
cos
2
[y] =
1 0 0 0
0 1 0 0
0 0 cos e
iv
sin
0 0 e
i()
sin e
i
cos
NOT
NOT NOT.
Once we have a particular computation in mind, we need to design a
quantum circuit to achieve it. We need to know what quantum gates we are
going to use and how to wire them together. There is no actual wire, but
the wiring is simply to specify which output feeds into which input.
Well dene the action of the
NOT
1+i
2
1i
2
1i
2
1+i
2
NOT (
NOT)
1+i
2
1i
2
1i
2
1+i
2
1i
2
1+i
2
1+i
2
1i
2
1 0
0 1
NOT
NOT =
1+i
2
1i
2
1i
2
1+i
2
1+i
2
1i
2
1i
2
1+i
2
0 1
1 0
One single
NOT
NOT[4, 4]
NOT.
Computation of the Hamiltonian operator
5
For a time-independent Hamiltonian
H, the Schrodingers equation takes
the form:
ih
|(t)
t
=
H |(t).
The solution of Schrodingers equation:
|(t) = e
i
Ht
h
|(0) =
U(t)|(0).
This implies, in time t the initial state of the memory register |(0)
evolves into the state of |(t) under the operator
U(t) = e
i
Ht
h
. So |(t)
is the output from the circuit at time t.
So we need to nd a time-independent Hamiltonian operator
H such
that, when insured into the matrix exponential, exp(i
Ht/h) results in a
unitary matrix
U(t) that mimics the action of our desired circuit.
To move the cursor forwards and backwards we need a creation and an
annihilation operator. We rst annihilate the cursor at the i
th
site and then
recreate it at the (i + 1)
th
site. So the term for moving the cursor from the
i
th
site to the (i +1)
th
site and coupling it to the application of the (i +1)
th
gate operation is
c
i+1
a
i
M
i+1
.
The creation operator c acting on a single spin state is
c =
0 0
1 1
0 1
0 1
1 0
0 1
0 0
1 0
1 0
0 1
1 0
0 1
H =
k1
i=0
c
i+1
a
i
M
i+1
+ (c
i
+ 1 a
i
M
i+1
)
.
Now the evolution operator
U(t) is
U(t) = (e
i
H/h
)
t
.
Application
Shors Algorithm
1. Choose n s.t. N
2
S = 2
n
< 2N
2
.
Choose y s.t. gcd(y, N) = 1.
2. initialize two n-qubit registers to state 0: |
0
= |0|0.
6
3. Randomize the rst n domain qubits:
|
0
|
1
=
S1
k=0
1
S
|k|0
4. Evaluate the function f(k) y
k
mod(N):
|
1
|
2
=
S1
k=0
1
S
|k|f(k).
5. Transform the rst n quits using nite Fourier transform F = F
S
,
which maps
|k
1
S
S1
u=0
exp
2iuk
S
|u.
and is implementable unitarily and feasibly: |
2
|
3
=
1
S
S1
u=0
|f(k) exp
2iuk
S
.
6. Since y is a periodic function, say, r-periodic, f is r-periodic. Let
k = m + jr, where 0 m < r and 0 j < A, A =
S
r
and f(k) can be
written as f(m). Then the nal state can be expressed as
|
3
=
S1
u=0
r1
m=0
b
u
exp
2iuk
S
|u|f(m), where b
u
=
1
S
1exp
2iurA
S
1exp
2iur
S
.
7. Measure the rst integer, obtaining as before a value u with proba-
bility
3
|P
u
|
3
= rb
u
2
8. Use u and S to deduce a value of r.
r is odd then return to 2.
r = 2s, y
s
1mod(N), return to 2.
Otherwise use the Euclidean algorithm to compute (N, y
s
1). If bigger
than 1, quit. Otherwise return to 2.
References
Muthukrishnan, Ashok. Classical and Quantum Logic Gates: An Intro-
duction to Quantum Computing Quantum Information Seminar. (1999).
Pittenger, Arthur O. An Introduction to Quantum Computing Algo-
rithms. Boston: Birkhuser, 1999. Print.
Williams, Colin P., and Scott H. Clearwater. Explorations in Quantum
Computing. Santa Clara, CA: TELOS, 1998. Print.
7