Use this file to discover all available pages before exploring further.
View on GitHub
Open this notebook in GitHub to run it yourself
The Grover operator is a unitary used in amplitude estimation and amplitude
amplification algorithms [1].The Grover operator is given byQ=Q(A,χ)=−AS0A−1Sχwhere A is a state preparation operator,A∣0⟩=∣ψ⟩Sχ marks good states and is called an oracle,Sχ∣x⟩={−∣x⟩−∣x⟩if χ(x)=1if χ(x)=0and S0 is a reflection about the zero state.S0=I−2∣0⟩⟨0∣Function: grover_operatorArguments:
oracle: QCallable[QArray[QBit]]
Oracle representing Sχ, accepting quantum state to apply on.
space_transform: QCallable[QArray[QBit]]
State preparation operator A, accepting quantum state to apply on.
packed_vars: QArray[QBit]
Packed form of the variable to apply the grover operator on.
The following example implements a grover search algorithm using the grover operator for a specific oracle, with a uniform superposition over the search space.The circuit starts with a uniform superposition on the search space, followed by 2 applications of the grover operator.
[1] G. Brassard, P. Hoyer, M. Mosca, and A. Tapp, “Quantum
Amplitude Amplification and Estimation,” arXiv:quant-ph/0005055, vol. 305, pp.
53–74, 2002, doi: 10.1090/conm/305/05215.