Module_4
Module_4
• Repeat the oracle √N times for a single target and √(N/t) for multiple
targets.
• Finally, validate the states with the values in the database.
Deutsch’s Algorithm
• The problem concerns functions of just one variable.
• The input can be either 0 or 1.
• The output also just takes the values of 0 or 1.
• There are four of these functions that we will denote f0, f1, f2 and f3
• The function f0 sends both inputs to 0 i.e. f0(0)=0 and f0(1)=0
• The function f1 sends 0 to 0 and 1 to 1 i.e. f0(0)=0 and f0(1)=1
• The function f2 sends 0 to 1 and 1 to 0 i.e. f0(0)=1 and f0(1)=0
• The function f3 sends both inputs to 1 i.e. f0(0)=1 and f0(1)=1
• The functions f0 and f3 are called constant functions.
• The output is the same value for both inputs—the output is constant.
• A function is called balanced if it sends half its inputs to 0 and the
other half to 1.
• Both f1and f2 are balanced.
• The question that Deutsch posed is: Given one of these four functions
at random, how many function evaluations do we have to make to
determine whether the function is constant or balanced?
• The classical analysis is as follows.
• We can evaluate our given function at either 0 or 1.
• Supposing that we choose to evaluate it by plugging in 0, then there are
two possible outcomes—either we get 0 or we get 1.
• If we get 0, all we know is f (0 )=0 . The function could be either f0 or f1.
• Since one is constant and the other is balanced, we are forced to evaluate
our function again to decide between them.
• Classically, to answer the question we have to plug both 0 and 1 into the
function.
• We need to make two function evaluations.
• Quantum Version:
• First, we construct gates that correspond to the four functions.
• This says that: If we input |0> ⊗ |0> , it outputs 0 ⊕ fi(0 ) .
• If we input |0> ⊗ |1> , it outputs 0 ⊗ |fi(0 ) ⊕ 1>.
• If we input |1> ⊗ |0> , it outputs 1 ⊗ |fi(1 )>.
• If we input |1> ⊗ |1> , it outputs 1 ⊗ |fi(1 ) ⊕ 1>.
• Notice that for each i, one of fi (0 ) and fi (0)⊕ 1 is equal to 0 and the other
is equal to 1,
• and one of fi (1 ) and fi (1)⊕ 1 is equal to 0 and the other is equal to 1.
• This means that the four outputs always give us the standard basis
elements.
• The little meter symbol at the right end of the top wire means that we are
going to measure this qubit.
• The lack of the meter symbol on the second wire tells us that we won’t be
measuring the second output qubit.
• The qubits 0 ⊗ 1 are input.
• They go through the Hadamard gates, which puts them in the state
• 1/√2 (|0>+ |1>) ⊗ 1/√2 (|0> - |1>) =1/2(|00>-|01>+|10>-|11>).
• These then go through the Fi gate.
• The state become
• ½ (|0>⊗ |fi(0)> −|0> ⊗ |fi(0)> ⊕ |1> + |1>⊗ |fi(1)> −|1> ⊗ |fi(1)>
⊕ |1> )
• This can be rearanged to give
• ½ (|0>⊗ |fi(0)> -|fi(0)> ⊕ |1>) + |1>⊗ (|fi(1)> −|fi(1)> ⊕ |1>)
• |fi(0)> -|fi(0)> ⊕ |1>) is either |0>-|1> or |1> - |0> depending on
whether fi(0) is 0 or 1.
• |fi(0)> -|fi(0)> ⊕ |1>= (-1) fi(0) (|0> - |1>)
• |fi(1)> -|fi(1)> ⊕ |1>= (-1) fi(1) (|0> - |1>)
• The state of our qubits after passing through the Fi gate can then be
written as
• ½ (|0> ⊗ ((-1)fi(0) (|0>-|1>) ) + |1> ⊗ ((-1)fi(1) (|0>-|1>) )
• ½ ((-1)fi(0) (|0> ⊗ ((|0>-|1>) ) + ((-1)fi(1) (|1> ⊗ ((|0>-|1>)))
• ½ ((-1)fi(0) |0>+ (-1)fi(1) |1> ⊗ (|0>-|1>)
• 1/√2 (-1)fi(0) |0>+ (-1)fi(1) |1> ⊗ 1/√2 (|0>-|1>)
• This shows that the two qubits are not entangled, and the top qubit has
state 1/√2 (-1)fi(0) |0>+ (-1)fi(1) |1>
• Let’s examine this state for each of the four possibilities for fi.
• For f0, we have f0(0) =f0(1)=0 so the qubit is (1/√2)(|0>+|1>)
• For f1, we have f1(0)=0 and f1(0)=1 so the qubit is (1/√2)(|0>-|1>)
• For f2, we have f2(0)=1 and f2(0)=0 so the qubit is (-1/√2)(|0>-|1>)
• For f3, we have f3(0)=1=f3(1)=1 so the qubit is (-1/√2)(|0>+|1>)
• The next step in the circuit is to send our qubit through the Hadamard
gate.
• This gate sends (1/√2)(|0>+|1>) to |0> and (1/√2)(|0>-|1>) to |1>.
• If i=0, the qubit is |0>.
• If i=1, the qubit is |1>.
• If i=2, the qubit is -|1>.
• If i=3, the qubit is - |0>.
• If we now measure the qubit in the standard basis, we will get 0 if i is either 0 or
3,
• and we will get 1 if i is either 1 or 2.
• f0 and f3 are the constant functions
• f1 and f2are the balanced.
• So, if after measuring we get 0, we know with certainty that the original function
was constant.
• If we get 1, we know that the original function was balanced.
• For Deutsch’s problem there is therefore a slight speedup using a
quantum algorithm.
• This algorithm has no real practical applications, but, as we noted
earlier, it was the first example of proving that there are quantum
algorithms faster than classical ones.
The Deutsch-Jozsa Algorithm
• Deutsch’s algorithm looked at functions of one variable.
• You were given one of these and had to determine whether it was a constant or
balanced function.
• The Deutsch-Jozsa problem is a generalization of this.
• We now have functions of n variables.
• The inputs for each of these variables can be either 0 or 1.
• The output is either 0 or 1.
• We are told that our function is either constant—all the inputs get sent to 0, or all the
inputs get sent to 1.
• or it is balanced—half the inputs get sent to 0 and the other half to 1.
• If we are given one of these functions at random, how many function evaluations do we
need to determine whether the function belongs to the constant group or to the
balanced group?
• We consider the case when n = 3.
• Our function takes three inputs, each of which can take two values.
• This means that there are 23, or 8, possible inputs: (0,0,0), (0,0,1),
(0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1).
• From the fact that f(0,0,0)= 1, f (0,0,1)= 1, f(0,1,0)= 1, f(0,1,1)= 1, we
cannot determine whether or not the function is balanced.
• We need to ask one more question.
• If the answer to the next question is also 1, then we know the
function is constant.
• If the answer is 0, then we know the function is balanced.
• This analysis works in general.
• Given a function of n variables, there will be 2n possible input strings.
• In the best-case scenario we can obtain the answer with just two
questions to the oracle, but in the worst case it will take us 2n−1 + 1
questions.
• Since the n−1 appears as an exponent, the function is exponential.
• In the worst case it requires an exponential number of inquiries to the
oracle.
• The Deutsch-Jozsa algorithm is a quantum algorithm that just
requires one question to the oracle, so the speedup is substantial!
• Given any function f(x0, x1, ….xn-1)− that has n boolean inputs and has
just one boolean output,
• We construct the gate F given by the following circuit, where the
slashes with n on the top lines indicate that we have n wires in
parallel.
Step 1. The Qubits Pass through the Hadamard Gate