
When you start studying quantum computing, sooner or later expressions like , or appear. If you come from software development, as is my case, your first impression may be that we have left programming behind to suddenly enter the territory of mathematics, and if you are like me, you have completely forgotten even the basics of the linear algebra you studied in high school or later at university, and perhaps this is discouraging and a small barrier that many people do not overcome when entering this discipline of quantum computing.
My purpose with this article is to demystify the linear algebra that describes quantum circuits, so you will see that it is easier than it seems; you just need to dust off some pre-university mathematics.
Dirac notation, also known as bra-ket notation, is essentially a compact language for working with vectors, dual vectors (which we will call brakets) and inner products. Behind symbols that may seem strange at first there are, therefore, linear algebra concepts, but as we will see, it is quite simple to understand.
This matters because quantum computing is built precisely on that mathematical language, and when you program with libraries like Qiskit, you will need to understand this notation well.
That said, we can learn to build circuits with Qiskit and run quantum gates without mastering all the theory behind them down to the smallest detail, in the same way that we can start programming without knowing in depth how a compiler works. However, if we want to understand what quantum algorithms really do, Dirac notation ends up being a tool that is hard to avoid.
With due distance, it is the equivalent of Boolean logic in the implementation of logic gates in classical computing (AND, XOR operations, etc.).
A ket is nothing more than a vector
Let’s start with the symbol you will find everywhere:
It is read “ket psi” and represents a state vector belonging to a complex vector space (which means its elements are complex numbers). In quantum computing, that vector contains the information needed to describe the state of a quantum system.
For a single qubit, the two states of the computational basis are written as:
If you have ever worked with vectors, you already know the idea hidden behind kets. What changes is the notation, which, as we will see, greatly simplifies working with quantum circuits and algorithms.
A qubit, moreover, does not have to be in only one of those two states. It can be in a linear combination of both:
, with and
A linear combination consists of multiplying several vectors by some coefficients and adding them together.
The coefficients and are probability amplitudes (this comes from quantum mechanics). When measuring the qubit in the computational basis, the Born rule assigns the probabilities and to obtaining the results and respectively.
It is worth pausing here for a moment. The quantum state is not a classical list of probabilities. Amplitudes can be complex numbers and their relative phases take part in phenomena such as interference. This difference is one of the reasons why complex linear algebra appears constantly when we study quantum algorithms, since a complex number has a polar representation that includes precisely that relative phase we are talking about; I know I am not being very precise, and that a mathematician could certainly make many qualifications to this description :-)
From ket to bra
Dirac introduced a second piece of notation:
It is read “bra psi”. If the ket is represented by a column vector, its associated bra is the conjugate transpose of that vector:
The asterisk represents the complex conjugate. This operation may seem like a formal detail, but it makes it possible to correctly define the inner product when we work with complex vector spaces.
And here appears the wordplay that gives the notation its name: a bra and a ket together form a bracket.
Conjugate transpose
The conjugate transpose of a vector or matrix is obtained by performing two operations:
- Transpose: swap the rows for the columns.
- Conjugate: replace each complex number with its conjugate, for example, .
For example, given the state:
its conjugate transpose is:
In quantum computing, this operation allows us to go from a ket to its bra . It is represented by the symbol (dagger) and is also called the Hermitian adjoint:
The inner product
Let’s take two states and . We can compute:
This is an inner product and its result is a complex scalar. It gives us information about the relationship between both vectors.
For example:
, while
That is why we say that and are orthogonal and normalized states. They form an orthonormal basis of the state space of a qubit. Due to properties of quantum mechanics, the basis that describes the quantum state must be orthonormal.
We can also check the normalization of a state with:
If we substitute , we recover precisely the previous condition:
In other words, the notation is compact, but underneath we are still doing linear algebra.
The outer product
If we reverse the order we get something different:
Now the result is not a number, but a linear operator, which in a chosen basis we can represent with a matrix.
A particularly useful example is:
This operator is the projector onto the state . Similarly, projects onto . Projectors appear naturally when mathematically describing quantum measurements.
Note the difference, because it is easy to confuse both operations at first:
is a scalar, while
is an operator.
Multiple qubits and the tensor product
So far we have worked with one qubit, but interesting quantum algorithms use registers of several qubits. The operation that allows us to compose their state spaces is the tensor product.
Two qubits in the states and form the state:
In vector form:
For qubits, the state space has dimension . This is a fundamental mathematical property for understanding why the explicit classical description of the full state grows exponentially with the number of qubits. But be careful: this does not imply that any quantum algorithm automatically provides an exponential speedup. The advantage depends on the problem, the algorithm, and the computational model considered.
The tensor product also allows us to express states that cannot be written as a product of individual states. For example, one of the Bell states is:
This is an entangled state: it cannot be factored as . Dirac notation manages to express it in an extraordinarily compact way.
Quantum gates are, in essence, linear algebra operations
An ideal quantum gate on a closed system is modeled by a unitary operator. If represents a gate and the initial state, the evolution is written simply as:
Let’s take the Hadamard gate:
Applied to the state :
Here we begin to truly appreciate the usefulness of the notation. Instead of dragging matrices and column vectors through an entire explanation, something very cumbersome as soon as we have several qubits, we can focus on the transformation of the state.
The same happens with complete sequences of gates. If we first apply and then , we write:
You can already see the usefulness of the notation here, right?
For someone used to programming, we can think of it as a composition or sequence of transformations, but with an important difference: unitary quantum operations obey specific mathematical constraints and, in general, the order of operations matters.
Why Dirac notation helps understand quantum algorithms
Many quantum algorithms can be understood by following the evolution of a state through several transformations. Dirac notation allows us to describe that evolution without losing sight of the mathematical structure.
In algorithms such as Deutsch-Jozsa, Grover or phase estimation, superpositions, basis changes, tensor products, phases and unitary transformations appear constantly. Merely looking at a drawn circuit can show us which gates are executed; also following their states with Dirac notation helps us understand which mathematical transformation the circuit is producing.
This distinction seems useful to me for those of us who come from programming. Quantum SDKs allow us to build circuits relatively soon, but knowing how to write a Hadamard gate in one line of code is not yet the same as understanding what is happening in the state space or what happens when it actually runs on a real quantum computer. To take that next step we need some linear algebra and a suitable language to express it. That language is precisely Dirac notation and, as we have seen, it does not seem so complicated.
What to remember
You don’t need to memorize a huge catalog of symbols to get started. If I had to keep a minimal core, it would be this:
- is a ket, a state vector.
- is its bra, the dual vector obtained by conjugate transposition.
- is an inner product and produces a scalar.
- is an outer product and produces an operator.
- allows composing systems through the tensor product.
- An ideal quantum gate is represented by a unitary operator and transforms states as .
- The condition expresses that the state is normalized.
With these ideas we can already read an important part of the mathematical formulation used in quantum computing without each expression seeming written in a foreign language.
To wrap up
Dirac notation is not a mathematical layer unnecessarily added to quantum computing. It is a concise way of expressing the linear algebra that describes its states and transformations.
My recommendation for a programmer starting out would not be to study the notation in isolation until memorizing it, but to use it. Write and its equivalent vector, apply a Hadamard both ways, compute some inner product, combine two qubits and check how the state vector grows. As soon as you do a few operations by hand, many symbols stop seeming abstract.
And then something interesting happens: quantum circuits begin to look different. They are no longer just a succession of gates, but transformations on vectors in a complex space. It is at that point where Dirac notation begins to become a tool for reasoning about quantum algorithms and not just a particular way of writing mathematics.