Glossary

Matrix Multiplication

Matrix multiplication combines two matrices by taking the dot product of rows from the first matrix with columns from the second. Each entry in the result is the sum of elementwise products between a row of the first and a column of the second. It only works when the number of columns in the first matrix equals the number of rows in the second.

by Frank Zickert
December 16, 2025
Matrix Multiplication

Quantum Computing Isn't Weird. It Is Just Matrix Multiplication

And this is what makes it weird

A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
diagrams are useful, but they also convey a false mental model. They suggest step-by-step updates, as with classic code. Initialize a A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State
do this, then that, then read a value.

This post is accompanied by a PDF file summarizing the key points.

Please Login to Download the PDF (your PyQML subscription works here!)

However, the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
does not work in this way. This is because it is not a list of commands that are executed step by step. Instead, the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
defines a mathematical operator . And applying the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
means applying this operator to the initial state.

Accordingly, Quantum Computing is a different kind of computation that builds upon the phenomena of Quantum Mechanics.
Learn more about Quantum Computing
can be summarized with a single equation:

This is not shorthand. This equation is the full computation written in one line.

The result of this equation is a A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
Learn more about Complex Number
That number is the In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
for the outcome .

Here:

  • is the bra corresponding to the A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
    Learn more about Basis State
    . When multiplied with a A quantum state vector is a mathematical object (usually denoted |ψ⟩) that fully describes the state of a quantum system. Its components give the probability amplitudes for finding the system in each possible basis state. The squared magnitude of each component gives the probability of measuring that corresponding outcome.
    Learn more about Quantum State Vector
    it computes the projection In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
    Learn more about Amplitude
    onto outcome .
  • is the A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
    Learn more about Quantum State
    It is a A vector is a mathematical object that has both magnitude (size) and direction. It’s often represented as an arrow or as an ordered list of numbers (components) that describe its position in space, such as . Vectors are used to represent quantities like velocity, force, or displacement.
    Learn more about Vector
    of A complex number is a number that has two parts: a real part and an imaginary part, written as , where . The real part behaves like ordinary numbers, while the imaginary part represents a direction perpendicular to the real axis on the complex plane. Complex numbers let us represent and calculate quantities involving square roots of negative numbers.
    Learn more about Complex Number
    called In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
    Learn more about Amplitude
    These numbers are not probabilities yet, but they relate to them.
  • is the state before the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
    Learn more about Quantum Circuit
    runs. In practice it is usually the A basis state in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are and ; any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of s and s (e.g., , , , and ), forming an orthonormal basis for the system’s Hilbert space.
    Learn more about Basis State
    .
  • is the state after the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
    Learn more about Quantum Circuit
    finishes.
  • is the operator defined by the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
    Learn more about Quantum Circuit
    Mathematically, it is a single matrix formed by multiplying together the matrices for every gate in the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
    Learn more about Quantum Circuit
    in the exact order they are applied.

To make this idea concrete, we will use one small Qiskit is an open-source Python framework for programming and simulating quantum computers. It lets users create quantum circuits, run them on real quantum hardware or simulators, and analyze the results. Essentially, it bridges high-level quantum algorithms with low-level hardware execution.
Learn more about Qiskit
example depicted in ?. It is simple, but it contains the core ideas of order, In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
manipulation, and projective In quantum computing, measurement is the process of extracting classical information from a quantum state. It collapses a qubit’s superposition into one of its basis states (usually or ), with probabilities determined by the amplitudes of those states. After measurement, the qubit’s state becomes definite, destroying the original superposition.
Learn more about Measurement

hzh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
 
qc = QuantumCircuit(1, 1)
 
qc.h(0)
qc.z(0)
qc.h(0)
 
psi_out = Statevector.from_instruction(qc)
qc.measure(0, 0)
 
print("Statevector:", np.array(psi_out))
print("Probabilities:", psi_out.probabilities())
Listing 1 The HZH Quantum Circuit

This A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
has one A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
Learn more about Quantum Bit
and three A quantum gate is a basic operation that changes the state of one or more qubits, similar to how a logic gate operates on bits in classical computing. It uses unitary transformations, meaning it preserves the total probability (the state’s length in complex space). Quantum gates enable superposition and entanglement, allowing quantum computers to perform computations that classical ones cannot efficiently replicate.
Learn more about Quantum Gate
The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
Learn more about Hadamard Operator
, then The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
then The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
Learn more about Hadamard Operator
again.

At first glance, the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
diagram depicted in ? looks like a sequence of steps. That visual impression is exactly where intuition goes wrong.

Figure 1 Circuit diagram of the HZH sequence

When we the QuantumCircuit(1, 1), we are not running anything. We are defining the space the computation will live in. With one A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states.
Learn more about Quantum Bit
that space is two-dimensional.

Each of the following lines a A quantum gate is a basic operation that changes the state of one or more qubits, similar to how a logic gate operates on bits in classical computing. It uses unitary transformations, meaning it preserves the total probability (the state’s length in complex space). Quantum gates enable superposition and entanglement, allowing quantum computers to perform computations that classical ones cannot efficiently replicate.
Learn more about Quantum Gate
We start with a Hadamard gate, followed by the Z gate, and end with a Hadamard gate.

Finally, we the qubit.

Applying a gate does not mean executing a command in a sequence of commands.

This is because a A quantum gate is a basic operation that changes the state of one or more qubits, similar to how a logic gate operates on bits in classical computing. It uses unitary transformations, meaning it preserves the total probability (the state’s length in complex space). Quantum gates enable superposition and entanglement, allowing quantum computers to perform computations that classical ones cannot efficiently replicate.
Learn more about Quantum Gate
is not an instruction but a matrix. So, the The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
Learn more about Hadamard Operator
corresponds to a fixed matrix, and the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
corresponds to another fixed matrix.

The The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
Learn more about Hadamard Operator
is represented by

The Z gate is represented by

Applying a gate simply means including its matrix as a factor in a matrix product.

Each gate you add changes the product, not by updating a A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State
but by extending the operator that will eventually act on the state.

After all three lines have been written, the circuit defines the following single operator:

This is the standard theoretical definition of a A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
A circuit is a product of A **unitary operator** is a linear operator ( U ) on a complex vector space that satisfies ( U^\dagger U = UU^\dagger = I ), meaning it preserves inner products. In simpler terms, it preserves the **length** and **angle** between vectors—so it represents a **reversible, norm-preserving transformation**. In quantum mechanics, unitary operators describe the evolution of isolated systems because they conserve probability.
Learn more about Unitary Operator
such as the The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
Learn more about Hadamard Operator
, the The Z-gate changes the phase of the state by (or radians) while leaving the state unchanged. This means the amplitude of gains a negative sign, effectively flipping its phase. It's a phase-flip operation that rotates the quantum state vector a half turn around the Z-axis of the Bloch sphere.
Learn more about Z-Gate
, and the The Hadamard operator, often denoted H, is a single-qubit quantum gate that creates an equal superposition of and . In other words, It turns the states of the computational basis and into the states of the Fourier basis and .
Learn more about Hadamard Operator
again. Altogether, the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit
itself is a A **unitary operator** is a linear operator ( U ) on a complex vector space that satisfies ( U^\dagger U = UU^\dagger = I ), meaning it preserves inner products. In simpler terms, it preserves the **length** and **angle** between vectors—so it represents a **reversible, norm-preserving transformation**. In quantum mechanics, unitary operators describe the evolution of isolated systems because they conserve probability.
Learn more about Unitary Operator

At this stage, nothing has happened to a A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State
No In quantum computing an amplitude is a complex number that describes the weight of a basis state in a quantum superposition. The squared magnitude of an amplitude gives the probability of measuring that basis state. Amplitudes can interfere, this means adding or canceling, allowing quantum algorithms to bias outcomes toward correct solutions.
Learn more about Amplitude
have changed. No probabilities exist yet. You have only specified which linear transformation will be applied to a A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State
when the circuit is finally executed.

So, only when this operator is multiplied with an initial state does the computation actually take place.

The key line to run the computation is this one:

1
psi_out = Statevector.from_instruction(qc)

This tells Qiskit is an open-source Python framework for programming and simulating quantum computers. It lets users create quantum circuits, run them on real quantum hardware or simulators, and analyze the results. Essentially, it bridges high-level quantum algorithms with low-level hardware execution.
Learn more about Qiskit
to take the default initial A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin.
Learn more about Quantum State
and apply the transformation defined by the A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically.
Learn more about Quantum Circuit

Qiskit is an open-source Python framework for programming and simulating quantum computers. It lets users create quantum circuits, run them on real quantum hardware or simulators, and analyze the results. Essentially, it bridges high-level quantum algorithms with low-level hardware execution.
Learn more about Qiskit
is computing:

Mathematically, this is

Here, the column A vector is a mathematical object that has both magnitude (size) and direction. It’s often represented as an arrow or as an ordered list of numbers (components) that describe its position in space, such as . Vectors are used to represent quantities like velocity, force, or displacement.
Learn more about Vector
on the right is the initial state is a basis state.
Learn more about
.

This makes the meaning concrete: Qiskit is an open-source Python framework for programming and simulating quantum computers. It lets users create quantum circuits, run them on real quantum hardware or simulators, and analyze the results. Essentially, it bridges high-level quantum algorithms with low-level hardware execution.
Learn more about Qiskit
multiplies three matrices together to form a single operator, and then multiplies that operator with the initial state A vector is a mathematical object that has both magnitude (size) and direction. It’s often represented as an arrow or as an ordered list of numbers (components) that describe its position in space, such as . Vectors are used to represent quantities like velocity, force, or displacement.
Learn more about Vector
to produce the final state.

Moreover, this is exactly why the phrase “the order of gates matters” is so often misunderstood.


When people hear that order matters, they instinctively reach for a familiar explanation. They assume gates must be commands that run one after another, changing the state step by step. Order matters in classical programs, so it must matter here for the same reason.

But that intuition is backwards.

Join to continue

This part is available to PyQML students and above. Log in or start a subscription to unlock member content.

Already a member? Use Log in. New here? Choose Subscribe.