0% found this document useful (0 votes)
14 views

Deutsch-Jozsa Algorithm

This document provides an overview of the Deutsch-Jozsa algorithm in quantum computing. It begins by explaining how mathematical functions can be executed on a quantum computer as unitary operations. It then describes Deutsch's original algorithm for determining if a function of one bit is constant or balanced by querying it once quantumly. Finally, it introduces the Deutsch-Jozsa algorithm, which generalizes Deutsch's approach to functions of any number of bits.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Deutsch-Jozsa Algorithm

This document provides an overview of the Deutsch-Jozsa algorithm in quantum computing. It begins by explaining how mathematical functions can be executed on a quantum computer as unitary operations. It then describes Deutsch's original algorithm for determining if a function of one bit is constant or balanced by querying it once quantumly. Finally, it introduces the Deutsch-Jozsa algorithm, which generalizes Deutsch's approach to functions of any number of bits.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Quantum Computing (CST Part II)

Lecture 7: Deutsch-Jozsa algorithm

Computer programming is an art form,


like the creation of poetry or music.
Donald Knuth

1 / 18
Resources for this lecture

Deutsch’s algorithm: Nielsen and Chuang p32


Deutsch-Jozsa algorithm: Nielsen and Chuang p34

2 / 18
Computing mathematical functions on quantum computers

In order to design quantum algorithms we need to know how to execute


functions on a quantum computer. In particular, we are interested in
functions that take a (binary) number, and output a truth value (i.e.,
{0, 1}). That is, functions of the form f : {0, 1}n → {0, 1}.

𝑥 = 0,1 𝑛 𝑓(𝑥) 0,1

However, we know that a quantum circuit is composed of quantum gates,


which are unitary operations, and apart from for trivial functions, this is
not a unitary.

3 / 18
Binary numbers and quantum states

It is usually convenient to express the action of a quantum circuit for a


general quantum state and then use linearity to express a sum of
superposed terms if necessary. To do so, we analyse the circuit for a
general n-qubit state:

|xi = |x1 x2 · · · xn i = |x1 i ⊗ |x2 i ⊗ · · · ⊗ |xn i

where xi ∈ {0, 1} for i = 1 · · · n and associated with |xi is the n-bit


binary number x.

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
𝑦 𝑦⊕𝑓(𝑥)

U can easily be seen to be self-inverse, and the universality of quantum


computing implies that any function f (x) can be efficiently encoded in
this way (to desired accuracy) as a quantum circuit consisting of gates
from a finite universal set.

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:

Function x f (x) Type Unitary

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
𝑦 𝑦⊕𝑓(𝑥)

Which we are going to incorporate into a quantum circuit.

7 / 18
Deutsch’s algorithm (1)

0 H 𝑥 𝑥 H

1 H 𝑦 𝑦⊕𝑓(𝑥)
𝜓0 𝜓1 𝜓2 𝜓3

Initially we prepare the state:

|ψ0 i = |01i

Which the initial Hadamard gates put in the superposition state:


  
|0i + |1i |0i − |1i
|ψ1 i = √ √
2 2
1
= (|00i − |01i + |10i − |11i)
2

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

That is the two balanced cases differ only by an unobservable global


phase (and likewise for the two constant cases).

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

Together with Richard Jozsa, who


is now a Professor here in DAMTP,
David Deutsch generalised the
algorithm to apply to constant /
balanced functions of any input
size.

Academia Europaea

Richard Jozsa

12 / 18
Deutsch’s problem

The Deutsch-Jozsa algorithm is usually motivated in terms of Deutsch’s


problem:
We have a function f : {0, 1}n → {0, 1}.
We are promised this function is either constant (same output for
each x) or balanced (f (x) is equal to each of 0 and 1 for exactly
half of the possible values of x).
Classically, we can see that we may need to query the function
2n
2 + 1 times to be sure whether the function is constant or balanced.
But quantumly, if the function is encoded as a quantum oracle, then
the Deutsch-Jozsa algorithm allows us to determine whether the
function is constant or balanced with only a single oracle call.

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

The initial state of which can be expressed:


⊗n
|ψ0 i = |0i |1i

which is then put into superposition, which can conveniently be


expressed:
X 1
|ψ1 i = √ |xi (|0i − |1i)
x∈{0,1}n
2n+1

14 / 18
Deutsch-Jozsa algorithm (2)
X 1
|ψ1 i = √ |xi (|0i − |1i)
x∈{0,1}n
2n+1

The unitary transforms |ψ1 i to:


X 1
|ψ2 i = √ (−1)f (x) |xi (|0i − |1i)
x∈{0,1}n
2n+1

We now address the interference H ⊗n on the first n wires, for which we


use the expression:
1 X
H ⊗n |xi = √ (−1)x·z |zi
2n z∈{0,1}n

which allows us to express:


X X 1 |0i − |1i
|ψ3 i = (−1)x·z+f (x) |zi √
2n 2
x∈{0,1}n z∈{0,1}n

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

Specifically, we consider the probability of measuring zero on every qubit,


⊗n
which corresponds to the term in the superposition where |zi is |0i :

In the case where the function is constant, then the co-efficient of


⊗n P
|0i , x (−1)f (x) /2n is equal to ±1... as this has amplitude 1,
⊗n
then we measure |0i with probability one.
In
P the case where the function is balanced then
f (x) ⊗n
x (−1) /2n = 0, and so we will never measure |0i .

So it follows that measuring the first n qubits allows us to determine


with certainty whether the function is constant (measure all zeros) or
balanced (measure at least one 1).
16 / 18
Potential for exponential speed-up using a quantum
computer

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

We can encode any mathematical function as a unitary matrix.


Deutsch’s algorithm was the first algorithm that demonstrated a
quantum advantage: specifically a reduction in query complexity
compared to the classical case.
The Deutsch-Jozsa algorithm generalises Deutsch’s algorithm, and
reveals the possibility of exponential speed-ups using quantum
computers.

18 / 18

You might also like