Skip to content
Skills Library
Science & research · Learning & explanation

qubits-and-gates

/qubits-and-gates

Use this skill when the user says 'qubit', 'Bloch sphere', 'superposition', 'Hadamard', 'Pauli X Y Z', 'CNOT', 'phase gate', 'T gate', 'rotation gates', 'universal gate set', 'unitary matrix', 'measurement basis'. Explains qubit states, measurement, single- and two-qubit gates with exact matrices and identities, universality (Clifford+T), and verifies them with Qiskit's quantum_info tools. Do NOT use for: entanglement protocols (quantum-computing/quantum-entanglement), algorithm design (quantum-computing/quantum-algorithms), or hardware/QEC topics (quantum-computing/quantum-error-correction).

Licence
MIT
Last repository change
10.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 10.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use this skill when the user says 'qubit', 'Bloch sphere', 'superposition', 'Hadamard', 'Pauli X Y Z', 'CNOT', 'phase gate', 'T gate', 'rotation gates', 'universal gate set', 'unitary matrix', 'measurement basis'. Explains qubit states, measurement, single- and two-qubit gates with exact matrices and identities, universality (Clifford+T), and verifies them with Qiskit's quantum_info tools. Do NOT use for: entanglement protocols (quantum-computing/quantum-entanglement), algorithm design (quantum-computing/quantum-algorithms), or hardware/QEC topics (quantum-computing/quantum-error-correction).

Triggers from the description

qubitBloch spheresuperpositionHadamardPauli X Y ZCNOTphase gateT gate
Original author description

Use this skill when the user says 'qubit', 'Bloch sphere', 'superposition', 'Hadamard', 'Pauli X Y Z', 'CNOT', 'phase gate', 'T gate', 'rotation gates', 'universal gate set', 'unitary matrix', 'measurement basis'. Explains qubit states, measurement, single- and two-qubit gates with exact matrices and identities, universality (Clifford+T), and verifies them with Qiskit's quantum_info tools. Do NOT use for: entanglement protocols (quantum-computing/quantum-entanglement), algorithm design (quantum-computing/quantum-algorithms), or hardware/QEC topics (quantum-computing/quantum-error-correction).

How it works

  1. Purpose
  2. Agent Protocol
  3. Qubit States
  4. Single-Qubit Gates
  5. Two-Qubit Gates
  6. Universality and Classical Simulability
  7. Verify with Qiskit
  8. Common Confusions
  9. Checklist
  10. References
Original SKILL.md headings · 112 lines, 799 words
SKILL.md preview
---
name: qubits-and-gates
description: >
  Use this skill when the user says 'qubit', 'Bloch sphere', 'superposition', 'Hadamard', 'Pauli X Y Z', 'CNOT', 'phase gate', 'T gate', 'rotation gates', 'universal gate set', 'unitary matrix', 'measurement basis'. Explains qubit states, measurement, single- and two-qubit gates with exact matrices and identities, universality (Clifford+T), and verifies them with Qiskit's quantum_info tools. Do NOT use for: entanglement protocols (quantum-computing/quantum-entanglement), algorithm design (quantum-computing/quantum-algorithms), or hardware/QEC topics (quantum-computing/quantum-error-correction).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
tags: [quantum-computing, qubits-and-gates, bloch-sphere, unitary, clifford, qiskit]
---

# Qubits & Gates

## Purpose
Give precise, checkable foundations: what a qubit state is, how measurement works, the standard gates as matrices, the identities used to simplify circuits, and why {Clifford + T} is universal. Every claim here can be verified numerically with `qiskit.quantum_info`.

## Agent Protocol

### Trigger
"qubit", "Bloch sphere", "superposition", "Hadamard", "Pauli", "CNOT", "CZ", "S gate", "T gate", "Rx/Ry/Rz", "universal gates", "unitary", "global phase".

### Input Context
- Concept to explain or circuit to analyze/simplify.
- Desired level (intuition vs matrices).

### Output Artifact
Explanation with matrices/states, identities used, and a numeric verification snippet.

### Response Format
```
State/Gate: {name} = {matrix or ket}
Action: {on |0>, |1>, |+>, |->}
Bloch: {rotation axis, angle}
Identity used: {e.g. HZH = X}
Verify: Operator(...).equiv(...) -> True
```

### Completion Criteria
- [ ] Matrices and conventions stated (basis order, Qiskit little-endian for multi-qubit).
- [ ] Global vs relative phase distinguished.
- [ ] Claims verified numerically where possible.

## Qubit States
- |ψ⟩ = α|0⟩ + β|1⟩, α, β ∈ ℂ, |α|² + |β|² = 1.
- Bloch form: |ψ⟩ = cos(θ/2)|0⟩ + e^{iφ} sin(θ/2)|1⟩ (global phase dropped; it is unobservable).
- Measurement in the Z basis yields 0 with probability |α|² (Born rule) and collapses the state. Measuring another basis = rotate, then measure Z.
- Useful states: |+⟩ = (|0⟩+|1⟩)/√2, |−⟩ = (|0⟩−|1⟩)/√2, |±i⟩ = (|0⟩ ± i|1⟩)/√2.
- n qubits live in ℂ^(2ⁿ); simulating them classically in general needs exponential memory.

## Single-Qubit Gates
| Gate | Matrix | Bloch action |
|---|---|---|
| X | [[0,1],[1,0]] | π about x (bit flip) |
| Y | [[0,−i],[i,0]] | π about y |
| Z | [[1,0],[0,−1]] | π about z (phase flip) |
| H | (1/√2)[[1,1],[1,−1]] | π about (x+z)/√2; maps Z-basis ↔ X-basis |
| S | [[1,0],[0,i]] | π/2 about z; S² = Z |
| T | [[1,0],[0,e^{iπ/4}]] | π/4 about z; T² = S |
| Rx(θ) | exp(−iθX/2) | θ about x |
| Ry(θ) | exp(−iθY/2) | θ about y |
| Rz(θ) | exp(−iθZ/2) | θ about z (equals P(θ) up to global phase) |

Identities: HXH = Z, HZH = X, HYH = −Y, XYZ = iI, Y = iXZ, X² = Y² = Z² = H² = I. Any single-qubit unitary = e^{iα} Rz(β) Ry(γ) Rz(δ) (ZYZ Euler decomposition).

## Two-Qubit Gates
- **CNOT (CX)**: flips the target if the control is 1. In basis |control,target⟩: |00⟩→|00⟩, |01⟩→|01⟩, |10⟩→|11⟩, |11⟩→|10⟩.
- **CZ**: phase −1 on |11⟩; symmetric in its qubits. CX = (I⊗H) CZ (I⊗H) with H on the target.
- **SWAP** = three CNOTs alternating direction.
- **Controlled phase CP(λ)**: phase e^{iλ} on |11⟩ (used in the QFT).
- Phase kickback: CNOT with target in |−⟩ applies a phase to the control; basis of oracles.

## Universality and Classical Simulability
- {H, S, CNOT} generate the **Clifford group**; Clifford circuits on stabilizer states are efficiently simulable classically (Gottesman-Knill theorem).
- Adding T gives a universal set: any unitary can be approximated to precision ε with O(logᶜ(1/ε)) gates (Solovay-Kitaev); fault-tolerant cost is dominated by T gates.
- Hardware native sets differ (e.g. {√X, Rz, CZ/ECR}); the transpiler rewrites circuits into them.

## Verify with Qiskit

```python
import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit.library import HGate, SGate, TGate, XGate, ZGate
from qiskit.quantum_info import Operator, Statevector

# HZH = X
qc = QuantumCircuit(1); qc.h(0); qc.z(0); qc.h(0)
assert Operator(qc).equiv(Operator(XGate()))

# T^2 = S, S^2 = Z
assert (Operator(TGate()) @ Operator(TGate())).equiv(Operator(SGate()))
assert (Operator(SGate()) @ Operator(SGate())).equiv(Operator(ZGate()))

# CX = (I ⊗ H) CZ (I ⊗ H), target = qubit 1
a = QuantumCircuit(2); a.cx(0, 1)
b = QuantumCircuit(2); b.h(1); b.cz(0, 1); b.h(1)
assert Operator(a).equiv(Operator(b))

# Bloch state with theta, phi and its measurement probabilities
theta, phi = np.pi / 3, np.pi / 4
psi = Statevector([np.cos(theta / 2), np.exp(1j * phi) * np.sin(theta / 2)])
print(psi.probabilities())          # [0.75, 0.25]
```

`Operator.equiv` ignores global phase; use `==` for exact equality including phase.

## Common Confusions
- Superposition is not "being 0 and 1 at once" in a classical sense; it is a vector whose amplitudes interfere.
- Relative phase matters (|+⟩ vs |−⟩ give identical Z-basis statistics but differ in X basis); global phase does not.
- Qiskit prints multi-qubit states/bitstrings little-endian (qubit 0 rightmost), while many textbooks use big-endian.
- Measurement is not unitary and cannot be undone.

## Checklist
- [ ] Basis and endianness conventions stated.
- [ ] Matrices correct (normalization factors, signs).
- [ ] Identities verified with `Operator.equiv`.
- [ ] Phase type (global/relative) identified when relevant.

## References
- Nielsen & Chuang, "Quantum Computation and Quantum Information", ch. 1, 2, 4.
- Gottesman, "The Heisenberg Representation of Quantum Computers" (1998) — Gottesman-Knill.
- Qiskit `quantum_info` documentation (Operator, Statevector).

Versions

The database has no other skills named qubits-and-gates.

Database snapshot: 13.11.2026 · package version ab12018eecdf (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100quantum-entanglement
    Use this skill when the user says 'entanglement', 'Bell state', 'EPR pair', 'CHSH', 'Bell inequality', 'quantum teleportation', 'superdense coding', 'GHZ state', 'no-communication theorem', 'entanglement entropy'. Explains entanglement precisely (non-separable states, Bell/CHSH…
  • 100quantum-information-computing
    Handle quantum information and computing: qubits, gates, circuits, entanglement, Bell inequalities, teleportation, Grover and Shor algorithms, error correction, quantum cryptography, hardware platforms. Use for any qubit, quantum circuit, or entanglement question.
  • 90quantum-computing
    Designs and analyzes quantum computing solutions including quantum circuit construction, algorithm implementation, error correction, and quantum advantage assessment; trigger when users discuss qubits, quantum gates, quantum algorithms, or quantum hardware.
  • 100quantum-expert
    Expert-level quantum computing, Qiskit, quantum algorithms, and quantum information. Use when the user mentions quantum computing, Qiskit, quantum algorithms, or quantum information, or when the task involves Quantum Mechanics Basics, Quantum Hardware, Circuit Design, or Algorithm Implementation.
  • 95fundamental-quantum-error-correction
    Use this skill when the user says 'why quantum error correction', 'logical vs physical qubits', 'threshold theorem', 'fault tolerance overhead', 'below threshold', 'how many physical qubits per logical qubit', 'magic state distillation', 'when will quantum computers be useful'.…
  • 100qiskit
    IBM quantum computing framework. Use when targeting IBM Quantum hardware, working with Qiskit Runtime for production workloads, or needing IBM optimization tools. Best for IBM hardware execution, quantum error mitigation, and enterprise quantum computing. For Google hardware use…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.