The Deutsch-Jozsa quantum algorithm solves a very specific problem which, although has little to no practical use, was among the first to show the speedup of quantum computing over classical computing.
The problem statement is as follows: given a boolean function , we must find out whether it is constant (i.e., ) or balanced (i.e., produces 1 on exactly half of the inputs ). We are promised it is either one or the other.
A classical computer would need evaluations of to yield a deterministic answer in the worst case. However, as we will see, the Deutsch-Jozsa quantum algorithm can yield the same answer with just one evaluation of .
The quantum circuit on which this algorithm runs requires qubits. The key of this algorithm is to find a way to implement as a quantum oracle that maps a state to , where denotes the bitwise exclusive-or (XOR) operator (alternatively, addition modulo 2).
A typical circuit implementing the Deutsch-Jozsa algorithm is shown below.
The quantum circuit has the initial state . Let us apply an gate on each of the qubits. This leads us to
In the equality above, the sum runs over all bitstrings of length . We then apply the quantum oracle to the circuit, which maps the state to . We obtain
which tells us that the first qubits are still is the same state as in the case of , but the qubit on position now successfully encodes .
We notice how, if , the state of the last qubit is . Similarly, if , the state of the last qubit is . For this reason, we can rewrite as
We may now ignore the last qubit and only focus on the first qubits. We are left with the following state:
Next, we apply the gate on the first qubits again. We obtain
In the expression above, is the sum of the bitwise product. Again, the sums in the expression of run over all bitstrings of length .
The last step of the algorithm involves measuring the first qubits. Given the state of , the probability of measuring is
We notice how, if (i.e., is constant), will evaluate to
In other words, if is constant, the probability to measure is 1. Similarly, if is balanced, then evaluates to 0, as any value of inside the sum will be canceled out by a value of . Therefore, if is balanced, any state other than will be measured.
Check out the following examples implemented in KetBy.
is balanced
is constant
© 2024 KetBy.com | All rights reserved.
Contact us at ketby.com@gmail.com