Transcript Lecture 2

Quantum Computing
MAS 725
Hartmut Klauck
NTU
20.2.2012
Quantum Computing





Suppose we have a supply of qubits in some basis
state
We want to apply a unitary transformation
 Corresponding to a function we wish to compute
 So that measuring the resulting state gives us a
desired output
This unitary transformation must be the product of
“few” simple, local, unitary transformations
I.e., unitary transformation on 2 or 3 qubits
This means to build a quantum circuit
What is the difference to
probabilistic computations


Randomized/probabilistic computations can be
described similarly
 Keeping track of the probability distribution as a
vector of probabilities
Important difference: amplitudes can be negative,
allowing for negative interference effects
 Undesirable computations can “cancel each
other out”
“Parallel” Computing?

Assume f is a function we can compute efficiently
We want to compute some property of f, for
instance “if f(x)=1 for some x?”
We first need an f-oracle: a unitary way to compute
f
Uf: for f:{0,1}n  {0,1}: Uf maps |xi|0i to |xi|f(x)i
⨂
Apply Uf H n to n+1 qubits in the state |0n+1i

Result:




“Parallel” Computing?

What can we do with the resulting state?

Measuring now just yields the uniform distribution on x,f(x)
We do (at least) get “really random” values of x
To determine interesting properties of f we usually have to
work harder and employ interference effects.


Time for the first algorithm






Deutsch’s Algorithm
Setup: Input is in a Black Box
A function f:{0,1}  {0, 1}
unknown to us (is the input)
Access: We can read f(0) or read f(1)
Either f(0)=f(1) or f(0)  f(1)
Problem: decide which is the case
Deutsch’s Problem



How many times do we have to query the Black
Box?
Any deterministic algorithm that must not err has to
read f(0) and f(1).
Any randomized algorithm with only 1 query has
error probability ½ (i.e. is as good as tossing a coin
for an answer....)
Quantum queries




In a deterministic query algorithm the result of
previous queries determines the next position to
query
Randomized queries: In our case there is a
probability distribution on 0 and 1, that determines
whether we query f(0) or f(1)
Quantum queries can be in superposition instead
We have to model a quantum query as a unitary
operator
Quantum queries


Definition of query operation:
 Uf |ii|ai=|ii|a©f(i)i for all i,a2{0,1};
© is XOR operation: 0©0=0; 0©1=1; 1©1=0
Then Uf is defined for all basis states and ) Uf is
defined
First Idea: “Parallel” computation






Uf: Query to the oracle
Two qubits
(H⨂ I) |00i
I: Identity
=1/21/2 (|00i+|10i)
Apply Uf
Result: 1/21/2 ( |0,f(0) i+ |1,f(1)i )
What now ?
Deutsch’s Algorithm





Start with |01i
Apply H ⨂ H
Result:
1/2 (|0i +|1i)(|0i -|1i)
Apply Uf
Result:
1/2 ( |0,f(0)i-|0,f(0)©1i+|1,f(1)i-|1,f(1)©1i )
Deutsch’s Algorithm

Idea for the analysis:
Effect of Uf on |xi 1/21/2(|0i- |1i):
results in
(-1)f(x)|xi 1/21/2(|0i-|1i)
Because:
Uf |0i 1/21/2( |0i-|1i )
=
|0i 1/21/2 ( |f(0)i -|f(0) © 1i )
= (-1)f(0) |0i 1/21/2( |0i-|1i)
Deutsch’s Algorithm

Uf |1i 1/21/2( |0i-|1i )
=
|1i 1/21/2 ( |f(1)i -|f(1) © 1i )
= (-1)f(1) |1i 1/21/2 ( |0i-|1i)

We can disregard the second qubit now
Deutsch’s Algorithm

Now apply Hadamard transform (on the remaining qubit)

State before the transformation:
f(0) = f(1): § 1/21/2 (|0i+|1i)
f(0)  f(1): § 1/21/2 (|0i-|1i)

Case 1: f(0)=f(1):
H § 1/21/2 (|0i+|1i) = § |0i
Case 2: f(0) F(1):
H § 1/21/2 (|0i-|1i) = § |1i


Measurement decides between both cases perfectly
Deutsch’s Algorithm
|0i
H
H
Uf
|1i
H
Measurement
Quantum Circuits


We write algorithms as circuits on n qubits, unitary
transformations are written as boxes
Initial states of qubits are denoted on the left side
Deutsch-Josza Algorithm






f:{0,1}n  {0,1}
Is f balanced (50% 0, 50% 1) or constant?
Promise: f is either balanced or constant, if not the output of
the algorithm can be anything
We show an algorithm with 1 query and no error
Any deterministic algorithm needs : 2n/2+1 queries!
Why?
We give an adversary argument:
 Fix f depending on the queries of the algorithm,
f(x1)=0,...,f(xl)=0
 Before l > 2n/2 the algorithm cannot make a “safe”
decision
 Algorithm can be forced to make an error (f might still be
balanced or constant)
Deutsch Josza Algorithm
|0in
n
n
n
Hn
Hn
Uf
|1i
H
Measure
Reminder: Hadamard
Transformation

x,z2{0,1}n and x¢z= xizi

H
⨂n
|xi=
1/2n/2 (|0i +(-1)x(1) |1i)(|0i +(-1)x(n) |1i)
Uf Gate/Black Box



Uf |xi|ai=|xi|a © f(x) i for all x2{0,1}n,a2{0,1}
f:{0,1}n ! {0,1}
© ist XOR Operation: 0©0=0; 0©1=1; 1©1=0
Deutsch Josza Algorithm






n Qubits in state |0ni
1 Qubit in state |1i
⨂n+1
Apply H
, then Uf
Result:
⨂n
Apply H , then measure
Apply: 0n iff f is constant
Deutsch Josza

Then Hadamard

Amplitude of |0ni:

f constant ) § 1
f balanced ) 0

A remark


The Deutsch Josza problem can be solved easily by a
randomized algorithm that is allowed to err with
some small probability
We will soon see quantum algorithms that “do
better”
Deutsch-Josza Algorithm



Deterministic: 2n/2+1 queries
Quantum: 1 query, O(n) gates (local
transformations), no error
Randomized algorithms are also efficient, but they
need to make errors