WOLFRAM NOTEBOOK

The Bernstein-Vazirani algorithm is a quantum algorithm that solves a specific problem known as the "oracle problem". In this problem, we are given a black-box oracle (a function) that computes a dot product between an unknown binary string "s" and an input binary string "x," modulo 2. The goal is to determine the unknown string "s." The Bernstein-Vazirani quantum circuit uses quantum parallelism to determine the unknown string "s" in a single query to the oracle, whereas a classical algorithm would require multiple queries—one for each bit of "s".
Using
QuantumCircuitOperator[{"BernsteinVazirani",st}]
, one can generate the Bernstein–Vazirani for the given secret string st.
Generate Bernstein–Vazirani circuit for the secret string 101:
In[69]:=
bv=QuantumCircuitOperator[{"BernsteinVazirani","101"}]
Out[69]=
QuantumCircuitOperator
Circuit diagram:
In[70]:=
bv["Diagram"]
Out[70]=
Only oracle part of the circuit:
In[72]:=
QuantumCircuitOperator[{"BernsteinVaziraniOracle","101"}]["Diagram"]
Out[72]=
Evaluate the BV circuit and get the measurement:
In[74]:=
meas=bv[]
Out[74]=
QuantumMeasurement
Target: {1,2,3}
Measurement Outcomes: 8
Return quantum probabilities:
In[75]:=
meas["Probabilities"]
Out[75]=
|0000,|0010,|0100,|0110,|1000,|1011,|1100,|1110
In[82]:=
meas["ProbabilityPlot"]
As one can see, the only result corresponds to the secret string.
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.