Statevector Simulation
Track: Quantum Gates & Circuits · Difficulty: Beginner · Est: 13 min
Statevector Simulation
Overview
Up to now, we’ve described circuits as sequences of gates acting on a quantum state, followed by measurement.
When you actually “run” a circuit in software, you need a representation of the quantum state. This page answers a practical execution question:
- What does it mean for a simulator to keep a statevector, and what can (and can’t) you learn from it?
Understanding this removes confusion about why simulation can feel “more powerful” than real execution, and it prepares you to interpret measurement results correctly.
Intuition
Before measurement, ideal quantum evolution is deterministic. If you start from a known initial state and apply a fixed sequence of unitary gates, the resulting quantum state is fixed.
The randomness appears only when you measure.
A statevector simulator takes advantage of this:
- it explicitly stores the amplitudes of the full quantum state,
- applies gates as deterministic updates to those amplitudes,
- and (if you choose) computes exact measurement probabilities from those amplitudes.
This is like having access to the “inside” of the quantum state, not just the sampled outcomes. That’s convenient for learning and debugging.
But there is a cost:
- the number of amplitudes grows exponentially with the number of qubits.
Formal Description
What a statevector represents
For qubits, the computational basis consists of basis states. A general pure state can be written as
where:
- is a bitstring like 000…0 or 101…1,
- is the corresponding basis ket,
- is a complex amplitude,
- and normalization means .
The statevector is the list of amplitudes .
Deterministic evolution before measurement
If a circuit applies unitary gates whose overall unitary is , then
This update is deterministic. A statevector simulator computes it directly.
Why simulators can access the full state
In software, the simulator has the data structure holding all amplitudes. So it can:
- print amplitudes,
- compute exact probabilities ,
- compute overlaps and expectation values directly.
A real experiment does not give direct access to all amplitudes; it gives samples from measurement.
Limitations of statevector simulation
The main limitation is scaling.
- For qubits, you store complex numbers.
- Doubling the number of qubits squares the state space size.
So statevector simulation becomes infeasible as grows. This is why “simulating a quantum computer” quickly becomes hard on classical machines.
Worked Example
Consider 2 qubits starting from . Apply H on the first qubit. The resulting state is
A statevector simulator would store four amplitudes corresponding to:
- .
In this example:
- amplitude of is ,
- amplitude of is ,
- the other two amplitudes are 0.
So the simulator can compute exact measurement probabilities:
- , , and .
If you actually measure, you won’t see “50%” directly. You will see a finite list of outcomes, and the frequencies will approach 50% as you repeat.
Turtle Tip
Keep the mental split: unitary evolution is deterministic; measurement produces randomness. Statevector simulation shows you the deterministic state before measurement.
Common Pitfalls
- Don’t confuse “simulator prints amplitudes” with “real devices reveal amplitudes.” Real execution gives samples, not the full statevector.
- Don’t forget the exponential scaling: amplitudes becomes huge quickly.
Quick Check
- For qubits, how many computational-basis amplitudes are in the statevector?
- Before measurement, why is the circuit’s evolution deterministic?
What’s Next
Statevector simulation explains the internal state, but real execution usually gives you samples. Next we explain measurement sampling and shots: why repeated runs are required and how histograms arise from probabilistic measurement.
