Quantum Gates Reference: Symbols, Matrices, and Qiskit, Cirq, and PennyLane Syntax
quantum gatesquantum circuitsQiskitCirqPennyLanequantum programming

Quantum Gates Reference: Symbols, Matrices, and Qiskit, Cirq, and PennyLane Syntax

QQubit365 Editorial Team
2026-11-07
5 min read

A practical quantum gates reference with matrices, state effects, and Qiskit, Cirq, and PennyLane syntax for building and debugging circuits.

Quantum gates are the instructions that transform qubits inside a quantum circuit. This reference explains the most common gates, shows their matrix representations and effects on basis states, and provides equivalent syntax in Qiskit, Cirq, and PennyLane so you can read, translate, and debug circuits with less guesswork.

Overview

A quantum gate is a reversible operation represented by a unitary matrix. Unlike a classical logic gate, it can change probability amplitudes and phases, creating superposition or establishing correlations between qubits. A circuit applies gates in sequence and usually ends with measurement, which converts the quantum state into classical results.

This guide uses the computational basis states |0> and |1>. Matrix order matters: the examples below use the conventional column-vector representation, with the first row and column corresponding to |0>. For multi-qubit operations, the exact ordering of wires should always be checked in the framework and circuit diagram you are using.

The code examples assume these broad import patterns:

  • Qiskit: from qiskit import QuantumCircuit
  • Cirq: import cirq, followed by qubit definitions such as q0, q1 = cirq.LineQubit.range(2)
  • PennyLane: import pennylane as qml, usually inside a QNode or quantum function

Framework APIs can change, so treat the snippets as a compact syntax reference and confirm details against the installed version before moving code into production.

What to track

Single-qubit gates

The following table covers the gates most often used in introductory circuits and algorithm prototypes.

GateMatrixEffectQiskitCirqPennyLane
X (bit flip)[[0,1],[1,0]]|0> → |1>, |1> → |0>qc.x(0)cirq.X(q0)qml.PauliX(wires=0)
Y[[0,-i],[i,0]]Flips the basis state and adds a phaseqc.y(0)cirq.Y(q0)qml.PauliY(wires=0)
Z (phase flip)[[1,0],[0,-1]]|0> → |0>, |1> → -|1>qc.z(0)cirq.Z(q0)qml.PauliZ(wires=0)
H (Hadamard)(1/√2)[[1,1],[1,-1]]|0> → (|0>+|1>)/√2qc.h(0)cirq.H(q0)qml.Hadamard(wires=0)
S[[1,0],[0,i]]Adds a π/2 phase to |1>qc.s(0)cirq.S(q0)qml.S(wires=0)
T[[1,0],[0,e^(iπ/4)]]Adds a π/4 phase to |1>qc.t(0)cirq.T(q0)qml.T(wires=0)

Phase gates do not change the measurement probabilities of a computational-basis state by themselves, but their phase changes become observable when combined with gates such as H. This is why a Z, S, or T gate can matter even when a simple measurement appears unchanged.

Parameterized rotation gates

Rotation gates move a qubit around the Bloch sphere. Their standard matrices are:

  • Rx(θ) = [[cos(θ/2), -i sin(θ/2)], [-i sin(θ/2), cos(θ/2)]]
  • Ry(θ) = [[cos(θ/2), -sin(θ/2)], [sin(θ/2), cos(θ/2)]]
  • Rz(θ) = [[e^(-iθ/2), 0], [0, e^(iθ/2)]]

Equivalent calls are qc.rx(theta, 0), qc.ry(theta, 0), and qc.rz(theta, 0) in Qiskit; cirq.rx(theta)(q0), cirq.ry(theta)(q0), and cirq.rz(theta)(q0) in Cirq; and qml.RX(theta, wires=0), qml.RY(theta, wires=0), and qml.RZ(theta, wires=0) in PennyLane.

Controlled and multi-qubit gates

A controlled gate applies a target operation only when the control qubit is in the required state. The most common example is CNOT, or controlled-X:

CNOT = [[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]

It maps |00> → |00>, |01> → |01>, |10> → |11>, and |11> → |10> when the first qubit is the control. In code, use qc.cx(0, 1), cirq.CNOT(q0, q1), or qml.CNOT(wires=[0, 1]).

Other useful multi-qubit operations include:

  • Controlled-Z: applies a minus sign only to |11>. Use qc.cz(0, 1), cirq.CZ(q0, q1), or qml.CZ(wires=[0, 1]).
  • SWAP: exchanges two qubit states. Its matrix is [[1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]]. Use qc.swap(0, 1), cirq.SWAP(q0, q1), or qml.SWAP(wires=[0, 1]).
  • Toffoli, or CCX: flips the target when both controls are |1>. Use qc.ccx(0, 1, 2), cirq.TOFFOLI(q0, q1, q2), or qml.Toffoli(wires=[0, 1, 2]).

When translating a circuit, preserve control-target order. Swapping the two wires in CNOT changes the operation, even though the same gate name appears in all three frameworks.

Cadence and checkpoints

Use this reference at three practical checkpoints:

  1. Before implementation: write down the intended state transformation and confirm that each gate has the required number of wires.
  2. During translation: compare wire order, angle units, controlled-gate direction, and whether the framework expects positional or named wire arguments.
  3. After an SDK update: run a small basis-state test and inspect the rendered circuit. Check import paths, operation names, parameter conventions, and matrix or unitary inspection tools.

A monthly or quarterly review is reasonable for shared teaching material, notebooks, and internal developer documentation. A personal notebook only needs attention when its environment, framework version, or target hardware changes. For larger experiments, pair gate checks with resource estimates covering qubit count, depth, gate counts, and shots; the quantum circuit resource estimation guide provides a useful planning framework.

How to interpret changes

Not every difference between frameworks indicates a mathematical disagreement. A circuit may look different because one SDK decomposes a high-level operation into native gates, uses a different diagram convention, or represents global phase differently. Focus first on the unitary action and measured output, not only on visual appearance.

For debugging, test simple inputs separately. Apply X to |0> and confirm the result is |1>. Apply H twice and confirm that the original state returns. For CNOT, test all four computational-basis inputs and verify the target flips only when the control is one. These tests isolate wire-order and matrix-convention errors before a larger algorithm obscures them.

Gate choice also depends on the task. H is a common entry point for creating equal superposition. CNOT and CZ are used to create or manipulate entanglement. Rotation gates are useful when an algorithm or variational circuit needs tunable parameters. In a variational workflow, do not select gates only because they are expressive; consider circuit depth, trainability, hardware connectivity, and the validation baseline described in the VQE implementation workflow.

When to revisit

Return to this quantum gates cheat sheet whenever you encounter an unfamiliar symbol, move a circuit between Qiskit, Cirq, and PennyLane, or receive an unexpected measurement distribution. Revisit it before publishing tutorials and after upgrading an SDK, changing simulator backends, or targeting a different hardware device.

For a disciplined update, keep a small regression notebook containing basis-state tests for X, H, CNOT, SWAP, and one parameterized rotation. Record the framework version, imports, circuit diagram, expected matrix action, and measured results. Run that notebook on your monthly or quarterly review schedule. If all checks pass, the reference remains usable; if one fails, isolate whether the cause is an API change, wire convention, parameter unit, decomposition, or environment issue.

Finally, connect gate-level checks to the wider experiment record. Version the code and results using a reproducible workflow, then estimate resources before moving from a simulator to hardware. This makes the gate reference more than a static list: it becomes a repeatable checkpoint for learning quantum programming and building reliable circuits.

Related Topics

#quantum gates#quantum circuits#Qiskit#Cirq#PennyLane#quantum programming
Q

Qubit365 Editorial Team

Quantum Computing Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.