The Simon’s algorithm is a quantum algorithm designed to find a hidden string s in a particular class of functions, achieving an exponential speedup over any classical algorithm. In this setting, the hidden string s appears in a bitwise addition relation that plays a role analogous to the period of a function. For this reason, the problem is sometimes referred to as the period-finding problem.
Simon’s algorithm holds historical significance as it was the first to demonstrate an exponential quantum advantage over the best known classical algorithm, revealing how quantum computation can surpass classical methods in well-defined computational tasks. The algorithm was proposed by Daniel R. Simon in 1994 in the paper On the Power of Quantum Computation.
Simon later recounted the story behind his algorithm in a blog article (Grant Salton, Daniel Simon, and Cedric Lin, Exploring Simon’s Algorithm with Daniel Simon, October 11, 2021.):
“I submitted my algorithm to a theoretical computer science conference (STOC 1993), but it was rejected. However, Peter Shor was on the program committee for that conference, and immediately saw the potential (that I had had absolutely no inkling of, to be honest) for applying the same general algorithm structure to concrete problems like factoring and discrete logarithms. After trying unsuccessfully to persuade the committee to accept my paper, he got to work on his own, and submitted it to the next major theoretical computer science conference (FOCS 1993)—in parallel with mine, resubmitted. We had in fact agreed to merge the papers if only his was accepted, but the committee fortunately agreed to accept them both, giving us each credit for our respective portions of the resulting achievement.”
From this account, we see that Simon’s algorithm served as a precursor to Peter Shor’s celebrated factoring algorithm. It laid the conceptual foundation for many of the seminal advances in quantum computation that followed. The problem addressed by Simon’s algorithm can be rigorously stated as follows:
Definition (Simon’s Problem). Let be a function satisfying the periodicity condition: there exists a string
such that
if and only if
for all
, where
denotes bitwise addition modulo two (XOR).
This implies that
can only take one of the following two forms:
• One-to-One Case: If , then
is one-to-one.
• Two-to-One Case: If , then for any distinct
,
if and only if
, so
is two-to-one.
The task is to determine the hidden string using as few evaluations of
as possible, where
is implemented as a black box (oracle).
The secret period bit string is also referred to as a mask—a term commonly used in computer science—and, since it is applied to the inputs via bitwise XOR, it is often called an XOR mask. It is important to distinguish between periodicity under ordinary addition and that under bitwise addition modulo two, as this difference can be subtle for first-time learners. For real-valued periodic functions, if
is a period, then
is also a period. Likewise, if we treat a bit string
as a binary number, then when
is a period, sums such as
,
, and so forth are also periods. In contrast, for functions defined using bitwise addition modulo two, any bit string
satisfies
. This property leads to an important consequence: if a nonzero period exists in this setting, it must be unique.
In the classical setting, we can find the secret XOR mask by identifying a collision—a pair of inputs that produce the same output. More precisely, we query the oracle by sending a bit string
as input and observing the corresponding output
. We then repeat this process for another input
, obtaining
, and continue in this manner for additional queries. By keeping a record of the function values, we eventually find a pair of input strings
and
such that
. According to the defining property of Simon’s problem, this equality implies that the two inputs differ by the secret string, i.e.,
. Using the property that any bit string satisfies
, we can verify that
Thus, the secret string
can be recovered.
Example. Consider the three-bit string . We can compute the bitwise addition
for all
as follows:
A function satisfying Simon’s property with period
must be two-to-one. That is, its outputs are paired as follows:
Where are all distinct. For example, one possible assignment is:
,
,
,
This illustrates that the function naturally pairs inputs that differ by the secret string .
One may now ask how many queries are required to solve Simon’s problem—that is, to determine the secret XOR mask . We have seen that
can be obtained by finding a collision pair, two distinct inputs
and
such that
. The question, then, becomes: how many queries does it take to find such a pair?
A straightforward approach is to query the oracle for every possible input. Since is defined on bit strings of length
, there are
possible inputs in total. By exhaustively querying all of them, we are guaranteed to find a matching pair and thus recover
. However, this brute-force strategy requires up to
queries. In fact, because
is a two-to-one function, it is sufficient to check at most half of the inputs in the worst case. Therefore, we require no more than
queries to find a collision and determine
.
Can we do better than brute-force querying? The answer is yes, if we query with random inputs—but the improvement is limited. By reasoning similar to that used in the birthday paradox (which considers the probability that at least two people in a group of
share the same birthday), we can draw an analogy to Simon’s problem. Roughly speaking, the total number of bit strings,
, is analogous to the total number of days in a year, and the number of queries corresponds to the number of people chosen. More precisely, suppose we query one input
and then another input
. The probability that they form a collision is
, since there are
possible bit strings and we have already queried one. If we query
inputs, there are
pairs of inputs. Hence, the probability of finding at least one collision is approximately
. Assuming a reasonable success probability, for example
, a simple calculation then shows that we expect to find a collision after roughly
queries. This quadratic improvement arises from the probabilistic nature of collisions: as we collect outputs of
, the likelihood of encountering a repeated value increases roughly with the square of the number of queries.
However, Simon’s algorithm performs significantly better, achieving an exponential speedup over classical approaches. It requires the use of a quantum oracle which is given to us as a black box (an “oracle”), and has a similar form to the oracle used in the Deutsch-Jozsa algorithm:
. Here, both
and
are
-qubit states, and the bitwise addition
indicates that they are not treated as ordinary binary numbers, but rather as bit strings under modulo-two addition.
Simon’s algorithm mainly consists of two parts: (i) The quantum part, implemented by the quantum circuit shown in the following Figure, which is run times. (ii) The classical postprocessing, which operates on the measurement outcomes and scales efficiently in
, used to determine the secret XOR mask
.

Exercise. The formula
is a crucial trick that we will use repeatedly hereinafter—prove it and remember it. Notice that we have used the convention .
The following is a detailed breakdown of the algorithm’s steps:
- Initial Setup
Prepare two quantum registers: An-qubit input register initialized to
. An
-qubit output register also initialized to
. The initial state of the system is
.
- Apply Hadamard Gates
Apply the Hadamard gateto all qubits in the input register to create a superposition of all possible input states:
.
The state now becomes.
- Query the Oracle
Use the oracleto compute
for each
:
.
After applying the oracle, the state becomes.
- Apply Hadamard Gates
Apply the Hadamard gateto all qubits in the input register, which gives
, where we use the equation in Exercise.
- Measure the Output Register
Measure the output register and obtain the value. There are two possible cases:
One-to-One Case: Ifis one-to-one, there is only a single
such that
. The post-measurement state becomes
.
Two-to-One Case: Ifis two-to-one, there exist
and
such that
. The post-measurement state is
.
Notice that this measurement step is not strictly necessary, as the result itself is not used in subsequent computations; however, we include it here because it simplifies the analysis and helps illustrate the underlying idea. - Generate Linear Equations
The relationships derived from the measurements create linear equations involving the secret string. If
is one-to-one, measuring the state in the previous step for the input register yields a uniformly random bit string
. If
is two-to-one, however, the measurement returns a random bit string
satisfying
, since otherwise the amplitude
cancels out. Explicitly,
So only the basis statessatisfying
have nonzero amplitude. Since
, we find that
. Thus, each measurement produces a random bit string
orthogonal to
.
- Repeat the Process
Repeat steps 1–6 abouttimes. Each iteration yields a new, independent equation of the form
involving the hidden string
. Since
has
independent components, only
such linear equations are required to determine it. This results in an exponential reduction in the number of queries needed.
- Classical Postprocessing: Solve the System of Equations
Once a sufficient number of equations have been collected:,
, … ,
.
Use classical linear algebra methods (such as Gaussian elimination) to solve for the hidden string.
