Pith. sign in

REVIEW 1 cited by

How to Write a Simulator for Quantum Circuits from Scratch: A Tutorial

Not yet reviewed by Pith; the record is open.

This paper has not been read by Pith yet. Machine review is queued; the pith claim, tier, and objections will appear here once it completes.

SPECIMEN: schema-true, not a live event

T0 review · schema-true

One-sentence machine reading of the paper's core claim.

pith:XXXXXXXX · record.json · timestamp

arxiv 2506.08142 v1 pith:KAFHEHDG submitted 2025-06-09 quant-ph

How to Write a Simulator for Quantum Circuits from Scratch: A Tutorial

classification quant-ph
keywords quantumcircuitsothersimulatorcomputequbitsscratchtutorial
verification ladder T0 review T1 audit T2 compute T3 formal T4 reserved
0 comments
read the original abstract

This tutorial guides a competent programmer through the crafting of a quantum circuit simulator from scratch, even for readers with almost no prior experience in quantum computing. Open source simulators for quantum circuits already exist, but a deeper understanding is gained by writing ones own. With roughly 1000-2000 lines of code, one can simulate Hadamard, Pauli X, Y, Z, SWAP, and other quantum logic gates, with arbitrary combinations of control and anticontrol qubits, on circuits of up to 20+ qubits, with no special libraries, on a personal computer. We explain key algorithms for a simulator, in particular: qubit-wise multiplication for updating the state vector, and partial trace for finding a reduced density matrix. We also discuss optimizations, and how to compute qubit phase, purity, and other statistics. A complete example implementation in JavaScript is available at https://github.com/MJMcGuffin/muqcs.js , which also demonstrates how to compute von Neumann entropy, concurrence (to quantify entanglement), and magic, while remaining much smaller and easier to study than other popular software packages.

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Forward citations

Cited by 1 Pith paper

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score.

  1. A Sparse and Truncated State Vector Simulator for Peaked Circuits

    quant-ph 2026-07 conditional novelty 5.0

    A vectorized sparse truncated state-vector simulator (CPU/GPU) recovers the mode of certain peaked quantum circuits by retaining far fewer than 2^n amplitudes via top-k or probability-mass truncation.