
# Two-Level Dynamics & Rabi Oscillations

> This is the last lesson of Term 1, and it is where the physics becomes the machine. We take the
> propagator $U(t)=e^{-iHt}$ from the previous lesson and apply it to the one Hamiltonian every qubit
> platform implements: a **driven two-level system**. Out falls the **Rabi oscillation** — population
> sloshing coherently between $|0\rangle$ and $|1\rangle$ — and, with it, the punchline of the entire
> term: **a quantum gate is just time evolution run for a chosen duration.** Driving $H=\tfrac{\Omega}{2}X$
> for the right time turns $|0\rangle$ into $|1\rangle$; that pulse *is* the $X$ gate. Everything in
> Term 2 (gates and circuits) and Term 4.4 (how superconducting qubits actually do this) rests here.

## Learning Objectives

After this lesson you will be able to:

1. Write the **two-level drive Hamiltonian** and identify the on-resonance limit $H = \tfrac{\Omega}{2}X$.
2. **Derive** the Rabi formula $P_1(t) = \sin^2(\Omega t/2)$ for a qubit starting in $|0\rangle$, two
   independent ways (closed-form exponential and energy eigenbasis).
3. Generalize to nonzero **detuning**: $P_1(t) = \frac{\Omega^2}{\Omega_{\text{eff}}^2}\sin^2(\Omega_{\text{eff}}t/2)$
   with $\Omega_{\text{eff}} = \sqrt{\Omega^2 + \Delta^2}$.
4. Interpret Rabi dynamics as **Bloch-vector precession** about the drive axis.
5. Show that evolving under $\tfrac{\Omega}{2}X$ for time $t$ realizes $R_x(\Omega t)$, so a
   **$\pi$-pulse** is an $X$ gate — connecting analog dynamics to the digital gate model.

---

## Intuition

Picture a qubit as a tiny magnet (a Bloch vector) sitting in a static field along $\hat z$ that splits
the energies of $|0\rangle$ and $|1\rangle$ by $\omega_0$. Left alone, the vector just precesses about
$\hat z$ and the **populations never change** — $|0\rangle$ and $|1\rangle$ are energy eigenstates
(this was Example 1 of the previous lesson). To *move* population between the levels you have to push
the qubit off the $z$-axis: you apply an oscillating drive (a microwave or laser tone) that, viewed in
the right rotating frame, becomes a *constant* field along an axis in the equatorial plane. The Bloch
vector then precesses about **that** tilted axis — and as it swings, its $\hat z$-projection runs from
$|0\rangle$ down to $|1\rangle$ and back. That coherent round-trip of population is a **Rabi
oscillation**.

The drive strength $\Omega$ (the **Rabi frequency**) sets how fast the vector swings. If the drive is
perfectly **on resonance** with the qubit's energy gap, the rotation axis lies flat on the equator and
the population swings *all the way* to $|1\rangle$. If the drive is **detuned**, the axis tilts up out
of the plane, the precession cone is narrower, and the qubit never fully reaches $|1\rangle$. So the
two knobs are: *how hard* you drive (amplitude $\Omega$) and *how far off* you are in frequency
(detuning $\Delta$). Stop the drive after exactly half a swing and you have flipped the qubit — that is
an $X$ gate, built out of physics.

---

## Theory

> **Symbol note.** $H$ is the **Hamiltonian** here, never the Hadamard. $\hbar = 1$, rotation gates use
> the half-angle convention $R_\sigma(\theta)=e^{-i\theta\sigma/2}$
> ([Appendix C](../../appendix/C-notation-glossary.md), [E](../../appendix/E-math-identities.md)).

### The driven two-level Hamiltonian

A qubit with bare energy splitting $\omega_0$ has free Hamiltonian $H_0 = \tfrac{\omega_0}{2}Z$ (energies
$\pm\tfrac{\omega_0}{2}$ for $|0\rangle,|1\rangle$). Couple it to a classical field oscillating at drive
frequency $\omega_d$ with amplitude (Rabi frequency) $\Omega$; the coupling is a transverse term:

$$
H(t) = \frac{\omega_0}{2}Z + \Omega\cos(\omega_d t)\,X .
$$

This is time-dependent, so the clean $e^{-iHt}$ machinery does not apply directly. The standard move is
to pass to the **frame rotating at the drive frequency** $\omega_d$ — i.e. substitute
$|\psi\rangle = e^{-i\frac{\omega_d}{2}Zt}|\tilde\psi\rangle$ — and drop the fast-oscillating
counter-rotating term (the **rotating-wave approximation**, RWA). The transformed Hamiltonian becomes
**time-independent** (derivation deferred to Term 4.4, where it is the working model of a real device):

$$
\boxed{\,H_{\text{RWA}} = \frac{\Delta}{2}\,Z + \frac{\Omega}{2}\,X,\qquad \Delta := \omega_0 - \omega_d\,}
$$

with **detuning** $\Delta$ (how far the drive is off resonance) and **Rabi frequency** $\Omega$ (how
hard we drive). This single, constant, Hermitian $2\times2$ operator generates all the dynamics below.
The whole point of the rotating frame is that it converts an oscillating drive into the kind of
constant-$H$ problem we solved in [1.6.1](01-time-evolution.md).

### On resonance: deriving $P_1(t)=\sin^2(\Omega t/2)$

Set the drive exactly on resonance, $\Delta = 0$. Then

$$
H = \frac{\Omega}{2}X .
$$

Start in $|\psi(0)\rangle = |0\rangle$ and apply the propagator. Because $X^2 = I$, the exponential
closes into trig ([Appendix E](../../appendix/E-math-identities.md), §3):

$$
U(t) = e^{-i\frac{\Omega}{2}Xt}
= \cos\!\frac{\Omega t}{2}\,I - i\sin\!\frac{\Omega t}{2}\,X
= \begin{pmatrix}\cos\frac{\Omega t}{2} & -i\sin\frac{\Omega t}{2}\\[2pt] -i\sin\frac{\Omega t}{2} & \cos\frac{\Omega t}{2}\end{pmatrix}.
$$

Apply it to $|0\rangle$:

$$
|\psi(t)\rangle = U(t)|0\rangle = \cos\!\frac{\Omega t}{2}\,|0\rangle - i\sin\!\frac{\Omega t}{2}\,|1\rangle .
$$

The Born rule ([Appendix C](../../appendix/C-notation-glossary.md)) gives the excited-state population:

$$
\boxed{\,P_1(t) = |\langle 1|\psi(t)\rangle|^2 = \sin^2\!\frac{\Omega t}{2} = \frac{1-\cos\Omega t}{2}\,}
$$

and $P_0(t) = \cos^2(\Omega t/2)$, so $P_0 + P_1 = 1$ at all times (unitarity). The population
**oscillates fully** between $0$ and $1$ at angular frequency $\Omega$ — these are **Rabi
oscillations**. The period is $T = 2\pi/\Omega$; the qubit is fully inverted ($P_1=1$) at
$t = \pi/\Omega$.

**Second derivation (energy eigenbasis), as a cross-check.** The eigenstates of $H=\tfrac{\Omega}{2}X$
are $|\pm\rangle$ with energies $E_\pm = \pm\tfrac{\Omega}{2}$. Expand $|0\rangle = \tfrac1{\sqrt2}(|+\rangle+|-\rangle)$
and evolve each by its phase (the recipe from [1.6.1](01-time-evolution.md)):

$$
|\psi(t)\rangle = \tfrac1{\sqrt2}\big(e^{-i\Omega t/2}|+\rangle + e^{+i\Omega t/2}|-\rangle\big).
$$

Now $\langle 1|\pm\rangle = \pm\tfrac1{\sqrt2}$, so

$$
\langle 1|\psi(t)\rangle = \tfrac1{\sqrt2}\Big(\tfrac{1}{\sqrt2}e^{-i\Omega t/2} - \tfrac{1}{\sqrt2}e^{+i\Omega t/2}\Big)
= \tfrac12\big(e^{-i\Omega t/2}-e^{+i\Omega t/2}\big) = -i\sin\!\frac{\Omega t}{2},
$$

giving $P_1(t) = \sin^2(\Omega t/2)$ — identical. ∎ The oscillation frequency $\Omega = E_+ - E_-$ is
exactly the **Bohr frequency** (energy *difference*) of the drive Hamiltonian, as the general theory
predicted.

### Off resonance: detuning and the effective Rabi frequency

Restore the detuning, $H = \tfrac{\Delta}{2}Z + \tfrac{\Omega}{2}X = \tfrac12\,\vec n\cdot\vec\sigma$
with $\vec n = (\Omega,\,0,\,\Delta)$. Write $\Omega_{\text{eff}} = |\vec n| = \sqrt{\Omega^2+\Delta^2}$
and the unit axis $\hat n = \vec n/\Omega_{\text{eff}}$. Then $H = \tfrac{\Omega_{\text{eff}}}{2}\,(\hat n\cdot\vec\sigma)$,
and since $(\hat n\cdot\vec\sigma)^2 = I$ the half-angle exponential applies again
([Appendix E](../../appendix/E-math-identities.md), §3):

$$
U(t) = e^{-i\frac{\Omega_{\text{eff}}}{2}(\hat n\cdot\vec\sigma)\,t}
= \cos\!\frac{\Omega_{\text{eff}}t}{2}\,I - i\sin\!\frac{\Omega_{\text{eff}}t}{2}\,(\hat n\cdot\vec\sigma).
$$

The amplitude to land in $|1\rangle$ from $|0\rangle$ comes from the off-diagonal piece of
$\hat n\cdot\vec\sigma$, which carries the factor $\Omega/\Omega_{\text{eff}}$. Squaring gives the
**generalized Rabi formula**:

$$
\boxed{\,P_1(t) = \frac{\Omega^2}{\Omega^2+\Delta^2}\,\sin^2\!\Big(\tfrac{\Omega_{\text{eff}}\,t}{2}\Big),
\qquad \Omega_{\text{eff}} = \sqrt{\Omega^2+\Delta^2}\,}
$$

Read off the physics: detuning makes the oscillation **faster** (frequency $\Omega_{\text{eff}}\ge\Omega$)
but **shallower** — the maximum reachable population is $\Omega^2/(\Omega^2+\Delta^2) < 1$. You can no
longer fully flip the qubit off resonance. Resonance ($\Delta=0$) is special precisely because it is the
only setting that achieves complete population transfer. (Sweeping $\Delta$ and watching this contrast
collapse is how experimentalists *find* a qubit's frequency — a **Rabi/chevron** measurement, Term
4.4.)

### Bloch-sphere picture: precession about the drive axis

The Liouville/Ehrenfest machinery from [1.6.1](01-time-evolution.md) makes the geometry exact. For a
single qubit, $H = \tfrac12\vec n\cdot\vec\sigma$ and $\rho=\tfrac12(I+\vec r\cdot\vec\sigma)$
([Appendix E](../../appendix/E-math-identities.md), §1). Feeding $\dot\rho = -i[H,\rho]$ through the
Pauli commutators $[\sigma_j,\sigma_k]=2i\varepsilon_{jkl}\sigma_l$ yields the **Bloch equation**:

$$
\boxed{\,\frac{d\vec r}{dt} = \vec n\times\vec r\,}
$$

This is exactly the equation of a vector **precessing about the axis $\vec n$** at angular speed
$|\vec n| = \Omega_{\text{eff}}$ — the classical-magnet picture is literally correct. On resonance
$\vec n = (\Omega,0,0)$ lies on the equator along $\hat x$: starting from the north pole $\vec r(0)=(0,0,1)$
($=|0\rangle$), the vector precesses in the $y$–$z$ plane down through the south pole ($|1\rangle$) and
back. Its height is $r_z(t) = \cos\Omega t = 1 - 2P_1(t)$, reproducing $P_1=\sin^2(\Omega t/2)$. With
detuning the axis tilts up to $\vec n=(\Omega,0,\Delta)$; the precession cone no longer reaches the
south pole, so $r_z$ never hits $-1$ — the geometric reason the population transfer is incomplete.

### The key computing connection: a gate is timed evolution

Compare the on-resonance propagator with the rotation gate from
[Appendix E](../../appendix/E-math-identities.md):

$$
U(t) = e^{-i\frac{\Omega}{2}Xt} = e^{-i\,(\Omega t)\,X/2} = R_x(\Omega t).
$$

So **letting the qubit evolve under the drive $\tfrac{\Omega}{2}X$ for a duration $t$ implements the
gate $R_x(\theta)$ with rotation angle $\theta = \Omega t$.** The "gate angle" is the Rabi frequency
times the pulse length — you dial it with *time*. Special pulses:

| Pulse | Duration $t$ | Angle $\theta=\Omega t$ | Gate $R_x(\theta)$ | Effect on $|0\rangle$ |
|---|---|---|---|---|
| $\pi/2$-pulse | $\pi/(2\Omega)$ | $\pi/2$ | $R_x(\pi/2)$ | $\to \tfrac1{\sqrt2}(|0\rangle - i|1\rangle)$ (equator) |
| **$\pi$-pulse** | $\pi/\Omega$ | $\pi$ | $R_x(\pi) = -iX$ | $\to -i|1\rangle \equiv |1\rangle$ |
| $2\pi$-pulse | $2\pi/\Omega$ | $2\pi$ | $R_x(2\pi) = -I$ | $\to -|0\rangle \equiv |0\rangle$ |

A **$\pi$-pulse is an $X$ gate** (NOT gate): $R_x(\pi) = \cos\tfrac\pi2 I - i\sin\tfrac\pi2 X = -iX$,
which equals $X$ up to the global phase $-i$ — and global phase is physically invisible
([Appendix C](../../appendix/C-notation-glossary.md)). It sends $|0\rangle\to|1\rangle$, the very first
peak of the Rabi curve $P_1(\pi/\Omega)=\sin^2(\pi/2)=1$. This is **not an analogy** — it is how $X$ is
physically realized on real hardware, by sending a calibrated $\pi$-pulse. The "digital" gate model of
[Term 2.1](../../term-2-qc-core/c01-gates-circuits/01-single-qubit-gates.md) is an abstraction layered
on top of exactly this analog control; how the pulse is engineered on a superconducting qubit (and what
limits its fidelity) is the subject of
[Term 4.4](../../term-4-noise-hardware/c04-hardware/01-superconducting-qubits.md). Choosing a *different*
drive axis (a $Y$-quadrature drive gives $\tfrac{\Omega}{2}Y\Rightarrow R_y$; the $\Delta$ term gives
$R_z$) lets a single physical mechanism realize any single-qubit rotation — which, by the Euler/ZYZ
decomposition ([Appendix E](../../appendix/E-math-identities.md), §3), is all of $SU(2)$.

The $X$ button below animates $R_x(t\pi)$ as $t$ runs from 0 to 1, which is the resonant evolution
$U(t) = R_x(\Omega t)$ stopped at $t = \pi/\Omega$. Watch $\lvert0\rangle$ precess down the $y$–$z$ great
circle, through $\tfrac1{\sqrt2}(\lvert0\rangle - i\lvert1\rangle)$ at the $\pi/2$ mark, to
$\lvert1\rangle$: a $\pi$-pulse. (Detuning, which tilts the axis toward $z$, is not modelled here.)

```qm-demo bloch-sphere
{ "gates": ["X"] }
```

---

## Worked Examples

### Example 1 — A $\pi$-pulse is an $X$ gate

Drive on resonance, $H=\tfrac{\Omega}{2}X$, for the time $t_\pi = \pi/\Omega$ (so $\theta = \Omega t_\pi = \pi$):

$$
U(t_\pi) = \cos\!\tfrac\pi2\,I - i\sin\!\tfrac\pi2\,X = -iX = \begin{pmatrix}0 & -i\\ -i & 0\end{pmatrix}.
$$

Acting on $|0\rangle$: $U(t_\pi)|0\rangle = -i|1\rangle$. Up to the irrelevant global phase $-i$, this is
$|1\rangle$ — a complete bit flip, with $P_1(t_\pi) = \sin^2(\pi/2) = 1$. Acting on $|1\rangle$:
$U(t_\pi)|1\rangle = -i|0\rangle \equiv |0\rangle$. So the $\pi$-pulse swaps $|0\rangle\leftrightarrow|1\rangle$
exactly as the $X$ (NOT) gate does. Since $X = i\,R_x(\pi)$, the standard $X$ gate and the physical
$\pi$-pulse differ only by global phase — operationally the same gate.

### Example 2 — Detuned drive: incomplete transfer

Drive with $\Omega = 1$ and detuning $\Delta = 1$ (so the drive is off resonance by exactly the Rabi
frequency). Then $\Omega_{\text{eff}} = \sqrt{1^2+1^2} = \sqrt2$ and the maximum reachable excited
population is

$$
P_1^{\max} = \frac{\Omega^2}{\Omega^2+\Delta^2} = \frac{1}{1+1} = \frac12 .
$$

The full curve is $P_1(t) = \tfrac12\sin^2\!\big(\tfrac{\sqrt2}{2}t\big)$. Compared to the resonant case
it oscillates faster (frequency $\sqrt2$ instead of $1$) but only ever reaches halfway up — a $\pi$-pulse
*duration* no longer produces a clean bit flip. This is why qubit drives must be carefully calibrated to
resonance: a control error in $\Delta$ both speeds up and caps the rotation, corrupting the intended
gate. (Detuning errors are a standard coherent-error model analyzed in Term 4.)

---

## Hands-on (Python)

We simulate the dynamics with `scipy.linalg.expm`, plot the Rabi oscillation, verify the $\pi$-pulse
realizes $X$, and overlay a detuned curve to see incomplete transfer.

```python
import numpy as np
from scipy.linalg import expm
import matplotlib.pyplot as plt

# Pauli matrices (Appendix E)
I = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)

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

def H_drive(Omega, Delta):
    """Rotating-frame two-level Hamiltonian H = (Δ/2)Z + (Ω/2)X."""
    return 0.5 * Delta * Z + 0.5 * Omega * X

def P1(t, Omega, Delta):
    """Excited-state population starting from |0>, via U(t)=exp(-iHt)."""
    U = expm(-1j * H_drive(Omega, Delta) * t)
    psi = U @ ket0
    return np.abs(ket1 @ psi) ** 2          # Born rule |<1|ψ(t)>|²

# --- Resonant Rabi oscillations: P1(t) = sin²(Ωt/2) ---
Omega = 2.0
ts = np.linspace(0, 3 * np.pi / Omega, 500)
P1_num   = np.array([P1(t, Omega, Delta=0.0) for t in ts])
P1_exact = np.sin(Omega * ts / 2) ** 2

print("resonant: max |numeric - sin²(Ωt/2)| =", np.max(np.abs(P1_num - P1_exact)))  # ~1e-15
```

```python
# --- The π-pulse maps |0> -> |1> and equals X up to global phase ---
t_pi = np.pi / Omega                         # θ = Ω t_pi = π
U_pi = expm(-1j * H_drive(Omega, 0.0) * t_pi)
psi_pi = U_pi @ ket0
print("ψ(t_π) =", np.round(psi_pi, 3))       # [0.-0.j  0.-1.j] = -i|1>
print("P1(t_π) =", round(P1(t_pi, Omega, 0.0), 12))   # 1.0  (full inversion)

# U_pi equals X up to a global phase: U_pi = -i X  ⇒  i*U_pi == X
print("U_π == X up to global phase? ", np.allclose(1j * U_pi, X))   # True
```

```python
# --- Detuning: faster but shallower oscillations (incomplete transfer) ---
fig, ax = plt.subplots(figsize=(7.5, 3.4))
for Delta, style in [(0.0, "-"), (Omega, "--"), (2 * Omega, ":")]:
    Oeff = np.sqrt(Omega**2 + Delta**2)
    cap = Omega**2 / (Omega**2 + Delta**2)   # P1_max = Ω²/Ω_eff²
    curve = np.array([P1(t, Omega, Delta) for t in ts])
    ax.plot(ts, curve, style, lw=2,
            label=fr"$\Delta={Delta/Omega:.0f}\,\Omega$  ($P_1^{{\max}}={cap:.2f}$)")

ax.axhline(1.0, color="gray", ls=":", lw=0.8)
ax.set_xlabel("time  t"); ax.set_ylabel(r"$P_1(t)$")
ax.set_title(r"Rabi oscillations: resonant vs. detuned ($\Omega=2$)")
ax.legend(loc="upper right"); fig.tight_layout()
plt.show()
# On resonance the population reaches 1 (a clean X gate at t=π/Ω);
# detuned drives oscillate faster (Ω_eff) but cap below 1.
```

```python
# --- The gate view: evolving (Ω/2)X for time t IS the gate R_x(Ωt) ---
def Rx(theta):                               # Appendix E half-angle convention
    return np.cos(theta/2) * I - 1j * np.sin(theta/2) * X

t = 0.37
U_t = expm(-1j * H_drive(Omega, 0.0) * t)
print("U(t) == R_x(Ω t)? ", np.allclose(U_t, Rx(Omega * t)))   # True
```

> **Braket note (optional).** Because $e^{-i\frac{\Omega}{2}Xt} = R_x(\Omega t)$, the identical
> dynamics is a single gate in the SDK — `from braket.circuits import Circuit; Circuit().rx(0, Omega * t)`
> on a `LocalSimulator` — and the $\pi$-pulse is just `Circuit().x(0)`. That is the whole bridge from
> this analog picture to the digital circuit model. We build Braket circuits properly in
> [Term 2.1](../../term-2-qc-core/c01-gates-circuits/01-single-qubit-gates.md); the pulse-level control
> beneath the gate is [Term 4.4](../../term-4-noise-hardware/c04-hardware/01-superconducting-qubits.md).

---

## Exercises

**E1 (easy).** A qubit has Rabi frequency $\Omega = 2\pi\times 50$ MHz on resonance. How long is a
$\pi$-pulse (an $X$ gate)? A $\pi/2$-pulse?

<details><summary>Solution</summary>

$t_\pi = \pi/\Omega = \pi/(2\pi\times 50\,\text{MHz}) = 1/(100\,\text{MHz}) = 10\ \text{ns}$. The
$\pi/2$-pulse is half that, $t_{\pi/2} = \pi/(2\Omega) = 5\ \text{ns}$. (These ns-scale gate times are
realistic for superconducting qubits, Term 4.4.)
</details>

**E2 (easy).** On resonance, at what times is the qubit in an equal superposition, $P_0 = P_1 = \tfrac12$?

<details><summary>Solution</summary>

$P_1 = \sin^2(\Omega t/2) = \tfrac12 \Rightarrow \sin(\Omega t/2) = \tfrac1{\sqrt2} \Rightarrow
\Omega t/2 = \pi/4 + k\pi/2$, i.e. $t = \frac{\pi}{2\Omega}(2k+1)$ for integer $k\ge0$. The first is the
$\pi/2$-pulse $t=\pi/(2\Omega)$, which puts the Bloch vector on the equator.
</details>

**E3 (medium).** Derive the generalized Rabi formula's maximum, $P_1^{\max} = \Omega^2/(\Omega^2+\Delta^2)$,
and explain geometrically why detuning prevents full inversion.

<details><summary>Solution</summary>

$P_1(t) = \frac{\Omega^2}{\Omega^2+\Delta^2}\sin^2(\Omega_{\text{eff}}t/2)$ is maximized when
$\sin^2(\cdot)=1$, giving $P_1^{\max} = \Omega^2/(\Omega^2+\Delta^2)$. Geometrically the Bloch vector
precesses about $\vec n=(\Omega,0,\Delta)$, which makes angle $\alpha$ with $\hat z$ where
$\cos\alpha = \Delta/\Omega_{\text{eff}}$. Starting at the north pole, the vector sweeps a cone of
half-angle $\alpha$ about $\vec n$; its lowest point reaches $r_z = \cos 2\alpha = 1 - 2\sin^2\alpha$,
and $1-r_z^{\min} = 2P_1^{\max}$ recovers the formula. Only $\Delta=0$ ($\alpha=\pi/2$, axis on the
equator) lets the cone reach the south pole. ∎
</details>

**E4 (medium).** Show $R_x(\pi) = -iX$ and explain in one sentence why the $\pi$-pulse counts as the $X$
gate despite the prefactor.

<details><summary>Solution</summary>

$R_x(\pi) = \cos\tfrac\pi2\,I - i\sin\tfrac\pi2\,X = 0\cdot I - i\cdot 1\cdot X = -iX$. The $-i$ is a
**global phase**, which has no observable consequence ([Appendix C](../../appendix/C-notation-glossary.md)) —
$-iX$ and $X$ produce identical measurement statistics on every state — so the $\pi$-pulse *is* the $X$
gate physically. ∎
</details>

**E5 (hard).** From $H = \tfrac{\Omega}{2}X$ and $\rho=\tfrac12(I+\vec r\cdot\vec\sigma)$, derive the
Bloch equation $\dot{\vec r} = (\Omega\hat x)\times\vec r$ and solve it for $\vec r(0)=(0,0,1)$.

<details><summary>Solution</summary>

$\dot\rho = -i[H,\rho] = -\tfrac{i\Omega}{4}[X, \vec r\cdot\vec\sigma]$. Using $[X,Y]=2iZ$, $[X,Z]=-2iY$,
$[X,X]=0$: $[X,\vec r\cdot\vec\sigma] = r_y[X,Y]+r_z[X,Z] = 2i(r_y Z - r_z Y)$. So
$\dot\rho = \tfrac{\Omega}{2}(r_y Z - r_z Y)\!\cdot\!\tfrac12\cdot 2 = \tfrac12(\dot{\vec r}\cdot\vec\sigma)$
forces $\dot r_x = 0,\ \dot r_y = -\Omega r_z,\ \dot r_z = +\Omega r_y$, i.e. $\dot{\vec r} = \Omega\hat x\times\vec r$.
With $\vec r(0)=(0,0,1)$: $r_x(t)=0$, $r_z(t)=\cos\Omega t$, $r_y(t)=-\sin\Omega t$ — precession about
$\hat x$, and $P_1 = (1-r_z)/2 = \sin^2(\Omega t/2)$ as required. ∎
</details>

**E6 (hard).** A $2\pi$-pulse on resonance returns every population to its start ($P_1(2\pi/\Omega)=0$),
yet $U(2\pi/\Omega) = -I \neq I$. Construct a setting in which this $-1$ is **physically observable**,
and explain why it does not contradict "global phase is unobservable."

<details><summary>Solution</summary>

$U(2\pi/\Omega) = R_x(2\pi) = \cos\pi\,I - i\sin\pi\,X = -I$. On a *single, isolated* qubit the $-1$ is a
global phase and unobservable. But make it **relative**: take two qubits in $\tfrac1{\sqrt2}(|0\rangle+|1\rangle)_A|0\rangle_B$
and apply the $2\pi$ drive to qubit $B$ *conditioned on $A=|1\rangle$* (a controlled rotation). Then the
$|1\rangle_A$ branch picks up $-1$ while the $|0\rangle_A$ branch does not, yielding
$\tfrac1{\sqrt2}(|0\rangle - |1\rangle)_A|0\rangle_B = |-\rangle_A|0\rangle_B$ — a *measurable* phase
flip on $A$, detectable by measuring $A$ in the $X$-basis. The rule "global phase is unobservable"
concerns an overall phase on the *whole* state; once the $-1$ multiplies only part of a superposition it
becomes a *relative* phase, which is physical. (This $4\pi$-periodicity is the spin-$\tfrac12$ signature
of $SU(2)$, and the mechanism behind controlled-phase gates, Term 2.1.) ∎
</details>

---

## Checkpoint

1. Write the rotating-frame two-level Hamiltonian and name each parameter.
2. Derive $P_1(t)$ for $H=\tfrac{\Omega}{2}X$ starting from $|0\rangle$. What is the period?
3. Give the detuned Rabi formula and the effective frequency; what is the maximum $P_1$?
4. Geometrically, what is a Rabi oscillation on the Bloch sphere?
5. Which pulse realizes an $X$ gate, and why is that the central message of this term?

<details><summary>Answers</summary>

1. $H = \tfrac{\Delta}{2}Z + \tfrac{\Omega}{2}X$: $\Delta=\omega_0-\omega_d$ is the **detuning**,
   $\Omega$ is the **Rabi frequency** (drive amplitude).
2. $U(t)=e^{-i\frac{\Omega}{2}Xt} = \cos\frac{\Omega t}{2}I - i\sin\frac{\Omega t}{2}X$, so
   $|\psi(t)\rangle = \cos\frac{\Omega t}{2}|0\rangle - i\sin\frac{\Omega t}{2}|1\rangle$ and
   $P_1(t)=\sin^2(\Omega t/2)$; period $T=2\pi/\Omega$.
3. $P_1(t) = \frac{\Omega^2}{\Omega^2+\Delta^2}\sin^2(\Omega_{\text{eff}}t/2)$ with
   $\Omega_{\text{eff}}=\sqrt{\Omega^2+\Delta^2}$; maximum $\Omega^2/(\Omega^2+\Delta^2) \le 1$, equal to
   $1$ only on resonance.
4. Precession of the Bloch vector about the drive axis $\vec n=(\Omega,0,\Delta)$ at rate
   $\Omega_{\text{eff}}$ (Bloch equation $\dot{\vec r}=\vec n\times\vec r$); on resonance the axis is
   $\hat x$ and the vector swings from the north pole to the south pole and back.
5. The on-resonance **$\pi$-pulse** ($t=\pi/\Omega$): $R_x(\pi)=-iX$, an $X$ gate up to global phase.
   This shows a **quantum gate is just time evolution run for a chosen duration** — the physics (Term 1)
   *is* the gate model (Term 2).

</details>

---

## Further Reading

- **[Sak]** Sakurai & Napolitano, §5.5 — time-dependent two-level problems, the rotating-wave
  approximation, and the Rabi formula derived in full (with $\hbar$ explicit).
- **[NC]** Nielsen & Chuang, §4.2 and §7.7 — single-qubit rotations $R_x,R_y,R_z$, and how physical
  Hamiltonians realize gates on real hardware.
- **[Gri]** Griffiths & Schroeter, §11.1–11.2 — two-level systems driven by a time-dependent
  perturbation; Rabi flopping.
- **[Pre]** Preskill, *Ph219*, Ch. 3 — qubit dynamics, the Bloch equation, and control.

---

← Prev: [Time Evolution](01-time-evolution.md) · Up: [Term 1](../README.md) · Next: [Single-Qubit Gates (Term 2)](../../term-2-qc-core/c01-gates-circuits/01-single-qubit-gates.md) →
