Ancilla preparation for the Bernstein-Vazirani algorithm (source code)

= Ancilla preparation for the Bernstein-Vazirani algorithm
{title2=$H|1\rangle=|-\rangle$}

The displayed <Bernstein-Vazirani algorithm> prepares its <ancilla qubit> in the <computational-basis state> $|1\rangle$ before the first <Hadamard gate>. At the <function oracle> it is therefore the $-1$ <eigenstate> $|-\rangle$ of the <Pauli X gate>, which enables <phase kickback>. Preparing $|0\rangle$ instead yields $|+\rangle$ at the <function oracle>; target flips leave this state unchanged, so the data contain no information about $a$.

The <Hadamard-conjugated linear oracle> makes the more general statement transparent. With zero data and initial <ancilla qubit> $\alpha|0\rangle+\beta|1\rangle$, the full fixed <quantum circuit> outputs
$$
\alpha|0\rangle^{\otimes n}|0\rangle+\beta|a\rangle|1\rangle.
$$
For nonzero $a$, the correct data outcome has <probability> $|\beta|^2$. To obtain exact identification for all $a$, this preparation must have $\alpha=0$, so it is $|1\rangle$ up to <global phase>. This is a condition on the prescribed preparation circuit: any alternative <quantum state preparation> that supplies $|-\rangle$ at the <function oracle> is equivalent.