QSWE
  • Welcome
  • Algorithms
    • BB84
    • Bell Inequality
    • Deutsch
    • Bernstein-Vazirani
    • Simon
  • Code
    • CirQ
      • BB84
      • Bell Inequality
      • Deutsch
      • Bernstein-Vazirani
      • Simon
  • Contact
Powered by GitBook
On this page
  • Objective
  • Classical protocol
  • Quantum protocol​
  • Expectation vs Reality
  1. Algorithms

Bernstein-Vazirani

Supercharging Deutsch-like algorithms

PreviousDeutschNextSimon

Last updated 2 years ago

Code :

The Bernstein-Vazirani (BV) algorithm can be considered an extension of the algorithm, and is in some ways even simpler to implement. However, the output of the BV algorithm is much more useful in practical applications and therefore important to understand.

Objective

Similar to algorithm, we have a oracle that implements a black box function f that maps {Xk}→{0,1}\{X_k\} \rightarrow \{0,1\}{Xk​}→{0,1}, where Xk=xk1...xknX_k = x_{k1}...x_{kn}Xk​=xk1​...xkn​ is a bitstring of length n i.e. xki∈{0,1}x_{ki} \in \{0,1\}xki​∈{0,1}

We know more about the function now, we know that f(X)=s⋅Xmod  2f(X) = s \cdot X \mod 2f(X)=s⋅Xmod2, where s is a unknown bitstring. We want to find s.

Classical protocol

The only way to identify s with classical bit is to query the oracle n times, with n different inputs. The simplest set of such inputs is{100...0∣010...0∣001...0∣...∣000...1}\{100...0 | 010...0 | 001...0| ... | 000...1\} {100...0∣010...0∣001...0∣...∣000...1}.

Quantum protocol​

Using quantum interference and phase kickback, we can solve this problem exactly using just 1 query to the oracle.

  1. Prepare n input qubits in ∣ψ⟩in=∣000...0⟩|\psi\rangle_{in} =|000...0 \rangle∣ψ⟩in​=∣000...0⟩state. Prepare the output qubit in ∣−⟩|-\rangle∣−⟩state.

  2. Apply Hadamard gates to all input qubits. This create a equiprobable superposition of all possible input combinations, i.e. ∣ψ⟩=∑∣Xi⟩|\psi\rangle = \sum |X_i\rangle∣ψ⟩=∑∣Xi​⟩ up to some normalization constant.

  3. Query the oracle with input qubits. The oracle effectively acts on all possible input combinations at the same time.

  4. The trick is how the oracle writes the result of its calculation : using a CNOT on the output qubit. Just like in the Deutsch algorithm, this kicks out the results of the computation and stores it in the phase of the input state. ∣ψ⟩in=∑(−1)s.Xk∣Xk⟩|\psi\rangle_{in} = \sum (-1)^{s.X_k}|X_k\rangle∣ψ⟩in​=∑(−1)s.Xk​∣Xk​⟩

  5. Apply Hadamard gates to the input qubits. This destructively interferes for all XkX_kXk​, except when Xk==sX_k==sXk​==s. therefore now ∣ψ⟩in=∣s⟩|\psi\rangle_{in}=|s\rangle∣ψ⟩in​=∣s⟩.

  6. Measure all input qubits, the result is the bitsting s.

Expectation vs Reality

The key difference between Deutsch and BV algorithms is that we have reduced our undefined function to a well defined function of an unknown bitstring s. While this reduces the space of functions, it makes the algorithm much more powerful in this restricted space.

The algorithm works for any length of string s, which means in principle we can read any s, (even say millions of bits long), with just 1 single query to the function.

However it suffers from the same problem as Deutsch, does such a specific problem ever arise in practice for us to solve?

Cirq
Deutsch
Deutsch