How to write a simulator for quantum circuits from scratch: A tutorial

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.

Authors

Institutions

Publication Details

Journal
SciPost Physics Lecture Notes
Published
2026-08-03
DOI
https://doi.org/10.21468/scipostphyslectnotes.131
Primary Topic
Quantum Computing Algorithms and Architecture
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

How to write a simulator for quantum circuits from scratch: A tutorial

Jean‐Marc Robert, Kazuki Ikeda, Michael J. McGuffin
SciPost Physics Lecture Notes
Quantum Computing Algorithms and Architecture
article

How to write a simulator for quantum circuits from scratch: A tutorial

Jean‐Marc Robert, Kazuki Ikeda, Michael J. McGuffin
article en

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.

SciPost Physics Lecture Notes
University of Massachusetts Boston (US), École de Technologie Supérieure (CA)
Openalex Percentile: Top 98%
Quantum Computing Algorithms and Architecture
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

How to write a simulator for quantum circuits from scratch: A tutorial — Jean‐Marc Robert, Kazuki Ikeda, et al. · SciPost Physics Lecture Notes (2026) | TGRS Research Map | TGRS