Quantum Gates

Quantum gates are reversible transformations applied to qubits. Mathematically they are represented by unitary matrices that preserve the overall probability of a quantum state. Gates may act on a single qubit or on multiple qubits simultaneously. You can implement any of the gates below onto qubits in the Quantum Simulator (opens in a new tab) to see how they affect the Bloch sphere representation.

These are the fundamental building blocks of quantum circuits, allowing us to manipulate qubits and create complex quantum states. Each gate corresponds to a unitary operation that transforms the state of one or more qubits. The following sections describe common single‑qubit and multi‑qubit gates, their matrix representations, and their effects on qubit states.

Single-Qubit Gates

GateMatrixDescription
X[0110]\begin{bmatrix}0&1\\1&0\end{bmatrix}Bit flip analogous to the classical NOT. Rotates the Bloch vector π\pi radians about the X‑axis.
Y[0ii0]\begin{bmatrix}0&-i\\i&0\end{bmatrix}Bit and phase flip. Rotates π\pi about the Y‑axis.
Z[1001]\begin{bmatrix}1&0\\0&-1\end{bmatrix}Phase flip. Rotates π\pi about the Z‑axis.
H12[1111]\tfrac{1}{\sqrt{2}}\begin{bmatrix}1&1\\1&-1\end{bmatrix}Creates superposition by rotating halfway between X and Z.
S[100i]\begin{bmatrix}1&0\\0&i\end{bmatrix}Quarter‑turn phase (π/2\pi/2 about Z).
T[100eiπ/4]\begin{bmatrix}1&0\\0&e^{i\pi/4}\end{bmatrix}Eighth‑turn phase (π/4\pi/4 about Z).

Rotation gates provide arbitrary rotations around the Bloch sphere axes:

Rx(θ)=eiθX/2,Ry(θ)=eiθY/2,Rz(θ)=eiθZ/2.R_x(\theta) = e^{-i\theta X/2}, \quad R_y(\theta) = e^{-i\theta Y/2}, \quad R_z(\theta) = e^{-i\theta Z/2}.

These gates rotate the Bloch vector by an angle θ\theta around the specified axis. For example, Rx(π)R_x(\pi) flips the qubit state, while Ry(π/2)R_y(\pi/2) creates a superposition.

These gates can be expressed in matrix form as:

Rx(θ)=[cosθ2isinθ2isinθ2cosθ2],Ry(θ)=[cosθ2sinθ2sinθ2cosθ2],Rz(θ)=[cosθ2isinθ2isinθ2cosθ2].R_x(\theta) = \begin{bmatrix}\cos\frac{\theta}{2} & -i\sin\frac{\theta}{2}\\-i\sin\frac{\theta}{2} & \cos\frac{\theta}{2}\end{bmatrix}, \quad R_y(\theta) = \begin{bmatrix}\cos\frac{\theta}{2} & -\sin\frac{\theta}{2}\\\sin\frac{\theta}{2} & \cos\frac{\theta}{2}\end{bmatrix}, \quad R_z(\theta) = \begin{bmatrix}\cos\frac{\theta}{2} & -i\sin\frac{\theta}{2}\\i\sin\frac{\theta}{2} & \cos\frac{\theta}{2}\end{bmatrix}.

These matrices describe how the gates transform the state of a qubit. For example, the Hadamard gate HH creates a superposition state from the basis states, while the Pauli gates flip the state or add a phase.

These gates can be visualised on the Bloch sphere, where they correspond to rotations around the axes. For example, the Hadamard gate HH rotates the state vector from the north pole (representing |0⟩) to the equator, creating a superposition of |0⟩ and |1⟩.

The Hadamard gate is particularly important because it creates superposition, allowing quantum algorithms to explore multiple states simultaneously. The Pauli gates are fundamental for manipulating qubit states and creating entanglement.

The single‑qubit gates listed above can be combined to create more complex operations. For example, the Hadamard gate H can be expressed as a rotation around the Y and Z axes:

H=Ry(π/2)Rz(π/2).H = R_y(\pi/2)R_z(\pi/2).

The Hadamard gate rotates the state vector from the north pole (representing |0⟩) to the equator, creating a superposition of |0⟩ and |1⟩.

Any single‑qubit unitary can be decomposed into a sequence of these rotations. A convenient form uses Euler angles

U=eiαRz(β)Ry(γ)Rz(δ),U = e^{i\alpha}R_z(\beta)R_y(\gamma)R_z(\delta),

where the global phase eiαe^{i\alpha} has no observable effect. This decomposition underlies many quantum compilation techniques.

The Quantum Simulator allows you to place single-qubit gates across different lines to observe how entanglement forms.

Multi-Qubit Gates

  • CNOT – Flips the target qubit when the control qubit is |1⟩.
  • CZ – Applies a Z phase to the target conditioned on the control being |1⟩.
  • Swap – Exchanges the states of two qubits.
  • Toffoli (CCNOT) – A two‑control CNOT used for reversible logic.
  • Controlled‑Phase – Adds a phase when all controls are |1⟩.

These gates are combined to create more complex operations and to generate entanglement between qubits. The Quantum Simulator allows you to place multi‑qubit gates across different lines to observe how entanglement forms.

Multi‑qubit gates operate on two or more qubits simultaneously, creating entanglement and enabling complex operations. The most common multi‑qubit gate is the controlled‑NOT (CNOT), which flips the target qubit if the control qubit is in the |1⟩ state. Other multi‑qubit gates include controlled phase gates, swap gates, and Toffoli gates.

These gates can be represented as unitary matrices that act on the joint state of multiple qubits. For example, the CNOT gate acting on qubit 0 (control) and qubit 1 (target) is represented by the matrix:

CNOT=[1000010000010010].CNOT = \begin{bmatrix}1 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0 & 0 & 0 & 1\\0 & 0 & 1 & 0\end{bmatrix}.

Multi‑qubit gates can be visualised as operations on the Bloch spheres of the involved qubits. For example, the CNOT gate creates entanglement by flipping the target qubit based on the state of the control qubit, resulting in a joint state that cannot be factored into individual qubit states. Multi‑qubit gates are essential for creating entangled states and performing complex quantum operations. They allow quantum circuits to implement algorithms that exploit the unique properties of quantum mechanics, such as superposition and entanglement.

Single‑qubit rotations together with the CNOT gate form a universal gate set. That means any unitary acting on a collection of qubits can be approximated to arbitrary precision using only these primitives.

Example: Bell State

A simple circuit that demonstrates entanglement uses a Hadamard gate followed by a CNOT:

  1. Apply H to qubit 0 creating (0+1)/2(|0⟩ + |1⟩)/\sqrt{2}.
  2. Use qubit 0 as the control of a CNOT acting on qubit 1.

The resulting two‑qubit state is

Φ+=12(00+11).|\Phi^+\rangle = \tfrac{1}{\sqrt{2}}(|00\rangle + |11\rangle).

The state of qubit 0 is entangled with the state of qubit 1. The state of qubit 0 is a superposition of |0⟩ and |1⟩ and the state of qubit 1 is a superposition of |0⟩ and |1⟩. When qubit 0 is measured, it collapses to either |0⟩ or |1⟩, and qubit 1 will collapse to the corresponding state. If qubit 0 is measured as |0⟩, then qubit 1 will also be |0⟩. If qubit 0 is measured as |1⟩, then qubit 1 will also be |1⟩.

Measurement of one qubit immediately determines the value of the other because the qubits are entangled. This Bell state is maximally correlated and forms the basis of quantum teleportation and dense coding. Try building this circuit in the simulator and watch the Bloch spheres update after each gate.