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
- Choose a gate from the library to see its matrix and description.
- Drag it onto a qubit wire (or press Enter on it to add it with the keyboard).
- Compare the "Before" and "After" columns of amplitudes and probabilities.
- Try HZH and compare it with X to see that they match.
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.
- Choose the H gate and the input $|0\rangle$.
- Read the two output amplitudes.
- Change the input to $|1\rangle$, then $|+\rangle$, then $|-\rangle$.
- Conclude that H swaps the two bases.
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.
- Choose the S gate and the input $|+\rangle$.
- Read the two output amplitudes.
- Apply $S^\dagger$ (sdg) to the output and check that it returns.
- Try S on $|0\rangle$: no change.
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.
- Choose SWAP and the input “01”.
- Read the output.
- Try “10” and “11”.
- Compare with applying three CNOT gates in the circuits lab.
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.
- Choose CZ and the input “11” and read the amplitude.
- Try “01” and “10”: no change.
- In the circuits lab, apply H to both qubits, then CZ, then H on qubit 1, and measure.
- Compare the result with a Bell state.
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
- 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.
- 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
