Quantum Data And Encoding

How Do We Mark the Good Stuff?

The Oracle Of Grover's Algorithm

The oracle is not magic. It is a way to tag the solution

by Frank Zickert
November 03, 2025
How Do We Mark the Good Stuff?

The goal of amplitude amplification is to increase the probability of favorable solutions. In our example, we use the amplitude amplification technique to increase the probability of the winning shell.

Amplitude Amplification

The Strange Art of Amplifying Success
5 min
Eight shells, one hidden gem, and a quantum trick that beats pure chance. Learn how quantum amplitude amplification uses simple geometry to bend probability.

In the previous post we learned that this is a two-step procedure. First, the An oracle is a black-box function that encodes information about a problem—typically deciding whether a given input satisfies some condition. It’s implemented as a quantum operation that can be queried in superposition, allowing a quantum algorithm to extract global properties of the function more efficiently than classical methods. Oracles are central to algorithms like Grover’s and Deutsch–Jozsa, where they guide the computation without revealing internal details.
Learn more about Oracle
reverses the sign of the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
that corresponds to the A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
Learn more about Basis State
that represents the correct answer. Then the The diffusion operator (also called the Grover diffusion operator) is a unitary operation that inverts the amplitude of each state about the average amplitude. It’s used in Grover’s search algorithm to amplify the probability of the marked (target) state. Mathematically, it’s represented as , where is the uniform superposition state.
Learn more about Diffusion Operator
reflects all In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
by the mean, boosting the one that is the farthest from the mean. That is the marked A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State
. The one with a negative In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude

So, the An oracle is a black-box function that encodes information about a problem—typically deciding whether a given input satisfies some condition. It’s implemented as a quantum operation that can be queried in superposition, allowing a quantum algorithm to extract global properties of the function more efficiently than classical methods. Oracles are central to algorithms like Grover’s and Deutsch–Jozsa, where they guide the computation without revealing internal details.
Learn more about Oracle
only job is to reverse the sign of the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
corresponding to the correct answer, as ? shows.

Listing 1 The effect of the oracle on the amplitude of the selected basis state

The oracle marks the correct basis state by reversing its phase, not its probability

But what does it actually mean to reverse the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
of a A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State

After all, Superposition in quantum computing means a quantum bit (qubit) can exist in multiple states (0 and 1) at the same time, rather than being limited to one like a classical bit. Mathematically, it’s a linear combination of basis states with complex probability amplitudes. This allows quantum computers to process many possible inputs simultaneously, enabling exponential speedups for certain problems.
Learn more about Superposition
tells us that every A quantum system is any physical system that is subject to the laws of quantum mechanics, whereby quantities such as energy or spin can only assume discrete (quantized) values. Its behavior is described by a wave function that encodes the probabilities of possible measurement results.
Learn more about Quantum System
is in a A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
Learn more about Complex Number
linear combination of its A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
Learn more about Basis State

  • A single A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
    Learn more about Quantum Bit
    has two A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
    Learn more about Basis State
    : is a basis state.
    Learn more about
    and is a basis state.
    Learn more about
    .
  • A two-A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
    Learn more about Quantum Bit
    A quantum system is any physical system that is subject to the laws of quantum mechanics, whereby quantities such as energy or spin can only assume discrete (quantized) values. Its behavior is described by a wave function that encodes the probabilities of possible measurement results.
    Learn more about Quantum System
    has four A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
    Learn more about Basis State
    : , , , and .
  • A three-A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
    Learn more about Quantum Bit
    A quantum system is any physical system that is subject to the laws of quantum mechanics, whereby quantities such as energy or spin can only assume discrete (quantized) values. Its behavior is described by a wave function that encodes the probabilities of possible measurement results.
    Learn more about Quantum System
    has eight A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
    Learn more about Basis State
    . And so on.

Each of these A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
Learn more about Basis State
has a A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
Learn more about Complex Number
In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
that denotes its contribution to the overall A quantum system is any physical system that is subject to the laws of quantum mechanics, whereby quantities such as energy or spin can only assume discrete (quantized) values. Its behavior is described by a wave function that encodes the probabilities of possible measurement results.
Learn more about Quantum System
A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
Learn more about Complex Number
here means the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
is a two-dimensional A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
Learn more about Complex Number
. This is similar to a 2D A vector is a mathematical object that has both magnitude (size) and direction. It’s often represented as an arrow or as an ordered list of numbers (components) that describe its position in space, such as . Vectors are used to represent quantities like velocity, force, or displacement.
Learn more about Vector
with magnitude (absolute length) and A **quantum phase** is the angle component of a particle’s wavefunction that determines how its probability amplitude interferes with others. It doesn’t affect observable probabilities directly but becomes crucial when comparing two or more states, as phase differences lead to interference effects. Essentially, it encodes the relative timing or “alignment” of quantum waves.
Learn more about Quantum Phase
(direction). See ?.

Figure 1 A complex number and its inversion of the real part

By inversion, we mean that we add a minus sign to the A real number is any number that can represent a distance along a continuous line, including all rational numbers (like fractions and integers) and irrational numbers (like or ). In other words, it’s any number that can appear on the number line. Real numbers exclude imaginary numbers, which involve .
Learn more about Real Number
part of the A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
Learn more about Complex Number
In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude

Apparently, this flip of the sign has no effect on the magnitude. But it changes the direction of the A vector is a mathematical object that has both magnitude (size) and direction. It’s often represented as an arrow or as an ordered list of numbers (components) that describe its position in space, such as . Vectors are used to represent quantities like velocity, force, or displacement.
Learn more about Vector
It changes the A **quantum phase** is the angle component of a particle’s wavefunction that determines how its probability amplitude interferes with others. It doesn’t affect observable probabilities directly but becomes crucial when comparing two or more states, as phase differences lead to interference effects. Essentially, it encodes the relative timing or “alignment” of quantum waves.
Learn more about Quantum Phase
. It marks the favorable A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State


The heart of the An oracle is a black-box function that encodes information about a problem—typically deciding whether a given input satisfies some condition. It’s implemented as a quantum operation that can be queried in superposition, allowing a quantum algorithm to extract global properties of the function more efficiently than classical methods. Oracles are central to algorithms like Grover’s and Deutsch–Jozsa, where they guide the computation without revealing internal details.
Learn more about Oracle
implementation is the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
The The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
rotates a the A quantum state vector is a mathematical object (usually denoted |ψ⟩) that fully describes the state of a quantum system. Its components give the probability amplitudes for finding the system in each possible basis state. The squared magnitude of each component gives the probability of measuring that corresponding outcome.
Learn more about Quantum State Vector
of a A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
Learn more about Quantum Bit
around the axis of the The Bloch sphere is a geometric representation of a single qubit’s quantum state as a point on or inside a unit sphere. The north and south poles represent the classical states |0⟩ and |1⟩, while any other point corresponds to a superposition of them. Its position encodes the qubit’s relative phase and probability amplitudes, making it a visual tool for understanding quantum state evolution.
Learn more about Bloch Sphere

Or, more precisely, it multiplies the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
of is a basis state.
Learn more about
by as cleary shown in ?.

Figure 2 The Pauli-Z operator

This rotation leaves the A quantum state vector is a mathematical object (usually denoted |ψ⟩) that fully describes the state of a quantum system. Its components give the probability amplitudes for finding the system in each possible basis state. The squared magnitude of each component gives the probability of measuring that corresponding outcome.
Learn more about Quantum State Vector
distance from the poles (and thus its In quantum computing, measurement is the process of extracting classical information from a quantum state. It collapses a qubit’s superposition into one of its basis states (usually or ), with probabilities determined by the amplitudes of those states. After measurement, the qubit’s state becomes definite, destroying the original superposition.
Learn more about Measurement
probabilities) unchanged, but reverses its A **quantum phase** is the angle component of a particle’s wavefunction that determines how its probability amplitude interferes with others. It doesn’t affect observable probabilities directly but becomes crucial when comparing two or more states, as phase differences lead to interference effects. Essentially, it encodes the relative timing or “alignment” of quantum waves.
Learn more about Quantum Phase
See ?.

Figure 3 Half rotation around the Z-axis

Marking the State

If the favorable state is is a basis state.
Learn more about
, the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
alone is sufficient. It multiplies the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
of is a basis state.
Learn more about
by and leaves is a basis state.
Learn more about
unchanged.

? shows how we use the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
to flip the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
of a single A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
Learn more about Quantum Bit

amplification.py
1
2
3
4
5
6
7
8
9
from qiskit import QuantumCircuit
 
qc = QuantumCircuit(1)
 
# Create |+> state
qc.h(0)
 
# Oracle: flip phase of |1>
qc.z(0)
Listing 2 The Z-gate
    This code listing
  1. QuantumCircuit from Qiskit,
  2. a QuantumCircuit wit a single A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
    Learn more about Quantum Bit
  3. a The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
    Learn more about Hadamard Operator
    on the qubit to put it into ,
  4. The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
    Learn more about Z-Gate
    that flips the sign of the is a basis state.
    Learn more about
    In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
    Learn more about Amplitude

? depicts the effect the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
has on the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
of a single A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
Learn more about Quantum Bit

Figure 4 The effect of the Z-gate

Marking the State

If we want to reverse the A **quantum phase** is the angle component of a particle’s wavefunction that determines how its probability amplitude interferes with others. It doesn’t affect observable probabilities directly but becomes crucial when comparing two or more states, as phase differences lead to interference effects. Essentially, it encodes the relative timing or “alignment” of quantum waves.
Learn more about Quantum Phase
of is a basis state.
Learn more about
instead, we must first select this state, then apply the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
and then unselect the state again.

Join to continue

This part is available to PyQML students and above. Log in or start a subscription to unlock member content.

Already a member? Use Log in. New here? Choose Subscribe.