Deutsch-Jozsa Algorithm
Deutsch-Jozsa Algorithm
1 / 18
Resources for this lecture
2 / 18
Computing mathematical functions on quantum computers
3 / 18
Binary numbers and quantum states
4 / 18
Arbitrary mathematical functions as unitaries
Instead, we must use the same trick that allowed us to write down the
Toffoli gates as a quantum (unitary) version of the classical AND gate:
as well as evaluating the function we output the input data:
𝑛 𝑛
𝑥 𝑥
U
𝑦 𝑦⊕𝑓(𝑥)
5 / 18
Constant and balanced function on a single bit
If the input, x, is a single bit (as is the output), then we have four
possible functions:
0 0 𝑥 𝑥
f (x) = 0 Constant
1 0 𝑦 𝑦⊕𝑓(𝑥)
0 1 𝑥 𝑥
f (x) = 1 Constant
1 1 𝑦 X 𝑦⊕𝑓(𝑥)
0 0 𝑥 𝑥
f (x) = x Balanced
1 1 𝑦 𝑦⊕𝑓(𝑥)
0 1 𝑥 𝑥
f (x) = x ⊕ 1 Balanced
1 0 𝑦 X 𝑦⊕𝑓(𝑥)
6 / 18
Deutsch’s algorithm set-up
We want to find out whether a particular function, with one input bit and
one output bit is constant or balanced. Classically, we need to evaluate
the function twice (i.e., for input = 0 and input = 1), but remarkably, we
only need to evaluate the function once quantumly, by using Deutsch’s
algorithm.
We have a two qubit unitary, which is one of the four on the previous
slide (we don’t know which):
𝑥 𝑥
U
𝑦 𝑦⊕𝑓(𝑥)
7 / 18
Deutsch’s algorithm (1)
0 H 𝑥 𝑥 H
1 H 𝑦 𝑦⊕𝑓(𝑥)
𝜓0 𝜓1 𝜓2 𝜓3
|ψ0 i = |01i
8 / 18
Deutsch’s algorithm (2)
1
|ψ1 i = (|00i − |01i + |10i − |11i)
2
Next the unitary is implemented, which sets the second qubit to
y ⊕ f (x), so we have four options for |ψ2 i:
1
f (x) = 0 |ψ2 i = 2 (|00i − |01i + |10i − |11i)
1
f (x) = 1 |ψ2 i = 2 (|01i − |00i + |11i − |10i)
1
f (x) = x |ψ2 i = 2 (|00i − |01i + |11i − |10i)
1
f (x) = x ⊕ 1 |ψ2 i = 2 (|01i − |00i + |10i − |11i)
which factorises as:
± |0i+|1i
√
|0i−|1i
√ if f (0) = f (1)
2 2
|ψ2 i =
± |0i−|1i
√
|0i−|1i
√ if f (0) 6= f (1)
2 2
9 / 18
Deutsch’s algorithm (3)
± |0i+|1i
√
|0i−|1i
√ if f (0) = f (1)
2 2
|ψ2 i =
± |0i−|1i
√
|0i−|1i
√ if f (0) 6= f (1)
2 2
The next step is to use the Hadamard gate to interfere the superposition
on the first qubit, which yields:
± |0i |0i−|1i
√ if f (0) = f (1)
2
|ψ3 i =
|0i−|1i
± |1i √ if f (0) 6= f (1)
2
The final step is to measure the first qubit, and we can see that the
outcome will always be 0 if the function is constant, and 1 if balanced.
We can see that superposition and interference, in some sense, play
complementary roles: we prepare a state in superposition, perform some
operations, and then use interference to discern some global property of
the state.
10 / 18
Quantum computing jargon
Query complexity:
In Deutsch’s algorithm we are not using a quantum computer to
evaluate a “classically difficult” function per se, but rather using
quantum phenomena to reduce the number of queries we need to
make to an unknown function, to ascertain some information
thereabout.
Oracles and black boxes:
In Deutsch’s algorithm, and other query complexity algorithms, we
query U, which is known as a “black box”, or often in quantum
computing an “oracle”. The oracle in Deutsch’s algorithm is
sufficiently simple that we can explicitly express each possible
option, but frequently in quantum computing problems are framed in
terms of oracles, even when this is not the case.
11 / 18
Deutsch-Jozsa algorithm
Academia Europaea
Richard Jozsa
12 / 18
Deutsch’s problem
13 / 18
Deutsch-Jozsa algorithm (1)
The circuit of the Deutsch-Jozsa algorithm closely resembles that of
Deutsch’s algorithm:
𝑛
0 ⊗𝑛 H⊗𝑛 𝑥 𝑥 H⊗𝑛
1 H 𝑦 𝑦⊕𝑓(𝑥)
𝜓0 𝜓1 𝜓2 𝜓3
14 / 18
Deutsch-Jozsa algorithm (2)
X 1
|ψ1 i = √ |xi (|0i − |1i)
x∈{0,1}n
2n+1
15 / 18
Deutsch-Jozsa algorithm (3)
We can now determine whether the function is constant or balanced by
measuring the first n qubits of the final state (i.e., we neglect the final
qubit which is in the |−i state):
X X 1 |0i − |1i
|ψ3 i = √ (−1)x·z+f (x) |zi √
n
2 2 2
z∈{0,1}n x∈{0,1}n
Imagine now that the oracle is held by a person, “Bob”, who is spatially
separated from the person, “Alice”, who is trying to determine whether
the function is constant or balanced.
To resolve an instance of Deutsch’s problem, classically Alice
n
transmits 22 + 1 messages, each of size n bits, and each of which
Bob replies to with a one bit message.
Whereas quantumly the Deutsch-Jozsa algorithm requires only the
transmission of a single n + 1 qubit message by Alice, to which Bob
replies with a n qubit message.
So there is an exponential reduction in the amount of information
transfer required to solve an instance of Deutsch’s problem. 17 / 18
Summary
18 / 18