Skip to content
DocumentationAvailable

Gate reference

Generated from the same gate registry the simulator executes, so the matrices below are exactly what runs. Rotation gates follow R_P(θ) = exp(−iθP/2); conventions match Qiskit.

Identity

qc.id(qubit)

Leaves the qubit unchanged. Useful as an explicit idle step.

Bloch sphere: No rotation.

Try in Studio →
(1001)\begin{pmatrix}1&0\\0&1\end{pmatrix}

Pauli-X

qc.x(qubit)

Quantum NOT: swaps the amplitudes of |0⟩ and |1⟩.

Bloch sphere: Rotation by π about the X axis.

Try in Studio →
(0110)\begin{pmatrix}0&1\\1&0\end{pmatrix}

Pauli-Y

qc.y(qubit)

Bit flip combined with a relative phase: |0⟩ → i|1⟩, |1⟩ → −i|0⟩.

Bloch sphere: Rotation by π about the Y axis.

Try in Studio →
(0−ii0)\begin{pmatrix}0&-i\\i&0\end{pmatrix}

Pauli-Z

qc.z(qubit)

Phase flip: multiplies the |1⟩ amplitude by −1. Probabilities in the computational basis are unchanged.

Bloch sphere: Rotation by π about the Z axis.

Try in Studio →
(100−1)\begin{pmatrix}1&0\\0&-1\end{pmatrix}

Hadamard

qc.h(qubit)

Maps |0⟩ → |+⟩ and |1⟩ → |−⟩, creating an equal-magnitude superposition from a basis state.

Bloch sphere: Rotation by π about the (X+Z)/√2 axis: swaps the Z and X axes.

Try in Studio →
12(111−1)\tfrac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}

S (phase π/2)

qc.s(qubit)

Applies a relative phase of i to |1⟩. S² = Z.

Bloch sphere: Rotation by π/2 about the Z axis.

Try in Studio →
(100i)\begin{pmatrix}1&0\\0&i\end{pmatrix}

S-dagger

qc.sdg(qubit)

Inverse of S: relative phase −i on |1⟩.

Bloch sphere: Rotation by −π/2 about the Z axis.

Try in Studio →
(100−i)\begin{pmatrix}1&0\\0&-i\end{pmatrix}

T (phase π/4)

qc.t(qubit)

Applies a relative phase e^{iπ/4} to |1⟩. T² = S.

Bloch sphere: Rotation by π/4 about the Z axis.

Try in Studio →
(100eiπ/4)\begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix}

T-dagger

qc.tdg(qubit)

Inverse of T: relative phase e^{−iπ/4} on |1⟩.

Bloch sphere: Rotation by −π/4 about the Z axis.

Try in Studio →
(100e−iπ/4)\begin{pmatrix}1&0\\0&e^{-i\pi/4}\end{pmatrix}

X rotation

qc.rx(theta, qubit)

R_X(θ) = exp(−iθX/2).

Bloch sphere: Rotation by θ about the X axis.

Try in Studio →
(cos⁡θ2−isin⁡θ2−isin⁡θ2cos⁡θ2)\begin{pmatrix}\cos\frac{\theta}{2}&-i\sin\frac{\theta}{2}\\-i\sin\frac{\theta}{2}&\cos\frac{\theta}{2}\end{pmatrix}

Y rotation

qc.ry(theta, qubit)

R_Y(θ) = exp(−iθY/2). Real-valued rotation; R_Y(θ)|0⟩ = cos(θ/2)|0⟩ + sin(θ/2)|1⟩.

Bloch sphere: Rotation by θ about the Y axis.

Try in Studio →
(cos⁡θ2−sin⁡θ2sin⁡θ2cos⁡θ2)\begin{pmatrix}\cos\frac{\theta}{2}&-\sin\frac{\theta}{2}\\\sin\frac{\theta}{2}&\cos\frac{\theta}{2}\end{pmatrix}

Z rotation

qc.rz(theta, qubit)

R_Z(θ) = exp(−iθZ/2). Equals the phase gate P(θ) up to a global phase e^{−iθ/2}.

Bloch sphere: Rotation by θ about the Z axis.

Try in Studio →
(e−iθ/200eiθ/2)\begin{pmatrix}e^{-i\theta/2}&0\\0&e^{i\theta/2}\end{pmatrix}

Phase

qc.p(lambda, qubit)

P(λ) applies the relative phase e^{iλ} to |1⟩. P(π)=Z, P(π/2)=S, P(π/4)=T.

Bloch sphere: Rotation by λ about the Z axis.

Try in Studio →
(100eiλ)\begin{pmatrix}1&0\\0&e^{i\lambda}\end{pmatrix}

CNOT (controlled-X)

qc.cx(control, target)

Flips the target qubit when the control qubit is |1⟩. With H, creates Bell states.

Try in Studio →
(1000000100100100) ∣t c⟩\begin{pmatrix}1&0&0&0\\0&0&0&1\\0&0&1&0\\0&1&0&0\end{pmatrix}_{\,|t\,c\rangle}

Controlled-Z

qc.cz(control, target)

Applies −1 to |11⟩. Symmetric in its two qubits.

Try in Studio →
diag(1,1,1,−1)\mathrm{diag}(1,1,1,-1)

SWAP

qc.swap(qubit_1, qubit_2)

Exchanges the states of two qubits.

Try in Studio →
(1000001001000001)\begin{pmatrix}1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{pmatrix}

Non-unitary operations

Measurement (Z basis)

qc.measure(qubit, clbit)non-unitary

Projective measurement in the computational basis. Outcome k occurs with probability ‖P_k|ψ⟩‖² and the state collapses to P_k|ψ⟩/‖P_k|ψ⟩‖. The result is stored in a classical bit.

Reset

qc.reset(qubit)non-unitary

Returns the qubit to |0⟩ regardless of its state. Non-unitary: if the qubit was entangled or in superposition, the result is a statistical mixture.

Barrier

qc.barrier(*qubits)non-unitary

Does not change the state. Marks a boundary that compilers must not optimize across; useful to group a circuit visually.

Planned operations

  • c_if / if_test — Apply a gate depending on a measured classical bit (needed for teleportation corrections). Planned for Phase 2.
  • noise channels — Requires a density-matrix backend with explicitly stated model assumptions. Planned for Phase 2.