When you encounter quantum algorithms in research papers or documentation, the first hurdle is often the symbols. Quantum mechanics utilizes a specific shorthand for linear algebra known as Dirac notation, or bra-ket notation. For those familiar with Python and NumPy, this is simply a different syntax for representing vectors and matrix operations.
In classical computing, we represent the state of a bit as a scalar value, either 0 or 1. In quantum computing, we represent the state of a qubit as a vector. Dirac notation provides a concise way to write these vectors without constantly drawing matrices.
The most common symbol you will see is the "ket," written as a vertical bar followed by a label and an angle bracket: .
In linear algebra terms, a ket represents a column vector. The label inside the bracket acts as a variable name. It identifies the state. When we talk about the standard states of a qubit, we use the labels "0" and "1". These are known as the computational basis states.
Mathematically, the state corresponds to the classical bit 0, and corresponds to the classical bit 1. However, they are defined as orthogonal column vectors of unit length:
This distinction is important. In Python code, 0 is an integer, but is a NumPy array with shape (2, 1).
Mapping Dirac notation symbols to their underlying column vector structures.
The counterpart to the ket is the "bra," written as . If the ket is a column vector, the bra is a row vector.
Specifically, the bra is the conjugate transpose (or Hermitian conjugate) of the ket. To convert a ket to a bra, you transpose the matrix (flip rows and columns) and take the complex conjugate of each element.
If we have a general state represented by complex numbers and :
Then the corresponding bra is:
Here, the symbol (dagger) denotes the conjugate transpose operation, and the denotes the complex conjugate. Since the basis vectors and typically contain only real numbers (0 and 1), the complex conjugate operation does not change the values, only the orientation from column to row.
The names "bra" and "ket" come from the word "bracket." When you put them together, , you form a complete bracket. This operation represents the inner product (or dot product) of two vectors.
In machine learning, the dot product calculates the projection of one vector onto another. In quantum mechanics, we use the inner product to calculate probabilities and determine how much two states overlap.
The calculation follows standard matrix multiplication rules: a row vector () multiplied by a column vector () results in a scalar ().
For example, calculating the inner product of with itself:
The result is 1. This indicates that the state is normalized.
If we calculate the inner product of and :
The result is 0. This confirms that the states are orthogonal, meaning they are mutually exclusive outcomes perfectly distinguishable from one another.
While the inner product creates a scalar, the outer product creates a matrix (an operator). This is written as . Note the order: the ket (column) comes first, followed by the bra (row).
Multipling a vector by a vector results in a matrix. This operation is fundamental for defining quantum gates and density matrices.
For instance, the outer product acts as a projection operator:
We will utilize outer products heavily in Chapter 2 when defining unitary matrices and quantum operators.
To ground this in your daily workflow, consider how these notations map to NumPy operations. When you set up your environment later in this chapter, you will structure your code to reflect these mathematical objects.
psi = np.array([[alpha], [beta]])psi_dagger = psi.conj().Tnp.dot(phi_dagger, psi)np.dot(psi, phi_dagger)Understanding these underlying linear algebra structures allows you to debug quantum circuits effectively. While frameworks like Qiskit or Cirq abstract the vector math away, the behavior of the system is entirely governed by these matrix operations.
Was this section helpful?
© 2026 ApX Machine LearningEngineered with