The Qubit: introduction to quantum algorithms
Introduction
In popular science contexts, the quantum computer is sometimes labeled as a particular computer that is “incredibly faster.” Although this characterization is not entirely detached from reality, some clarifications are necessary.
A quantum computer is structurally distinct from a classical computer, to such an extent that the logic governing its internal processes departs from conventional logic, as it can only be described through the laws of quantum mechanics.
In order to highlight the innovative aspects introduced by the quantum computational model, it is necessary to recall the classical model of computation, namely the method by which modern computers process information.
Data encoding is performed through sequences of bits. A single bit represents the basic unit of classical information and is described by two possible states, 0 and 1; therefore, any data processed by a computer are represented as a binary string (a sequence of 0s and 1s).
The most significant distinction lies precisely in the different unit of information adopted by a quantum processor: the classical concept of the bit is superseded and generalized by that of the quantum bit, or qubit.
The quantum states describing a qubit are not limited to the values 0 and 1, as is the case for a classical bit, but can assume infinitely many intermediate configurations, giving rise to the phenomenon known in quantum mechanics as superposition.
By exploiting this phenomenon, the scientific community has devised algorithms through which a quantum computer is able to compute a given result in a number of steps that is much smaller than that required by classical counterparts.
With the support of mathematical formalism, the following sections will provide a technical treatment of the qubit and of quantum computing. Finally, an example of quantum speed-up (i.e., a reduction in computational cost) with respect to the classical approach for solving a particular problem will be presented.
Definition of a Qubit
The quantum states 0 and 1 are denoted by the symbols[1]
and
. A generic qubit is given by a linear combination of these two symbols
![]()
where the coefficients
and
satisfy the relation
. This constraint on the coefficients makes it possible to associate
(resp.
) with the probability of observing the state
(resp.
).
Qubits are often represented as points on the so-called Bloch sphere.

Measurement or Observation
The term observation is particularly important in this context. In physics, an observable is defined as any quantity that can be measured directly by appropriate techniques; therefore, in what follows, observation and measurement will be treated as synonyms.
This concept is crucial in distinguishing between classical and quantum mechanics. In classical mechanics, measurement has no effect on the system, as it describes something pre-existing without altering it. For example, consider a runner whose speed is measured: it is evident that the act of measurement does not affect the observable (the speed, in this case) at any moment in time.
In quantum mechanics, by contrast, observing a superposition of quantum states causes the system to collapse irreversibly into a specific state. As a consequence, the original quantum state in its entirety becomes an entity inaccessible to any measuring instrument.
Indeed, in quantum computing, given a qubit
, it is not possible to determine exactly the values
and
that define it. In general, the only feasible approach is to reproduce
multiple times, perform measurements, and estimate the probabilities based on the observed frequencies of 0 and 1 as outcomes.
In summary, the quantum circuit receives the qubit
as input

and returns, irreversibly transforming the qubit,
![Rendered by QuickLaTeX.com \[\begin{aligned}|0\rangle\text{ con probabilità } |\alpha|^2, \\ |1\rangle \text{ con probabilità } |\beta|^2.\end{aligned}\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-054bb6c41be42f3391fea209450ea64a_l3.png)
Quantum Gates
Before proceeding with the description of the transformations characterizing quantum circuits, we formally introduce the concatenation of multiple qubits. Let
=
and
=
be two qubits; their concatenation
![]()
is a 2-qubit system, and note that the coefficients of the symbols
can still be interpreted as probabilities, since
![]()
The same reasoning extends to an
-qubit system, where
is any positive integer.
The operations (quantum gates) through which qubits can be manipulated are largely extensions of the logical gates used in classical computation, with the constraint that the transformation of a qubit must preserve the relation among its coefficients (such transformations are called unitary).
Formally, a transformation acting on a
-qubit
![]()
must satisfy
. Analogously, this relation is preserved in the case of
-qubit systems.
Below we list the most common gates used in the construction of quantum circuits. Their action is shown on
,
in the
-qubit case, and on
in the
-qubit case; this action extends by linearity to generic qubit states.
The gate
or
describes the NOT operation on
-qubit systems.

The gate
describes the CNOT operation and acts on the state of a
-qubit system as a NOT on the second input if and only if the value of the first is
.

The gate
describes the SWAP operation and acts by exchanging the state of a
-qubit system.

Note that the quantum gates described above correspond to operations that admit an equivalent construction in the classical case. The differences between the classical and quantum computational models become evident with quantum gates that, by construction, cannot have a classical counterpart.
For example, the Hadamard gate
is used to generate (uniform) superposition. Indeed, when applied to
or
, it produces a qubit that can assume both values with equal probability.

The gate
acts exclusively on the coefficient of
.

It is worth noting that the set of gates presented is sufficient to describe any quantum gate acting on a generic
-qubit system. A set of gates with this property is called universal.
Finally, given a function
, the gate
is defined for its evaluation,

where in this case the operation
denotes the usual XOR.
Deutsch–Jozsa Algorithm
We now provide an example that offers an initial intuition into the potential of quantum computation by exhibiting a speed-up with respect to the classical model. Consider the functions
![Rendered by QuickLaTeX.com \[\begin{aligned}b_1:\{0,1\} & \longrightarrow\{0,1\} & c_1:\{0,1\} & \longrightarrow\{0,1\} \\0&\longmapsto 0&0&\longmapsto 0\\1&\longmapsto 1&1 &\longmapsto 0\\[5pt] b_2:\{0,1\} & \longrightarrow\{0,1\} &c_2:\{0,1\} &\longrightarrow\{0,1\} \\0 &\longmapsto 1 & 0 &\longmapsto 1\\ 1 & \longmapsto 0 & 1& \longmapsto 1\end{aligned}\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-938dbb7b0c9e53a33abaa69012ae4e77_l3.png)
,
are said to be balanced, since over all possible inputs they return as many 0s as 1s; formally,
. Conversely,
and
are said to be constant, since they return the same output independently of the input.
Consider the following problem: let
be a function known only to belong to the set
. Is
balanced or constant?
In the classical computational model, given an oracle
for evaluating
, the problem is solved by applying the oracle to half of all possible inputs plus
. This corresponds to
evaluations in the
-dimensional case and to
evaluations in the
-dimensional case.
The quantum Deutsch–Jozsa algorithm solves the problem by means of the following circuit, combining the quantum gates
and
introduced previously.

Using this algorithm, the solution requires a single execution of
in the
-dimensional case, and the same result extends straightforwardly to the
-dimensional case. Therefore,
application of
versus
calls to
(in the
-dimensional case) demonstrates an exponential speed-up compared to the classical approach.
The proof follows.
1. The gate
applied to both qubits acts as follows.
![Rendered by QuickLaTeX.com \[|01\rangle\longmapsto\frac{1}{2}\sum_{x\in \{0,1\}}|x\rangle\left(|0\rangle-|1\rangle\right)\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-f1ad692c85f8f4958502cb9a4f59ceab_l3.png)
2. As anticipated, the gate
corresponds to the evaluation of
.
![Rendered by QuickLaTeX.com \[ \begin{aligned} \frac{1}{2}\sum_{x\in \{0,1\}}|x\rangle\left(|0\rangle-|1\rangle\right)\longmapsto & \frac{1}{2}\sum_{x\in \{0,1\}}|x\rangle\left(|f(x)\rangle-|1\oplus f(x)\rangle\right) \\ & = \frac{1}{2}\sum_{x\in \{0,1\}}(-1)^{f(x)}|x\rangle(|0\rangle-|1\rangle) \end{aligned} \]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-31ca2750f22f737b391e8456fac95c12_l3.png)
3. The gate
applied to both qubits computes
![Rendered by QuickLaTeX.com \[\frac{1}{2}\sum_{x\in \{0,1\}}(-1)^{f(x)}|x\rangle(|0\rangle-|1\rangle) \longmapsto \frac{1}{2}\sum_{x,y\in\{0,1\}}(-1)^{f(x)+\langle x,y \rangle}|y\rangle|1\rangle.\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-0b372596c2dbeafb88af857689517cde_l3.png)
4. Measuring the first qubit returns
with probability
![Rendered by QuickLaTeX.com \[\frac{1}{2^{2}}\left|\sum_{x\in\{0,1\}}(-1)^{f(x)+\langle x,y \rangle}\right|^2.\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-68ff619e454e13bc9bdf03c07f4dd450_l3.png)
In the case where
is constant, one obtains
with probability
![Rendered by QuickLaTeX.com \[\frac{1}{2^{2}}\left|\sum_{x\in\{0,1\}}(-1)^{f(x)+\langle x,y \rangle}\right|^2=\frac{1}{2^{2}}\left|\sum_{x\in\{0,1\}}(-1)^{\text{const}+0}\right|^2=1,\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-2913becec5e402062aa5212c5b47586f_l3.png)
whereas in the case where
is balanced, the probability of obtaining
is
![Rendered by QuickLaTeX.com \[\frac{1}{2^{2}}\left|\sum_{x\in\{0,1\}}(-1)^{f(x)+\langle x,y \rangle}\right|^2=\frac{1}{2^{2}}\left|\sum_{x\in\{0,1\}}(-1)^{f(x)+x}\right|^2=1.\]](https://www.telsy.com/wp-content/ql-cache/quicklatex.com-da4737045ad7ba3e56c69f151c9b687b_l3.png)
Consequently, the outcome of the measurement of the first qubit discriminates the nature of the function
: if it is constant, the result is certainly
, whereas if it is balanced, the certain outcome is
. An entirely analogous discussion applies in the
-dimensional case, that is, for
, still requiring only a single application of the gate
.
Sources:
[1] From a mathematical point of view, these symbols represent vectors in the Hilbert space
. This theoretical background is beyond the scope of the present article.
[2] Entity that allows the evaluation of the function
without knowing it explicitly
This article is part of a series of contributions by the Telsy Cryptography Research Group dedicated to quantum computing and its implications for cryptography. For other articles, please refer to the index of the section.
For other articles related to quantum and cryptography, please refer to the relevant categories in the blog.
The authors
Veronica Cristiano, a bachelor’s degree in Mathematics from the University of Pisa and a master’s degree in Mathematics with a specialization in Cryptography at the University of Trento, joined the Telsy Cryptography research group in mid-2021.
Francesco Stocco, a master’s degree in Mathematics at the University of Padua and the Université de Bordeaux attending the course of study “Algebra Geometry And Number Theory” (ALGANT), joined the Telsy research group in Cryptography at end of 2020 focusing in particular on issues related to quantum technologies.