---
title: Two-level systems, magnetic resonance and Rabi oscillation
heading: Driving a qubit from one state to the other
eyebrow: B10 · Lesson 26 · Two-level systems, magnetic resonance and Rabi oscillation
xp: 50
---

::: hook
A spin in a magnetic field, an atom's two levels under a laser, and a superconducting qubit under a microwave pulse all behave the same way: two levels a frequency $f_0$ apart, driven by an oscillating field near $f_0$. The result is **Rabi oscillation**: the system swings smoothly from one state to the other and back, at a rate set by the drive's strength. Every quantum gate on a qubit is a carefully timed piece of one of these swings, and every MRI image is built from spins tipped by them.
:::

::: play
- A two-level system starts in its lower state. The drive has Rabi frequency $f_R$ (its strength) and detuning δ from the transition. The curve is the probability of finding it in the upper state, against time in microseconds.
- On resonance (δ = 0) it swings all the way up and back. The first peak, at $t = \frac{1}{2f_R}$, is a **π pulse**: it flips the state exactly.
- Detune the drive: the swings get faster but never reach the top; at δ = $f_R$ they peak at ½. The resonance has a width set by the drive itself.
:::
:::

```sim plot
view: graph
x: t = 0..1 µs
y: P = 0..1
slider: f = 1..20 step 0.5 = 5 MHz
slider: d = -20..20 step 0.5 = 0 MHz
plot: f^2/(f^2 + d^2)*sin(pi*sqrt(f^2 + d^2)*t)^2 | samples: 1500 | label: probability of the upper state
readout: largest transfer = f^2/(f^2 + d^2)
readout: π pulse on resonance, ns = 1000/(2*f)
readout: period of the swing, ns = 1000/sqrt(f^2 + d^2)
```

::: predict
## A qubit is driven on resonance with Rabi frequency 25 MHz. How long a pulse flips it from |0⟩ to |1⟩?

- [ ] 40 ns
- [x] 20 ns
- [ ] 10 ns
- [ ] 6.4 ns

::: reveal
The upper-state probability is $\sin^2(\pi f_Rt)$, which first reaches 1 at $t = \frac{1}{2f_R}$ = 20 ns. Half as long, 10 ns, is a π/2 pulse: it makes an equal superposition, the starting point of most quantum algorithms. Superconducting qubits use pulses of about this length.
:::
:::

::: nameit
## The driven two-level system

Two levels $|0\rangle$ and $|1\rangle$, split by $hf_0$, driven by a field at frequency f with coupling strength $hf_R$ (for a spin, $f_R$ = 28.0 MHz per mT of rotating field $B_1$; for an atom, $hf_R = dE_0$ with d the transition dipole). In a frame rotating with the drive, and dropping terms that oscillate at 2f (the **rotating-wave approximation**), the Hamiltonian becomes a constant 2×2 matrix:

$$\hat H = \frac h2\begin{pmatrix}-\delta & f_R\\ f_R & \delta\end{pmatrix}, \qquad \delta = f - f_0$$

## Rabi's formula

Starting in $|0\rangle$,

$$P_1(t) = \frac{f_R^2}{f_R^2 + \delta^2}\sin^2\left(\pi\sqrt{f_R^2 + \delta^2}\,t\right)$$

- On resonance it reaches 1, at $t_\pi = \frac{1}{2f_R}$.
- Off resonance the swing is faster, at the **generalized Rabi frequency** $\sqrt{f_R^2 + \delta^2}$, and smaller.
- The resonance is a Lorentzian in δ with half-width $f_R$: a stronger drive is less selective (power broadening).

## On the Bloch sphere

The drive is a rotation of the state about an axis set by the drive's phase and detuning. A π pulse turns the north pole (|0⟩) to the south pole (|1⟩); a π/2 pulse leaves it on the equator. Quantum gates are rotations chosen by pulse length, amplitude and phase.

## Where it's used

- **MRI:** a π/2 pulse tips the protons' spins into the plane, where their precession induces a voltage in a pickup coil.
- **Qubits:** single-qubit gates are timed Rabi rotations; the qubit's frequency and the pulse's spectrum must keep it away from other transitions.
- **Atomic clocks and lasers:** the same mathematics with optical fields.
:::

::: example
## A spin is driven at 10 MHz Rabi frequency, 10 MHz off resonance. How far does it get, and how fast does it swing?

::: solution
1. **Largest transfer.**
   $$\frac{100}{100 + 100} = \frac12$$
2. **Generalized Rabi frequency.**
   $$\sqrt{100 + 100}\ \text{MHz} = 14.1\ \text{MHz}$$
   so the swing repeats every 70.7 ns.
3. **The resonance's width.** Detuning by $f_R$ halves the transfer: that's the resonance's half-width.

**Answer:** it reaches at most half the population, and the swing repeats every 70.7 ns (14.1 MHz).
:::
:::

::: example
## An ESR experiment applies a rotating field $B_1$ = 0.1 mT. How long is a π pulse?

::: solution
1. **Rabi frequency.**
   $$\begin{aligned} f_R &= 28.0 \times 0.1\ \text{MHz} \\ &= 2.80\ \text{MHz} \end{aligned}$$
2. **π pulse.**
   $$\begin{aligned} t_\pi &= \frac{1}{2 \times 2.80\text{ MHz}} \\ &= 178\ \text{ns} \end{aligned}$$
3. **A stronger field.** Doubling $B_1$ halves it, at the cost of four times the microwave power.

**Answer:** a π pulse lasts 178 ns.
:::
:::

::: example
## In a Ramsey experiment, two π/2 pulses are separated by a wait of T with the drive detuned by 100 kHz. How does the final population of |1⟩ vary with T?

::: solution
1. **Phase drift during the wait.** The state's phase drifts relative to the drive by $\Delta T$, so the second pulse finds it rotated and
   $$P_1 = \cos^2\frac{\Delta T}{2}$$
   with $\Delta = 2\pi \times 100$ kHz.
2. **The fringes.** The population oscillates with T, a fringe every 10 µs.
3. **Why it's useful.** Counting the fringes measures the detuning to a precision set by how long the wait can be, which is why atomic clocks use Ramsey's method: longer waits give narrower fringes and more precise frequencies.

**Answer:** $P_1 = \cos^2\frac{\Delta T}{2}$, which oscillates with a fringe every 10 µs.
:::
:::

::: check
given: f = 2 | 5 | 10; d = 1 | 4 | 15
answer: f^2/(f^2 + d^2)
tolerance: 0.1%

## A two-level system is driven with Rabi frequency {f} MHz, detuned by {d} MHz. What's the largest probability of reaching the upper state?

::: right
Right. $\frac{f_R^2}{f_R^2 + \delta^2}$ = {answer}.
:::

::: misses
- [f/(f + d)] Square the frequencies: it's a Lorentzian.
- [1] Only on resonance does the transfer reach 1.
- [any] Not yet. Rabi's formula's amplitude.
:::
:::

::: check
given: f = 4 | 12.5 | 50
answer: 1000/(2*f)
unit: ns
tolerance: 0.1%

## How long is a π pulse for Rabi frequency {f} MHz on resonance?

::: right
Right. $t_\pi = \frac{1}{2f_R}$ = {answer} ns.
:::

::: misses
- [1000/f] That's a full cycle, a 2π pulse, which returns to the start.
- [1000/(4*f)] That's a π/2 pulse.
- [any] Not yet. $\sin^2(\pi f_Rt) = 1$ first at $t = \frac{1}{2f_R}$.
:::
:::

::: check
given: f = 3 | 8; t = 20 | 50 | 110
answer: sin(pi*f*t/1000)^2
tolerance: 0.5%

## A resonant drive with Rabi frequency {f} MHz runs for {t} ns. What's the probability of the upper state?

::: right
Right. $\sin^2(\pi f_Rt)$ = {answer}.
:::

::: misses
- [sin(2*pi*f*t/1000)^2] The argument is $\pi f_Rt$: a full Rabi cycle takes $1/f_R$.
- [any] Not yet. On resonance, $P_1 = \sin^2(\pi f_Rt)$.
:::
:::

::: check
given: B = 0.05 | 0.2 | 1
answer: 1000/(2*28.025*B)
unit: ns
tolerance: 0.2%

## An electron spin is driven by a rotating field of {B} mT. How long is a π pulse?

::: right
Right. $f_R$ = 28.0 MHz/mT × $B_1$, so $t_\pi$ = {answer} ns.
:::

::: misses
- [1000/(28.025*B)] That's a 2π pulse.
- [any] Not yet. $t_\pi = \frac{1}{2f_R}$.
:::
:::

::: check
given: f = 5 | 15; d = 5 | 12 | 30
answer: 1000/sqrt(f^2 + d^2)
unit: ns
tolerance: 0.2%

## Rabi frequency {f} MHz, detuning {d} MHz: how long is one full swing up and back?

::: right
Right. $\frac{1}{\sqrt{f_R^2 + \delta^2}}$ = {answer} ns.
:::

::: misses
- [1000/f] Off resonance the swing is faster than $f_R$.
- [1000/(f + d)] Add in quadrature.
- [any] Not yet. The generalized Rabi frequency.
:::
:::

::: check
kind: choice

## A qubit in |0⟩ gets a π/2 pulse, then a second π/2 pulse with the same phase. What's the state?

- [ ] Still an equal superposition
- [x] |1⟩
- [ ] |0⟩
- [ ] A random one of |0⟩ and |1⟩

::: misses
- [1] Two quarter turns of the Bloch sphere make a half turn.
- [3] That would need the second pulse to undo the first, with the opposite phase.
- [4] The evolution is deterministic until a measurement.
:::
:::

::: check
kind: parts
given: O = 10 | 25; D = 5 | 20

## A two-level system is driven with Rabi frequency {O} MHz, {D} MHz off resonance.

::: part
answer: O^2/(O^2 + D^2)
tolerance: 0.5%

### What is the most it can be flipped?

::: misses
- [O/(O + D)] Rabi's formula has squares: $\frac{\Omega^2}{\Omega^2 + \Delta^2}$.
- [any] The amplitude of Rabi's formula.
:::
:::

::: part
answer: sqrt(O^2 + D^2)
unit: MHz
tolerance: 0.5%

### At what frequency does it swing?

::: misses
- [any] The generalized Rabi frequency $\sqrt{\Omega^2 + \Delta^2}$.
:::
:::
:::

::: check
kind: derivation
vars: O = 1..30, D = 0..30, t = 0..1

## Rabi's formula with drive Ω (write O), detuning Δ (write D) and time t (angular frequencies).

::: step
answer: O^2/(O^2 + D^2)*sin(sqrt(O^2 + D^2)*t/2)^2

### What is the population of the upper level?
:::

::: step
answer: 2*pi/sqrt(O^2 + D^2)

### What is the period of the oscillation?
:::

::: right
Right. Detuning speeds the oscillation up and shrinks it: a faster, shallower swing.
:::
:::

::: explain
## Why does a drive that's off resonance never fully flip a two-level system?

::: model
In the frame rotating with the drive, the system feels two effects at once: the drive, which tries to rotate the state between |0⟩ and |1⟩, and the detuning, which acts like a field along the |0⟩ to |1⟩ axis that makes the state precess around it. The combined rotation is about a tilted axis on the Bloch sphere. A state starting at the north pole circles that tilted axis and comes back without reaching the south pole; the more detuned the drive, the more the axis tips toward the pole and the smaller the circle. Only on resonance does the axis lie in the equator, so the circle passes through both poles.
:::
:::

::: practice

::: check
given: f = 3 | 20; d = 2 | 25
answer: f^2/(f^2 + d^2)
tolerance: 0.1%

## Largest transfer, $f_R$ = {f} MHz, δ = {d} MHz?

::: misses
- [any] $\frac{f_R^2}{f_R^2 + \delta^2}$.
:::
:::

::: check
given: f = 1 | 2 | 5 | 10 | 20 | 40
answer: 1000/(2*f)
unit: ns
tolerance: 0.1%

## π pulse for $f_R$ = {f} MHz?

::: misses
- [any] $\frac{1}{2f_R}$.
:::
:::

::: check
given: f = 6 | 10; t = 15 | 70
answer: sin(pi*f*t/1000)^2
tolerance: 0.5%

## Upper-state probability after {t} ns at $f_R$ = {f} MHz?

::: misses
- [any] $\sin^2(\pi f_Rt)$.
:::
:::
:::
