Skip to content

Qubit Representation — Bloch Sphere, Dirac Notation and Quantum States Explained

DodaTech Updated 2026-06-23 10 min read

In this tutorial, you'll learn about Qubit Representation. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Qubit representation uses Dirac notation and the Bloch sphere to mathematically describe quantum states, enabling Superposition and phase relationships that classical bits cannot Express.

What You'll Learn

By the end of this tutorial, you will understand Dirac (bra-ket) notation, how to represent qubit states as vectors, visualize them on the Bloch sphere, use density matrices for mixed states, and represent multi-qubit systems using tensor products.

Why It Matters

Every quantum algorithm, gate, and measurement operation is expressed using qubit representation. Without understanding how qubits are represented mathematically, you cannot design quantum circuits, analyze quantum algorithms, or debug quantum programs. This is the language of Quantum Computing.

Real-World Use

When IBM calibrates its quantum processors, engineers reconstruct the qubit state using quantum state tomography — a process that relies entirely on the mathematical representation of qubit states. Google's quantum supremacy experiment required representing the output distribution of a 53-qubit system, a 2^53-dimensional state space.

Learning Path

flowchart LR
  A[Quantum Computing Overview] --> B[Qubit Representation]
  B --> C[Quantum Gates]
  C --> D[Quantum Circuits]
  B --> E{You Are Here}
  style E fill:#f90,color:#fff
ℹ️ Info

Prerequisites: Basic Python and high school math. No quantum physics background required.

Dirac Notation (Bra-Ket)

Dirac notation is the standard language of Quantum Computing. It uses angle brackets and bars to represent quantum states.

Ket: Column Vector

A ket |ψ⟩ represents a quantum state as a column vector:

|ψ⟩ = [α]
      [β]

The computational basis states are:

|0⟩ = [1]      |1⟩ = [0]
      [0]           [1]

Bra: Row Vector (Conjugate Transpose)

A bra ⟨ψ| is the conjugate transpose of the corresponding ket:

⟨ψ| = [α*  β*]

The inner product ⟨φ|ψ⟩ gives the overlap between two states:

⟨0|0⟩ = 1    ⟨0|1⟩ = 0    ⟨1|0⟩ = 0    ⟨1|1⟩ = 1

State Vector Normalization

A valid qubit state must satisfy ⟨ψ|ψ⟩ = 1:

|ψ⟩ = α|0⟩ + β|1⟩,  where |α|^2 + |β|^2 = 1
# dirac_notation.py
import numpy as np

# Basis states
ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)

# Create a superposition state
alpha = 1 / np.sqrt(2)
beta = 1 / np.sqrt(2)
psi = alpha * ket0 + beta * ket1

# Bra is conjugate transpose
bra0 = ket0.conj().T
bra1 = ket1.conj().T
bra_psi = psi.conj().T

# Inner products
print("=== Dirac Notation ===")
print(f"|0⟩ = {ket0}")
print(f"|1⟩ = {ket1}")
print(f"|ψ⟩ = {psi}")
print(f"⟨0|0⟩ = {bra0 @ ket0}")
print(f"⟨0|1⟩ = {bra0 @ ket1}")
print(f"⟨ψ|ψ⟩ = {bra_psi @ psi}")
print(f"⟨0|ψ⟩ = {bra0 @ psi}")

# Outer product (projector)
P0 = np.outer(ket0, bra0)
P1 = np.outer(ket1, bra1)
print(f"\nProjector |0⟩⟨0|:\n{P0}")
print(f"Projector |1⟩⟨1|:\n{P1}")

Expected output:

=== Dirac Notation ===
|0⟩ = [1 0]
|1⟩ = [0 1]
|ψ⟩ = [0.70710678 0.70710678]
⟨0|0⟩ = 1
⟨0|1⟩ = 0
⟨ψ|ψ⟩ = 1.0
⟨0|ψ⟩ = 0.70710678

Projector |0⟩⟨0|:
[[1 0]
 [0 0]]
Projector |1⟩⟨1|:
[[0 0]
 [0 1]]

The Bloch Sphere

The Bloch sphere is a geometric representation of a single qubit's state space. Every pure qubit state corresponds to a unique point on the sphere's surface.

Coordinates

|ψ⟩ = cos(θ/2)|0⟩ + e^(iφ) sin(θ/2)|1⟩

θ: polar angle (0 to π)
φ: azimuthal angle (0 to 2π)
graph TD
  subgraph "Bloch Sphere Representation"
    Z("|0⟩ (North Pole)") --> Center
    Center --> Z_("|1⟩ (South Pole)")
    X_plus("|+⟩ = (|0⟩+|1⟩)/√2") --> Center
    Y_plus("|+i⟩ = (|0⟩+i|1⟩)/√2") --> Center
  end
  style Z fill:#4488ff,color:#fff
  style Z_ fill:#ff4444,color:#fff

Key Points on the Bloch Sphere

| Point | State | θ | φ | |-------|-------|---|---| | North Pole | |0⟩ | 0 | — | | South Pole | |1⟩ | π | — | | Positive X | |+⟩ = (|0⟩+|1⟩)/√2 | π/2 | 0 | | Negative X | |-⟩ = (|0⟩-|1⟩)/√2 | π/2 | π | | Positive Y | |+i⟩ = (|0⟩+i|1⟩)/√2 | π/2 | π/2 | | Negative Y | |-i⟩ = (|0⟩-i|1⟩)/√2 | π/2 | 3π/2 |

# bloch_sphere.py
import numpy as np

def bloch_coordinates(state):
    """Extract Bloch sphere coordinates from a qubit state."""
    alpha = state[0]
    beta = state[1]

    # Compute expectation values
    X = np.array([[0, 1], [1, 0]], dtype=complex)
    Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
    Z = np.array([[1, 0], [0, -1]], dtype=complex)

    x = (state.conj().T @ X @ state).real
    y = (state.conj().T @ Y @ state).real
    z = (state.conj().T @ Z @ state).real

    # Compute angles
    theta = np.arccos(z)
    phi = np.arctan2(y, x)

    return x, y, z, theta, phi

# Test various states
ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)
plus = np.array([1, 1], dtype=complex) / np.sqrt(2)
minus = np.array([1, -1], dtype=complex) / np.sqrt(2)
plus_i = np.array([1, 1j], dtype=complex) / np.sqrt(2)

print("=== Bloch Sphere Coordinates ===")
for name, state in [("|0⟩", ket0), ("|1⟩", ket1), ("|+⟩", plus),
                    ("|-⟩", minus), ("|+i⟩", plus_i)]:
    x, y, z, theta, phi = bloch_coordinates(state)
    print(f"{name:>6}: (x={x:.2f}, y={y:.2f}, z={z:.2f}), "
          f"θ={theta:.2f}, φ={phi:.2f}")

Expected output:

=== Bloch Sphere Coordinates ===
   |0⟩: (x=0.00, y=0.00, z=1.00), θ=0.00, φ=0.00
   |1⟩: (x=0.00, y=0.00, z=-1.00), θ=3.14, φ=0.00
   |+⟩: (x=1.00, y=0.00, z=0.00), θ=1.57, φ=0.00
   |-⟩: (x=-1.00, y=0.00, z=0.00), θ=1.57, φ=3.14
  |+i⟩: (x=0.00, y=1.00, z=0.00), θ=1.57, φ=1.57

Density Matrix Representation

For pure states, the density matrix is ρ = |ψ⟩⟨ψ|. For mixed states (statistical ensembles), it is a convex combination of pure states.

Properties

  • ρ is positive semidefinite
  • Tr(ρ) = 1
  • Tr(ρ^2) = 1 for pure states, < 1 for mixed states
  • ρ is Hermitian (ρ = ρ†)
# density_matrix.py
import numpy as np

class DensityMatrix:
    def __init__(self, state_vectors, probabilities=None):
        """
        Create a density matrix from a list of pure states.
        If probabilities is None, assume equal mixture.
        """
        if probabilities is None:
            probabilities = [1/len(state_vectors)] * len(state_vectors)

        dim = len(state_vectors[0])
        rho = np.zeros((dim, dim), dtype=complex)

        for state, prob in zip(state_vectors, probabilities):
            rho += prob * np.outer(state, state.conj())

        self.rho = rho

    def purity(self):
        return np.trace(self.rho @ self.rho).real

    def is_pure(self, tol=1e-10):
        return abs(self.purity() - 1.0) < tol

    def bloch_vector(self):
        X = np.array([[0, 1], [1, 0]], dtype=complex)
        Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
        Z = np.array([[1, 0], [0, -1]], dtype=complex)

        x = np.trace(self.rho @ X).real
        y = np.trace(self.rho @ Y).real
        z = np.trace(self.rho @ Z).real
        return np.array([x, y, z])

    def __str__(self):
        return str(self.rho)

# Pure state
ket0 = np.array([1, 0], dtype=complex)
pure = DensityMatrix([ket0])
print("=== Density Matrix Examples ===")
print(f"Pure |0⟩ state:\n{pure}")
print(f"Purity: {pure.purity():.2f}")
print(f"Is pure: {pure.is_pure()}")
print(f"Bloch vector: {pure.bloch_vector()}")

# Mixed state (50/50 |0⟩ and |1⟩)
mixed = DensityMatrix(
    [np.array([1, 0], dtype=complex),
     np.array([0, 1], dtype=complex)],
    [0.5, 0.5]
)
print(f"\nMixed state (50% |0⟩, 50% |1⟩):\n{mixed}")
print(f"Purity: {mixed.purity():.2f}")
print(f"Is pure: {mixed.is_pure()}")
print(f"Bloch vector: {mixed.bloch_vector()}")

Expected output:

=== Density Matrix Examples ===
Pure |0⟩ state:
[[1.+0.j 0.+0.j]
 [0.+0.j 0.+0.j]]
Purity: 1.00
Is pure: True
Bloch vector: [0. 0. 1.]

Mixed state (50% |0⟩, 50% |1⟩):
[[0.5+0.j 0. +0.j]
 [0. +0.j 0.5+0.j]]
Purity: 0.50
Is pure: False
Bloch vector: [0. 0. 0.]

Multi-Qubit Representation

Multi-qubit states are represented using tensor products (Kronecker products).

Two-Qubit Basis

|00⟩ = |0⟩ ⊗ |0⟩    |01⟩ = |0⟩ ⊗ |1⟩
|10⟩ = |1⟩ ⊗ |0⟩    |11⟩ = |1⟩ ⊗ |1⟩

Tensor Product Example

# tensor_product.py
import numpy as np

def tensor_product(*states):
    """Compute the tensor product of multiple states."""
    result = states[0]
    for state in states[1:]:
        result = np.kron(result, state)
    return result

# Basis states
ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)

# Two-qubit basis
ket00 = tensor_product(ket0, ket0)
ket01 = tensor_product(ket0, ket1)
ket10 = tensor_product(ket1, ket0)
ket11 = tensor_product(ket1, ket1)

print("=== Two-Qubit Basis ===")
print(f"|00⟩ = {ket00}")
print(f"|01⟩ = {ket01}")
print(f"|10⟩ = {ket10}")
print(f"|11⟩ = {ket11}")

# Bell state
bell = (ket00 + ket11) / np.sqrt(2)
print(f"\nBell state |Φ+⟩ = (|00⟩+|11⟩)/√2:")
print(bell)

# Three-qubit GHZ state
ket000 = tensor_product(ket0, ket0, ket0)
ket111 = tensor_product(ket1, ket1, ket1)
ghz = (ket000 + ket111) / np.sqrt(2)
print(f"\nGHZ state (|000⟩+|111⟩)/√2:")
print(ghz)
print(f"Dimension: {len(ghz)}")

# Verify entanglement
# Product state: |0⟩ ⊗ |+⟩
product = tensor_product(ket0, (ket0 + ket1) / np.sqrt(2))
print(f"\nProduct state |0⟩⊗|+⟩:")
print(product)

Expected output:

=== Two-Qubit Basis ===
|00⟩ = [1 0 0 0]
|01⟩ = [0 1 0 0]
|10⟩ = [0 0 1 0]
|11⟩ = [0 0 0 1]

Bell state |Φ+⟩ = (|00⟩+|11⟩)/√2:
[0.70710678 0.         0.         0.70710678]

GHZ state (|000⟩+|111⟩)/√2:
[0.70710678 0.         0.         0.         0.         0.
 0.         0.70710678]
Dimension: 8

Product state |0⟩⊗|+⟩:
[0.70710678 0.70710678 0.         0.        ]

Common Mistakes

1. Confusing Inner and Outer Products

The inner product ⟨φ|ψ⟩ is a scalar (complex number). The outer product |ψ⟩⟨φ| is a matrix. They are fundamentally different operations with different results.

2. Forgetting Global Phase

States that differ by a global phase e^(iθ) are physically equivalent. For example, |ψ⟩ and -|ψ⟩ represent the same physical state because measurement probabilities are unchanged.

3. Misapplying Tensor Products

The tensor product is not commutative: |0⟩⊗|1⟩ is not the same as |1⟩⊗|0⟩. The order of qubits matters and must be consistent throughout a computation.

4. Thinking the Bloch Sphere Shows All States

The Bloch sphere only represents single-qubit pure states. Multi-qubit states and mixed states require more complex representations (density matrices or state vectors in larger Hilbert spaces).

5. Ignoring Normalization

A valid quantum state must have unit norm. If you create a state without normalizing it, subsequent calculations will give incorrect probabilities.

Practice Questions

1. What is the difference between a bra and a ket in Dirac notation?

A ket |ψ⟩ is a column vector representing a quantum state. A bra ⟨ψ| is the conjugate transpose (row vector) of the corresponding ket. The bra-ket inner product ⟨φ|ψ⟩ gives the overlap amplitude between two states.

2. How does the Bloch sphere represent a qubit state?

The Bloch sphere maps a pure qubit state to a point on a unit sphere. The polar angle θ determines the |0⟩ vs |1⟩ probability, and the azimuthal angle φ determines the relative phase between components.

3. What is a density matrix and when is it used?

A density matrix ρ represents statistical mixtures of quantum states. It is used for mixed states (where the exact state is unknown), subsystems of larger systems, and quantum noise channels. Pure states have Tr(ρ^2) = 1; mixed states have Tr(ρ^2) < 1.

4. How do you represent a multi-qubit state?

Multi-qubit states use the tensor product (Kronecker product) of individual qubit states. An n-qubit state vector has dimension 2^n and encodes all possible basis state amplitudes.

Challenge: Quantum State Tomography

Implement a simple quantum state tomography routine that reconstructs an unknown single-qubit state from measurement statistics:

def state_tomography(measurement_data):
    """
    Reconstruct a qubit state from measurement statistics.
    
    measurement_data: dict with keys 'X', 'Y', 'Z', each containing
                      a dict {'plus': count, 'minus': count}
    
    Returns: density matrix of the reconstructed state
    """
    pass

Hints: Compute the Bloch vector from the expectation values ⟨X⟩, ⟨Y⟩, ⟨Z⟩. The density matrix is ρ = (I + xX + yY + zZ) / 2.

Real-World Task: Qubit State Verification

Using the density matrix simulator, generate a known state, apply a simulated measurement with finite statistics (1000 shots), and use tomography to reconstruct it. Compare the reconstructed state to the original using fidelity F = Tr(√(√ρ₁ ρ₂ √ρ₁)). This is exactly how quantum hardware vendors verify their gate operations.

FAQ

What is Dirac notation?

Dirac notation uses bras ⟨| and kets |⟩ to represent quantum states. It is the standard mathematical shorthand used throughout Quantum Computing literature.

What is the Bloch sphere?

The Bloch sphere is a 3D geometric representation of a single qubit's state space. Every point on the sphere surface corresponds to a pure state.

What is a density matrix?

A density matrix generalizes state vectors to handle statistical mixtures and subsystems. It is essential for describing noise, decoherence, and open quantum systems.

How many dimensions does an n-qubit state have?

An n-qubit state vector has 2^n complex amplitudes. This exponential scaling is both the power and the challenge of Quantum Computing.

What is quantum state tomography?

Quantum state tomography is the process of reconstructing an unknown quantum state from measurement statistics on many copies of the state.

What's Next

Quantum Gates — Hadamard, Pauli, CNOT
Quantum Computing Overview
Quantum Circuits Explained

You now understand the mathematical language of quantum states. Next, you will learn how to manipulate these states using quantum gates.

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Last updated: 2026-06-23.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro