
Complex numbers are at the foundation of quantum computing
When a software developer starts studying quantum computing, it is essential to accept that they will have to review linear algebra: vectors, matrices, inner products, eigenvalues…, just as I have described in other articles.
However, there is another mathematical ingredient that may seem secondary at first but is, in reality, everywhere: complex numbers.
They are not there for the sake of mathematical elegance or because someone decided to unnecessarily complicate the notation. Quantum states are described by complex amplitudes, and the operations we perform on them modify both their magnitudes and, especially importantly, their phases. Believe me when I tell you that this is where the real complexity lies: in quantum computing, information is manipulated through phases represented by complex numbers.
And it is precisely in the relationships between those phases that one of the essential mechanisms of quantum computing appears: interference.
If you come from software development, think for a moment about a variable that does not simply contain a value, but enough information to determine how that value can combine with others later on. Something similar happens with a quantum amplitude: knowing only its magnitude is not enough. Its phase also matters.
Let’s start from the beginning.
A complex number is nothing more than two well-organized dimensions
A complex number is usually written as:
, where is the real part, the imaginary part and is the imaginary unit, defined by:
This is basic mathematics that you surely studied at some point in high school.
Although the term “imaginary” may suggest something strange, geometrically the idea is quite simple. We can represent as a point, or as a vector, in a two-dimensional plane: the horizontal axis represents the real part and the vertical axis the imaginary part.
For example:
, corresponds to the point . Its modulus is the distance from the origin:
So far there is not much mystery. But we can describe exactly the same number in another way: instead of indicating how far we move along the real and imaginary axes, we can specify a distance from the origin and an angle.
That is where things start to get interesting for quantum computing.
Polar notation: magnitude and phase
If is the modulus of a complex number and the angle it forms with the real axis, we can write:
This is its polar form. The quantity tells us how “big” the complex number is and determines its phase. Hold on to this concept because I assure you it is vital in quantum computing.
We can recover its Cartesian components with:
For a programmer, we could think of the Cartesian and polar forms as two different representations of the same object. And in essence they are, but the form we choose allows us to develop other concepts later on. Neither changes the underlying mathematical value, but each one makes certain operations more natural. Adding complex numbers is usually convenient in Cartesian form; understanding rotations and phase changes is much more intuitive in polar form.
This last point leads us to one of the most important expressions in the mathematics used in quantum computing.
Euler’s formula: the bridge we need
Euler’s formula states that:
This is one of the most beautiful expressions in mathematics, and it is especially important in quantum computing.
This expression allows the previous polar form to be written much more compactly:
This expression brings together in a single entity the magnitude and the phase .
There is an especially useful geometric interpretation: represents a point of modulus one on the unit circle of the complex plane. Varying is equivalent to moving around that circle. Multiplying by a factor of the form , therefore, introduces a phase rotation.
So, if we have
, and we multiply it by , we get:
The modulus does not change. What changes is the angle.
Hold on to this idea because it will reappear constantly when you analyze quantum circuits and algorithms: many quantum operations can be understood as controlled transformations of amplitudes and phases.
From the complex number to the qubit
Let’s now look at the relationship between complex numbers and the concept of the qubit.
A pure qubit can be written as:
with and the normalization condition:
Here an important difference appears with respect to a classical bit. and are not probabilities. They are complex probability amplitudes (that is, each includes a magnitude and a phase). If we measure the qubit in the computational basis, the probabilities are:
When measuring, we lose direct access to the phase of the amplitudes. This can lead to a wrong conclusion: if the probability depends only on the squared modulus, why do we need the phase?
Here is the subtle and essential point: precisely because amplitudes can combine before measurement. Read that again because this is a fundamental concept.
Quantum computing does not get its interesting behavior from directly observing complex numbers (and this is no coincidence; it is inherited, of course, from quantum mechanics). It gets it from transforming their phase relationships so that some amplitudes reinforce each other and others cancel out before we measure the system.
The essential difference between global phase and relative phase
Consider the state:
If we multiply the entire state by the same phase factor:
both vectors represent the same observable physical state. That common factor is called a global phase.
However, let’s compare:
, with
The probabilities of obtaining or when measuring directly in the computational basis are the same in both cases: . But the states are not equivalent. There is a relative phase difference of between their components.
We can see this by applying another Hadamard gate :
, while:
Have you noticed what just happened? Information that was invisible in a direct measurement has become, through interference, a completely observable (that is, measurable) difference.
That is one of the reasons why thinking only in terms of “probabilities” is insufficient to understand a quantum algorithm. You have to think in terms of complex amplitudes and the relative phases that exist between them.
Phase gates: changing so that apparently nothing changes
A gate acts as follows:
If we apply to , the probability of measuring is still one. At first glance it seems that nothing relevant has happened. However, can be written using Euler as:
The gate has introduced a phase of on that component. More generally, a phase gate can be expressed as:
Its action is:
We are not directly changing . We are modifying its relative phase with respect to . That change can become visible later if the circuit combines the amplitudes again.
In other words, a quantum gate can perform computational work even though an immediate measurement before and after seems to offer exactly the same distribution. Phew, I understand this is not easy to grasp at first.
A quantum algorithm is also interference engineering
This idea appears, in different forms and levels of sophistication, in well-known classic quantum algorithms, but it is essential that you understand this perfectly in order to go deeper into quantum computing and beyond.
In Deutsch-Jozsa, for example, the oracle encodes information about the function in phases through the mechanism known as phase kickback. Then, the Hadamard transformations make the amplitudes interfere and allow distinguishing the constant case from the balanced one under the algorithm’s query model.
The idea can be summarized schematically as:
The value of is encoded in a sign, that is, in a phase difference of . Subsequently, interference converts that phase structure into amplitudes whose measurement provides the information we are looking for.
In Grover’s algorithm we also find related logic. The oracle marks, through a phase inversion, the states that satisfy the search condition. That mark, by itself, does not tell us what the solution is when we measure. The diffusion operator then transforms those phase differences in such a way that the amplitude of the marked state increases. After the appropriate number of iterations, the probability of measuring a solution is high. It is worth being precise: Grover offers a quadratic improvement in the unstructured search model, not an exponential speedup for any search problem.
The Quantum Fourier Transform (QFT) perhaps shows even more clearly the importance of phases. Its transformation can be written as:
Here the complex exponential factors are not ornamental: they encode phase relationships between components. Quantum phase estimation (Quantum Phase Estimation, QPE), a central subroutine in numerous algorithms, uses precisely interference and an inverse Fourier transform to extract information about a phase associated with an eigenvalue of a unitary operator.
In essence, the circuit evolves in a complex space
For a system of qubits, the general pure state is written as:
with
The amplitudes are complex numbers. An ideal quantum circuit successively applies unitary operators to that state vector:
That is why I find it especially useful to think that the execution of a quantum algorithm is a structured evolution of complex amplitudes. The algorithm distributes magnitudes, introduces and modifies relative phases, entangles degrees of freedom when several qubits are involved, and causes interferences that end up concentrating probability on certain results.
We must avoid, however, an oversimplification: a quantum algorithm does not consist solely of “moving or modifying phases”. The amplitudes, the entanglement, the choice of basis, the structure of the Hilbert space and the complete sequence of unitary transformations are all part of the process. But phase is one of the concepts that best explains why working only with classical probabilities is not enough.
A useful way to see it from software
When we implement a circuit simulator, all of this stops being abstract. A state of qubits can be represented, in a direct though costly way, by a vector of complex numbers. Applying a gate is equivalent to transforming that vector through complex linear algebra.
For a developer, this is perhaps the most tangible connection: underneath a high-level API of a quantum framework we find complex vectors, unitary matrices and operations that modify their amplitudes.
The well-known factor then stops seeming like a mathematical oddity. It is part of the structure that allows representing rotations, phases and interferences in a coherent way.
And here appears one of those ideas worth remembering as you continue advancing in quantum computing: two states can initially produce the same measurement probabilities and yet behave differently later because their relative phases are different.
That observation considerably changes the way you look at a circuit.
To wrap up
Complex numbers are not a mathematical appendix of quantum computing. They are part of its natural language, inherent to Dirac notation. Polar notation allows us to separate magnitude and phases; Euler’s formula turns phase rotations into an extraordinarily compact expression, and the unitary dynamics of a circuit transforms complex amplitudes until producing interference patterns that we can exploit computationally.
Deutsch-Jozsa, Grover, the QFT or quantum phase estimation are different examples, but all of them force you, sooner or later, to look beyond probabilities and observe what is happening to the amplitudes before measurement.
For all these reasons, if you come from software development and are learning quantum computing, understanding well is not an academic exercise to get out of the way before moving on to more interesting matters. It is just the opposite: you have probably just arrived at one of the pieces that allow you to understand what a quantum circuit is really doing, running in the guts of a quantum computer.
And the most extraordinary and exciting thing about all this is that nature does it constantly…