ExperimentBeginnerEstablished concept Runs in the browser

Quantum Gates Playground

Quantum Gates Playground

A visual library of the fourteen gates. Drag any gate onto the circuit, and see its matrix and its effect on the state before and after applying it.

Experiment steps

  1. Choose a gate from the library to see its matrix and description.
  2. Drag it onto a qubit wire (or press Enter on it to add it with the keyboard).
  3. Compare the "Before" and "After" columns of amplitudes and probabilities.
  4. Try HZH and compare it with X to see that they match.
Loading the simulator…
Loading the simulator…
What theory predicts and what you observe

Every gate is a unitary matrix: it always preserves normalisation. Some gates change only the phase (Z, S, T and Rz).

Ready-made scenarios

Each scenario opens the simulator with specific settings; the simulator loads only when the scenario is opened.

Hadamard on Basis States

The H gate turns $|0\rangle$ into $|+\rangle$ and $|1\rangle$ into $|-\rangle$, and is its own inverse.

Goal: Learn the table of the H gate's effect on the $Z$ and $X$ bases.

  1. Choose the H gate and the input $|0\rangle$.
  2. Read the two output amplitudes.
  3. Change the input to $|1\rangle$, then $|+\rangle$, then $|-\rangle$.
  4. Conclude that H swaps the two bases.
Loading the simulator…

Theory predicts: $|0\rangle\to|+\rangle$ with amplitudes $(0.7071,\,0.7071)$; $|1\rangle\to|-\rangle$ with amplitudes $(0.7071,\,-0.7071)$; $|+\rangle\to|0\rangle$; $|-\rangle\to|1\rangle$.

S Gate Turns |+⟩ into |i+⟩

The gate $S=\mathrm{diag}(1,i)$ multiplies the amplitude of $|1\rangle$ by $i$, turning $|+\rangle$ into $|i+\rangle=(|0\rangle+i|1\rangle)/\sqrt2$.

Goal: See the effect of a phase gate on the amplitudes without changing the probabilities.

  1. Choose the S gate and the input $|+\rangle$.
  2. Read the two output amplitudes.
  3. Apply $S^\dagger$ (sdg) to the output and check that it returns.
  4. Try S on $|0\rangle$: no change.
Loading the simulator…

Theory predicts the output $(0.7071,\,0.7071i)$, i.e. $|i+\rangle$, with $P(0)=P(1)=0.5$. The effect of S on $|0\rangle$ is the identity.

The SWAP Gate

The SWAP gate exchanges the states of two qubits: $|01\rangle\to|10\rangle$, leaving $|00\rangle$ and $|11\rangle$ unchanged.

Goal: Verify the SWAP gate's table and understand the qubit-ordering convention.

  1. Choose SWAP and the input “01”.
  2. Read the output.
  3. Try “10” and “11”.
  4. Compare with applying three CNOT gates in the circuits lab.
Loading the simulator…

Theory predicts: $|01\rangle\to|10\rangle$ and $|10\rangle\to|01\rangle$ with probability 1, while $|00\rangle$ and $|11\rangle$ stay unchanged.

CZ Adds a −1 Phase to |11⟩

The CZ gate multiplies the amplitude of $|11\rangle$ by $-1$ and leaves the other basis states unchanged; it is symmetric in the two qubits.

Goal: See that some gates change phases rather than probabilities, and that their effect shows up in superpositions.

  1. Choose CZ and the input “11” and read the amplitude.
  2. Try “01” and “10”: no change.
  3. In the circuits lab, apply H to both qubits, then CZ, then H on qubit 1, and measure.
  4. Compare the result with a Bell state.
Loading the simulator…

Theory predicts the output $-|11\rangle$ (amplitude $-1$, probability 1). The other basis states stay unchanged. The suggested circuit produces the Bell state $|\Phi^+\rangle$, so 00 and 11 each appear with probability $1/2$.

Concepts this experiment explains

References

  1. Michael A. Nielsen; Isaac L. Chuang (2010). Quantum Computation and Quantum Information (10th Anniversary Edition). Cambridge University Press doi:10.1017/CBO9780511976667The standard reference for quantum computing; the Crossref record gives 2012 for the Cambridge Core online edition.
  2. A. Barenco; C. H. Bennett; R. Cleve; D. P. DiVincenzo; N. Margolus; P. Shor; T. Sleator; J. A. Smolin; H. Weinfurter (1995). Elementary gates for quantum computation. Phys. Rev. A 52(5):3457–3467 doi:10.1103/PhysRevA.52.3457

Local experiment results come from an exact classical state-vector simulation running in your browser, and computation server results come from Qiskit and PennyLane simulators; neither is equivalent to running on a real quantum computer. Memory doubles with each qubit ($2^n$ amplitudes), so the number of qubits is limited to 16 in the browser.