Skip to content

About

A visual quantum circuit simulator in the browser: watch amplitudes split, turn and cancel. Companion to the book Not Faster, Just Different.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Otherwise: watch amplitudes interfere

A quantum circuit simulator in the browser, built to make one idea visible: a quantum computer does not try every answer at once. It sets up paths whose arrows cancel for wrong answers and add up for the right one.

Live: https://asaptf.github.io/quantum-visual-sim/

Grover's search on two qubits: three states cancelled, the answer certain

It is the companion to the book Not Faster, Just Different: English · Español · Русский

What you can do

  • Build a circuit with 1 to 8 qubits. Drag gates from the dock, or click a gate and then a wire. H, X, Y, Z, S, T, RX/RY/RZ with any angle, CNOT, CZ, SWAP, extra controls on any gate, and measurement. Drag a gate off the circuit to delete it. Undo with ⌘Z.
  • Step through it column by column (← →, Space to play). Each amplitude is drawn as an arrow: its length is the amplitude, its direction is the phase, the filled disc is the probability. On each step the arrows split, travel and add head to tail.
  • Ask why. Click any state to see the paths that lead into it and how their arrows add up, for this step or from the very start. This view works for circuits up to 3 qubits; past that there are too many paths to read.
  • Watch each qubit alone on a 3D Bloch sphere (drag to turn it). The arrow is honest: when a qubit gets entangled, it shrinks, down to a dot for a Bell pair.
  • Measure. Run 1 to 100,000 shots and compare the histogram with the exact probabilities. Mid-circuit measurements collapse the state; click the badge on a measurement to follow the other outcome.
  • Share and export. The circuit lives in the URL. Export it as Qiskit (Python) or OpenQASM 3.
  • Link to an example in a language: ?ex=bell&lang=ru opens the Bell pair in Russian. These short links are what the book prints, and the tests pin them so they keep working.
  • Start from the book's examples: two H gates in a row, a Mach–Zehnder interferometer, the Bell pair, GHZ, the Elitzur–Vaidman bomb tester, thirty-two paths that leave one answer, Deutsch–Jozsa, Bernstein–Vazirani, Grover on 2 and 3 qubits, the 3-qubit QFT and teleportation.
  • English, Spanish and Russian interface.

The "why" panel: four paths into |00⟩, two pointing each way, sum zero

Run it locally

You need Node.js 22.12 or newer.

npm install
npm run dev
npm test
npm run build

npm run build type-checks and writes a static site to dist/. It uses relative paths, so it works from any folder, including a GitHub Pages project site.

How it works

The simulator is a plain state-vector simulator written for this project, with no quantum libraries: 2^n complex amplitudes in two Float64Arrays, gates applied as 2×2 matrices with control masks. Qubit order follows Qiskit: qubit 0 is the rightmost bit.

  • src/sim/ is the engine: state vector, gates, circuit runs with measurement branches, exact outcome distributions and the per-path decomposition behind the "why" panel.
  • src/ui/ is the interface, in plain TypeScript and SVG with no framework. The Bloch sphere is a small canvas 3D renderer written for this project.
  • tests/ checks the physics: Bell and GHZ states, the QFT against the discrete Fourier transform, Grover's success probabilities, norm preservation, the URL format and the exports. If you set QISKIT_PYTHON to a Python that has Qiskit installed, presets and random circuits are also compared against Qiskit's own state vectors.

Licence

Code: MIT.

Fonts are bundled under the SIL Open Font License 1.1: Onest, Literata and JetBrains Mono (licence texts in public/fonts/).

About

A visual quantum circuit simulator in the browser: watch amplitudes split, turn and cancel. Companion to the book Not Faster, Just Different.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages