Overview

Appendix B. More about quantum states and gates

This appendix deepens intuition about single‑qubit states and gates by connecting their complex‑amplitude descriptions to geometric and algebraic tools that are practical for software work. It shows how the Bloch sphere offers a compact visualization of any qubit, and how global phase can be ignored without changing measurement statistics. It also emphasizes that all single‑qubit operations can be constructed from just two primitives—the Hadamard (H) and Phase (P) gates—and that such identities are routinely used in both circuit simplification and real hardware implementations, with code‑based checks preferred over formal proofs.

The Bloch sphere section explains that any single‑qubit state can be written in the form cos(θ/2)|0⟩ + e^{iφ} sin(θ/2)|1⟩, where θ controls the probability p of measuring 0 via p = cos²(θ/2), and φ is the relative phase. Starting from general complex amplitudes √p e^{iθ₀} and √(1−p) e^{iθ₁}, factoring out the global phase e^{iθ₀} yields the Bloch form with φ = θ₁ − θ₀; the global factor is physically irrelevant. A concrete example illustrates the mapping: with p = 0.35, θ₀ = π/3, and θ₁ = 2π/3, one obtains φ = π/3 and θ = 2 arccos(√p), showing how probabilities and relative phases translate into Bloch coordinates.

The gate‑synthesis section demonstrates that Z equals a phase rotation of π (Z = P(π)) and that X can be composed as HZH, equivalently HP(π)H, by turning amplitudes into sum/difference, flipping the sign of the difference, and transforming back. It then lists broader identities that reduce general rotations to H and P, such as Rz(θ) via X and P or purely H/P sequences, Rx(θ) = H Rz(θ) H, Ry(θ) from phase‑shifted Rx, and Y from a π rotation around X combined with a phase. These relations both explain how hardware with limited native gates can implement arbitrary single‑qubit unitaries and provide a toolkit for simplifying circuits, with the book’s accompanying code using assertions and unit tests to validate the equivalences on random states.

Figure B.1 The Bloch sphere.
APPB F01 gonciulea

FAQ

What is the Bloch sphere and why is it useful?The Bloch sphere is a 3D unit sphere that represents all pure single-qubit states (up to a global phase). It provides geometric intuition for amplitudes, phases, and how single-qubit gates act as rotations on the sphere.
How do I write a single-qubit state in Bloch sphere form?Any single-qubit state can be written as |ψ> = cos(θ/2)|0> + e^{iφ} sin(θ/2)|1>, where 0 ≤ θ < π and 0 ≤ φ < 2π.
How is the measurement probability p related to θ on the Bloch sphere?The probability of outcome 0 is p = cos²(θ/2), and the probability of outcome 1 is 1 − p = sin²(θ/2).
What is global phase and why can we ignore it on the Bloch sphere?A global phase is an overall factor e^{iα} multiplying the whole state. It has no physical effect on measurement probabilities or relative phases, so the Bloch sphere representation ignores it.
How do I derive Bloch parameters (θ, φ) from a general two-amplitude state?Starting from √p e^{iθ₀}|0> + √(1−p) e^{iθ₁}|1>, factor out e^{iθ₀} to get e^{iθ₀}(√p|0> + e^{i(θ₁−θ₀)}√(1−p)|1>). Ignoring the global phase e^{iθ₀}, set φ = θ₁ − θ₀ and choose θ so that √p = cos(θ/2) and √(1−p) = sin(θ/2).
Given p = 0.35 and phases θ₀ = π/3, θ₁ = 2π/3, what are θ and φ?φ = θ₁ − θ₀ = π/3. θ is computed from p by θ = 2 arccos(√p) = 2 arccos(√0.35) ≈ 1.88 radians (≈ 107.8°).
Why is the Z gate equal to a phase gate with angle π?Z multiplies the |1> amplitude by −1. The phase gate P(π) multiplies |1> by e^{iπ} = −1. Therefore, Z = P(π).
How can the X gate be built from Hadamard and Phase gates?Apply H, then Z (i.e., P(π)), then H again: X = HZH = HP(π)H. Intuitively, H moves to the sum/difference basis, Z flips the sign of the difference, and H maps back, swapping amplitudes.
Can H and P generate arbitrary single-qubit rotations? What are the identities?Yes. Useful decompositions are: RZ(θ) = X P(−θ/2) X P(θ/2) = H P(π) H P(−θ/2) H P(π) H P(θ/2); RX(θ) = H RZ(θ) H; RY(θ) = P(π/2) RX(θ) P(−π/2). These express rotations using only H and P (plus their compositions).
Why are gate identities like these useful in practice?They let you implement and simplify circuits using a small, hardware-friendly gate set (e.g., H and P), enable decomposition of higher-level gates, and support verification via code-based assertions on random states.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Building Quantum Software with Python ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Building Quantum Software with Python ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Building Quantum Software with Python ebook for free