Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Quantum circuit simulator

Build quantum circuits on up to 5 qubits and see every amplitude, the chances, Bloch spheres, entanglement and seeded measurement shots.

State and chances

Each qubit on the Bloch sphere

Measure

How to use

  1. Pick the number of qubits (1 to 5). Every qubit starts as 0, so the circuit starts in the state |00...0>.
  2. Add gates with the menus, or type them one per line: h 0, x 1, cx 0 1 (control 0, target 1), cz 0 1, swap 0 2, ccx 0 1 2, rx 0 pi/2, ry 1 0.3, rz 0 -pi/4, p 0 pi/8, cp 1 0 pi/4. Other names: s, sdg, t, tdg, sx, y, z, cnot, toffoli. A # starts a note.
  3. Press Run. The table lists every basis state with its amplitude, its chance (the amplitude squared) and its phase.
  4. Drag Step through to see the state after each gate; later gates turn grey in the drawing.
  5. Measure runs the circuit many times and counts the results, as a real quantum computer would report them.

Keyboard and touch

TabMove between the menus, the circuit box and the buttons
Left RightOn the Step through slider: one gate back or forward
EnterIn a number box: run the circuit

Tips

  • Start with the Bell example: each qubit alone is a coin toss (its arrow shrinks to the centre of the sphere), yet the two always agree. A shrunken arrow, purity below 1, means the qubit is entangled with the others.
  • A phase never shows up in the chances. Load A hidden phase: Z changes only the sign of |1>, and the last H turns that sign into a certain 1.
  • Measurement counts wobble around the exact chances; more shots make the shares closer.
  • Qubit 0 is the leftmost digit: |10> means qubit 0 is 1 and qubit 1 is 0. Some textbooks and toolkits write the order the other way round.
  • Angles are in radians: pi is half a turn, pi/2 a quarter turn.

About this tool

The simulator keeps the full list of 2n complex amplitudes and applies each gate exactly as its matrix says, so the numbers are the textbook answers, not estimates. Gates follow the common conventions: RX, RY and RZ turn by the angle about their axis (RZ(θ) = diag(e-iθ/2, eiθ/2)), P(φ) and CP(φ) add the phase eiφ to |1> or |11>. Each qubit's Bloch vector comes from its reduced density matrix; purity is (1 + length²)/2.

Measurement shots use a seeded random generator, so a seed always gives the same counts. Real hardware adds noise and errors that this ideal simulator leaves out, and the teleportation example replaces mid-circuit measurements with controlled gates (the deferred measurement principle), which gives the same result. Everything runs in your browser.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product