Why build a simulator?
It is easy to repeat the language of superposition and interference without being able to calculate what a circuit does. A state-vector simulator makes the mathematics concrete: every state is a vector, every gate a linear operation, and every measurement follows from amplitudes.
It is also the substrate for our central question: the circuits we train and compare against classical baselines run inside this simulator.
Implementation approach
- Represent an n-qubit pure state with 2ⁿ complex amplitudes.
- Implement single-qubit gates and controlled operations using explicit index transformations.
- Check that unitary operations preserve normalization and that known circuits produce the correct output distributions.
- Inspect interference and amplitude amplification in small Grover-style examples.
- Compare simulator results with analytically tractable circuits before attempting more ambitious experiments.
The representation
This straightforward representation is useful for studying small circuits, but it requires exponentially more memory as the number of qubits increases. That constraint is part of the subject, not an implementation mistake.
Related note: taking the transformer apart