Quantum states are represented as vectors in a Hilbert space. Defining how these vectors interact is fundamental for analyzing quantum systems. In classical mechanics, vectors are often compared using the dot product to determine angles or projection. Quantum mechanics utilizes two specific operations to extract information from a system or transform it: the inner product and the outer product.
These operations act as the computational engine for quantum algorithms. The inner product allows us to calculate probabilities and check if states are distinct. The outer product allows us to build operators (matrices) from vectors, which is how we construct quantum gates and measurements.
The inner product is a scalar multiplication of two vectors. In Dirac notation, it combines a bra and a ket to form the bracket . The result of this operation is a single complex number, not a vector.
Mathematically, to calculate the inner product of two vectors and , you calculate the conjugate transpose of the first vector and multiply it by the second vector. If we have two column vectors:
The inner product is:
The symbol denotes the complex conjugate. This means if an element is , it becomes . This conjugation is strictly required. Unlike the standard dot product in real Euclidean space, the order matters in complex vector spaces. is the complex conjugate of .
The structural difference between inner and outer products relies on the order of multiplication. The inner product "collapses" the dimensions into a single value.
Dimensionality reduction in the inner product calculation.
The inner product provides the probability amplitude of measuring a system in a specific state. If you have a qubit in state and you want to know the probability of finding it in state , you compute the inner product .
To get the actual probability (a real number between 0 and 1), you take the squared magnitude of this result:
If the inner product is 0, the states are orthogonal. This means they are mutually exclusive. If the system is in one state, it has zero probability of being measured as the other.
In Python, we use NumPy to handle these operations. While np.dot works for real numbers, quantum mechanics requires careful handling of complex conjugates. For 1D arrays, np.vdot is often preferred because it automatically handles the complex conjugation of the first argument. However, when working with explicit matrices (column vectors), we usually define the conjugate transpose manually to maintain clarity.
import numpy as np
# Define a standard state |0>
ket_0 = np.array([[1], [0]])
# Define a state |+> (superposition)
# 1/sqrt(2) * [1, 1]
ket_plus = np.array([[1], [1]]) / np.sqrt(2)
# Calculate Inner Product <0|+>
# Step 1: Create the bra (conjugate transpose of ket_0)
bra_0 = ket_0.conj().T
# Step 2: Matrix multiplication
overlap = np.dot(bra_0, ket_plus)
print(f"Amplitude: {overlap[0][0]}")
print(f"Probability: {abs(overlap[0][0])**2:.2f}")
Running this code yields a probability of approximately 0.5, confirming that the state has a 50% chance of collapsing to .
While the inner product creates a scalar, the outer product creates a matrix (an operator). In Dirac notation, this is written as . Note that the ket comes first, followed by the bra.
If we take the same vectors from before, the multiplication order changes:
The result is an matrix. In quantum computing, matrices represent operators or gates. The outer product is useful for constructing projection operators and density matrices, which are required for advanced noise modeling.
The outer product expands two vectors into a matrix representation.
Dimensionality expansion in the outer product calculation.
A primary application of the outer product is creating projection operators. A projector allows us to filter a state. For example, the operator that projects a generic qubit state onto the axis is defined as:
When you apply this matrix to a vector, it eliminates the component associated with , leaving only the component associated with .
The following chart illustrates the result of the outer product . Since is an equal superposition, the resulting density matrix has equal values of 0.5 distributed across all elements.
Heatmap representation of the matrix resulting from the outer product of the plus state with itself.
We use the function np.outer or standard matrix multiplication to compute this. Note that np.outer in NumPy does not automatically take the complex conjugate of the second vector, so you must pass the conjugate explicitly if you are not constructing the bra manually.
Here is the way to do it using standard matrix multiplication logic ():
# Define state |1>
ket_1 = np.array([[0], [1]])
# Create the projector |1><1|
# We need ket_1 (column) multiplied by bra_1 (row)
bra_1 = ket_1.conj().T
projector_1 = np.dot(ket_1, bra_1)
print("Projector for |1>:")
print(projector_1)
A fundamental axiom of quantum mechanics is that probabilities must sum to 1. This leads to the concept of normalization.
For a state to be a valid physical state, the inner product with itself must equal 1:
This quantity is also known as the squared L2 norm of the vector. If you perform a calculation and the resulting vector has an inner product greater or less than 1, the vector is unnormalized and does not represent a valid closed quantum system.
When you initialize a qubit in a simulator, it usually starts in .
Understanding these two checks is important for debugging quantum circuits. If your inner product is non-zero for states that should be orthogonal, your phases are misaligned. If your self-inner product is not 1, your system has lost probability (non-unitary error).
In the next section, we will look at Unitary Matrices, which are the specific type of matrices that ensure the length of our state vectors, and thus the total probability, always stays equal to 1.
Was this section helpful?
© 2026 ApX Machine LearningEngineered with