Skip to content
Quantum ComputingAN INTERACTIVE OPEN TEXTBOOK
charithj.com.au

Introduction to quantum gates

Small operations on amplitudes become the building blocks of a circuit.

12 min readDr. Charith Jayasekara↓ Chapter PDF
By the end, you’ll be able to
  • Trace the order of operations in a circuit.
  • Distinguish a gate’s effect on amplitudes from its effect on measurement probabilities.

An ideal quantum gate applies a unitary matrix to a state. X exchanges amplitudes. Z changes the sign of the 1 component. H mixes components so they can reinforce or cancel.

If H is applied first and Z second, the resulting state is ZH∣ψ⟩ZH\lvert\psi\rangle. The rightmost matrix acts first. Circuit diagrams here read left to right, so follow the physical order when translating to algebra.

GateAction on a one-qubit state (α,β)T(\alpha,\beta)^T
X(β,α)T(\beta,\alpha)^T
Z(α,−β)T(\alpha,-\beta)^T
H(α+β,α−β)T/2(\alpha+\beta,\alpha-\beta)^T/\sqrt2
S(α,iβ)T(\alpha,i\beta)^T
T(α,eiπ/4β)T(\alpha,e^{i\pi/4}\beta)^T

Apply H to q0 and CX from q0 to q1. Predict which two basis outcomes survive. Use Undo to check the circuit one step at a time.

L02 · INTERACTIVE LABRuns on your device

Quantum gate playground

Gates act on amplitudes. Build a small circuit one operation at a time and compare its exact predictions with repeated measurements.

Make a prediction first

Apply H to q0, then CX from q0 to q1. Which two outcomes should disappear?

Experiment controls

Add a gate · left to right

|00⟩ → I
Maximum 20 gates. CX has q0 as control, q1 as target.
Exact probability
|00⟩
100.0%
|01⟩
0.0%
|10⟩
0.0%
|11⟩
0.0%

Exact ideal-model predictions · run a measurement experiment to compare.

MODEL · Ideal pure-state vector, complex double precisionORDER · q0 is the leftmost bit
Take it further

Create the Bell state, then undo the gates in reverse order. Where did the randomness go?

On ∣0⟩\lvert0\rangle, H followed by Z gives ∣−⟩\lvert-\rangle. Z followed by H gives ∣+⟩\lvert+\rangle. Their Z probabilities match, so add a final H to reveal the difference.

Do not infer that two circuits are equivalent merely because they give the same counts for one input in one basis. A gate is a transformation with a contract over its allowed inputs.

Challenge: find two gates in the table that square to I. Then explain why S is not one of them.

Reference: IBM Quantum — Bits, gates, and circuits.

ONE IDEA FURTHER

Ready for the next step?

Your progress stays in this browser.