Skip to content
Single-Qubit Gates (X, Y, Z, H, S, T, and Rotations)

Single-Qubit Gates (X, Y, Z, H, S, T, and Rotations)

February 5, 2025

Single-qubit gates are 2×22\times 2 unitary matrices. They transform a qubit statevector while preserving normalization. Intuitively, most single-qubit gates correspond to rotations of the Bloch sphere.

If you have not read it yet, start with the Bloch sphere overview: Bloch sphere.

A tiny Qiskit helper (statevector)

The quickest way to sanity-check a gate is to look at the resulting statevector:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

def show_state(circuit: QuantumCircuit):
    return Statevector.from_instruction(circuit)

Pauli-X (bit flip)

Matrix:

X=(0110). X=\begin{pmatrix}0&1\\1&0\end{pmatrix}.

Effect:

  • 01\lvert 0\rangle \mapsto \lvert 1\rangle
  • 10\lvert 1\rangle \mapsto \lvert 0\rangle
  • a 180° rotation about the X axis on the Bloch sphere
qc = QuantumCircuit(1)
qc.x(0)
print(show_state(qc))

Pauli-Z (phase flip)

Matrix:

Z=(1001). Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}.

Effect:

  • 0\lvert 0\rangle is unchanged
  • 1\lvert 1\rangle gets a minus sign
  • a 180° rotation about the Z axis

This is the first place where relative phase matters: 12(0+1)\frac{1}{\sqrt{2}}(\lvert 0\rangle+\lvert 1\rangle) and 12(01)\frac{1}{\sqrt{2}}(\lvert 0\rangle-\lvert 1\rangle) are different states.

qc = QuantumCircuit(1)
qc.h(0)     # prepares |+>
qc.z(0)     # flips phase of |1>
print(show_state(qc))  # should match |->

Pauli-Y (bit + phase flip)

Matrix:

Y=(0ii0). Y=\begin{pmatrix}0&-i\\i&0\end{pmatrix}.

Effect:

  • a 180° rotation about the Y axis
  • mixes bit flips with phase factors (ii and i-i)

Hadamard (H)

Matrix:

H=12(1111). H=\frac{1}{\sqrt{2}} \begin{pmatrix}1&1\\1&-1\end{pmatrix}.

Effect:

  • 0+=12(0+1)\lvert 0\rangle \mapsto \lvert +\rangle=\frac{1}{\sqrt{2}}(\lvert 0\rangle+\lvert 1\rangle)
  • 1=12(01)\lvert 1\rangle \mapsto \lvert -\rangle=\frac{1}{\sqrt{2}}(\lvert 0\rangle-\lvert 1\rangle)
qc = QuantumCircuit(1)
qc.h(0)
print(show_state(qc))
Want a focused explanation and common identities like H2=IH^2=I? See What is a Hadamard gate?.

Rotation gates: Rx, Ry, Rz

Rotation gates let you rotate by an arbitrary angle:

  • Rx(θ)R_x(\theta): rotate around X by θ\theta
  • Ry(θ)R_y(\theta): rotate around Y by θ\theta
  • Rz(θ)R_z(\theta): rotate around Z by θ\theta

In practice, RzR_z is especially common because many compilers can implement Z-rotations efficiently (platform dependent).

from math import pi

qc = QuantumCircuit(1)
qc.h(0)
qc.rz(pi/4, 0)
print(show_state(qc))

Phase gates: S and T

The S and T gates are special cases of Z-rotations:

  • SRz(π/2)S \approx R_z(\pi/2) (up to a global phase)
  • TRz(π/4)T \approx R_z(\pi/4) (up to a global phase)

Why do people care?

  • SS and TT appear in fault-tolerant gate sets, compilation, and circuit identities.
When comparing gate matrices, you may see “equal up to a global phase.” Global phase does not affect measurement probabilities, but relative phase does.

Quick exercises

  1. Verify that HXH=ZH X H = Z using a circuit and statevector inspection.
  2. Start from +\lvert +\rangle. Apply Rz(θ)R_z(\theta) for different θ\theta. What changes and what stays the same on the Bloch sphere?

Next

  • For multi-qubit operators and tracing out subsystems: Tensor products and partial trace
  • For phase intuition (why Z rotations matter): we can add a dedicated “global vs relative phase” page next.