SciPost Submission Page
How to Write a Simulator for Quantum Circuits from Scratch: A Tutorial
by Michael J. McGuffin, Jean-Marc Robert, Kazuki Ikeda
Submission summary
| Authors (as registered SciPost users): | Michael McGuffin |
| Submission information | |
|---|---|
| Preprint Link: | scipost_202508_00028v1 (pdf) |
| Code repository: | https://github.com/MJMcGuffin/muqcs.js |
| Date submitted: | Aug. 11, 2025, 6:58 p.m. |
| Submitted by: | Michael McGuffin |
| Submitted to: | SciPost Physics Lecture Notes |
| Ontological classification | |
|---|---|
| Academic field: | Physics |
| Specialties: |
|
| Approach: | Computational |
Abstract
We guide a competent programmer through the programming of a quantum circuit simulator, supporting quantum logic gates with arbitrary control qubits on 20+ qubits, assuming no previous knowledge of quantum computing. We explain qubit-wise multiplication for updating the state vector; how to compute partial traces on arbitrary subsets of qubits to find reduced density matrices; and computing qubit phase and purity. A sample implementation in JavaScript is provided, which also demonstrates how to compute von Neumann entropy, concurrence (to quantify entanglement), and magic, with source code much smaller and easier to study than other popular software packages.
Current status:
In refereeing
