---
title: QAM, and the SNR cost of more bits per symbol
heading: Putting bits in amplitude and phase together, square QAM constellations from 16 to 256 points, Gray coding on a grid, the minimum distance at fixed energy and the Eb/N0 each doubling of points costs, peak-to-average power, and how links pick a constellation to fit the SNR
eyebrow: D12 · Lesson 9 · QAM
xp: 40
---

::: hook
QPSK uses only phase. Varying the amplitude too packs more points into the I/Q plane: 16 points carry 4 bits per symbol, 64 carry 6, 256 carry 8. Same symbol rate, same bandwidth, two to four times the data. The cost is that the points crowd together, so less noise is enough to push a symbol into its neighbor. Every Wi-Fi and cable modem link measures its SNR and picks the densest constellation that still works, stepping down when the signal fades.
:::

::: play
- 16-QAM received at the chosen $E_b/N_0$, with a carrier phase error θ.
- At the same $E_b/N_0$ that keeps QPSK's clouds well apart (8 dB), 16-QAM's overlap. It needs about 4 dB more for the same error rate.
- The outer points sit farthest from the origin, so a phase error moves them most: dense constellations need precise carrier recovery as well as high SNR.
:::

```sim plot
view: constellation
scheme: 16qam
slider: EbN0 = 0..20 = 12 dB step 0.5
slider: theta = -20..20 = 0 ° step 1
ebn0: EbN0
phase: theta°
symbols: 800
regions: on
```

::: predict
## Going from QPSK (2 bits per symbol) to 16-QAM (4 bits) doubles the bit rate in the same bandwidth. How much more Eb/N0 does 16-QAM need for about the same bit error rate?

- [ ] None
- [ ] 3 dB
- [x] About 4 dB
- [ ] About 12 dB

::: reveal
At equal energy per bit, 16-QAM's closest points are $\sqrt{1.6}$ apart against QPSK's $\sqrt{4}$, a squared-distance ratio of 2.5, which is 3.98 dB. Each further doubling of bits per symbol costs more: 64-QAM needs 8.5 dB more than QPSK, and 256-QAM 13.3 dB.
:::
:::

::: nameit
## Square QAM

Each axis uses √M levels, ±1, ±3, ..., ±(√M − 1), carrying $\frac{1}{2}\log_2 M$ bits Gray coded so that neighbors differ in one bit. The average symbol energy is $E_s = 2(M - 1)/3$ for spacing 2, so at fixed energy the minimum distance shrinks as

$$\frac{d_\min^2}{E_s} = \frac{6}{M - 1}, \qquad \frac{d_\min^2}{E_b} = \frac{6\log_2 M}{M - 1}$$

against 4 for QPSK. The penalty relative to QPSK at the same $E_b/N_0$ is $10\log_{10}\frac{4(M - 1)}{6\log_2 M}$.

## Error rate

Each axis is a √M-level PAM decision, with error rate $p = 2\left(1 - \frac{1}{\sqrt M}\right)Q\left(\sqrt{\frac{3E_s}{(M - 1)N_0}}\right)$, and the symbol is right only if both axes are: $P_s = 1 - (1 - p)^2$.

## Peak power

The corner points carry $2(\sqrt M - 1)^2$ against the average $2(M - 1)/3$, a peak-to-average ratio of $3(\sqrt M - 1)^2/(M - 1)$: 2.55 dB for 16-QAM, 3.68 dB for 64-QAM. The transmitter's amplifier must stay linear up to the peaks, which costs efficiency (D9).

## Adaptive modulation

Shannon's limit says a symbol can carry at most $\log_2(1 + \text{SNR})$ bits, so 4 bits need at least 11.8 dB of SNR and 8 bits 24.1 dB. Real constellations need a few dB more. Links measure SNR from the preamble and pilots and choose QPSK, 16-, 64-, 256- or 1024-QAM with a matching code rate.
:::

```sim plot
view: graph
x: e = 0..34
y: P = 1e-6..1 log
plot: 1 - (1 - 2*(1 - 1/2)*Q(sqrt(3*10^(e/10)/3)))^2 | samples: 400 | label: QPSK symbol error rate (Es/N0 in dB)
plot: 1 - (1 - 2*(1 - 1/4)*Q(sqrt(3*10^(e/10)/15)))^2 | samples: 400 | color: ch3 | label: 16-QAM
plot: 1 - (1 - 2*(1 - 1/8)*Q(sqrt(3*10^(e/10)/63)))^2 | samples: 400 | color: ch4 | label: 64-QAM
plot: 1 - (1 - 2*(1 - 1/16)*Q(sqrt(3*10^(e/10)/255)))^2 | samples: 400 | color: ch2 | label: 256-QAM
```

::: example
## What Es/N0 does each constellation need for a symbol error rate of 10⁻³?

::: solution
1. **Solve the formula numerically.** Set the symbol error rate to $10^{-3}$ for each constellation and solve for $E_s/N_0$:
   $$\begin{aligned} \text{QPSK:}\ &10.3\ \text{dB} \\ \text{16-QAM:}\ &17.6\ \text{dB} \\ \text{64-QAM:}\ &24.0\ \text{dB} \\ \text{256-QAM:}\ &30.1\ \text{dB} \end{aligned}$$
2. **The pattern.** That's roughly 6 to 7 dB for each extra 2 bits per symbol, as the curves show.

**Answer:** QPSK needs 10.3 dB, 16-QAM 17.6 dB, 64-QAM 24.0 dB and 256-QAM 30.1 dB.
:::
:::

::: example
## How much average energy does 64-QAM with levels ±1, ±3, ±5, ±7 have, and what's its peak-to-average ratio?

::: solution
1. **Average energy.**
   $$\begin{aligned} E_{\text{avg}} &= \frac{2(64 - 1)}{3} \\ &= 42 \end{aligned}$$
2. **Peak energy.** The corner (7, 7) has
   $$7^2 + 7^2 = 98$$
3. **Peak-to-average ratio.**
   $$\frac{98}{42} = 2.33$$
   or 3.68 dB.

**Answer:** an average energy of 42 and a peak-to-average ratio of 2.33, or 3.68 dB.
:::
:::

::: example
## 16-QAM runs at 1200 baud. What bit rate does it carry, and what $E_b/N_0$ corresponds to the 17.6 dB of $E_s/N_0$ it needs?

::: solution
1. **Bit rate.** 16-QAM carries 4 bits per symbol:
   $$4 \times 1200 = 4800\ \text{bit/s}$$
2. **Energy per bit.**
   $$\begin{aligned} \frac{E_b}{N_0} &= \frac{E_s}{N_0} - 10\log_{10}4 \\ &= 17.6 - 6.0 \\ &= 11.6\ \text{dB} \end{aligned}$$
3. **The trade.** Packing more bits per symbol costs energy per bit, but saves bandwidth.

**Answer:** 4800 bit/s, and $E_b/N_0$ = 11.6 dB.
:::
:::

::: check
kind: python

## Map and slice 16-QAM, and check the error-rate formula against a simulation.

```python starter
import numpy as np
from math import erfc, sqrt

LEVELS = {(0, 0): -3, (0, 1): -1, (1, 1): 1, (1, 0): 3}   # Gray coded: neighbors differ in one bit
SCALE = 1/np.sqrt(10)                                     # average symbol energy 1

def qam16_map(bits):
    # Groups of 4 bits: the first two pick the real level, the last two the imaginary level,
    # from LEVELS, times SCALE. Return a complex numpy array.
    return np.zeros(len(bits)//4, dtype=complex)

def qam16_slice(z):
    # Back to bits: for each part, pick the nearest of the four levels (times SCALE) and
    # output its two bits, real part first.
    return []

def ser_16qam(esn0):
    # The symbol error rate formula for 16-QAM at Es/N0 = esn0 (a ratio, not dB):
    # p = 2*(1 - 1/4)*Q(sqrt(3*esn0/15)) per axis, and 1 - (1 - p)**2 for the symbol.
    # Q(x) = 0.5*erfc(x/sqrt(2)).
    return 0.0
```

```python solution
import numpy as np
from math import erfc, sqrt

LEVELS = {(0, 0): -3, (0, 1): -1, (1, 1): 1, (1, 0): 3}   # Gray coded: neighbors differ in one bit
SCALE = 1/np.sqrt(10)                                     # average symbol energy 1

def qam16_map(bits):
    b = np.asarray(bits).reshape(-1, 4)
    i = np.array([LEVELS[(x[0], x[1])] for x in b])
    q = np.array([LEVELS[(x[2], x[3])] for x in b])
    return SCALE*(i + 1j*q)

def qam16_slice(z):
    inv = {v: k for k, v in LEVELS.items()}
    lv = np.array([-3, -1, 1, 3])
    out = []
    for v in z:
        for part in (v.real, v.imag):
            nearest = lv[np.argmin(np.abs(part/SCALE - lv))]
            out += list(inv[int(nearest)])
    return out

def ser_16qam(esn0):
    p = 2*(1 - 1/4)*0.5*erfc(sqrt(3*esn0/15)/sqrt(2))
    return 1 - (1 - p)**2
```

```python tests
assert np.isclose(qam16_map([1, 0, 0, 0])[0], (3 - 3j)/np.sqrt(10)), "1000 is the real level +3 and the imaginary level −3, over √10."
_rng = np.random.default_rng(16)
_bits = list(_rng.integers(0, 2, 4000))
_s = qam16_map(_bits)
assert abs(np.mean(np.abs(_s)**2) - 1) < 0.05, "The scaled constellation has an average energy of 1."
assert qam16_slice(_s) == _bits, "Without noise every bit comes back."
assert abs(ser_16qam(10**1.8) - 5.73e-4) < 1e-5, f"At Es/N0 = 18 dB the formula gives a symbol error rate of 5.73e-4; got {ser_16qam(10**1.8):.3g}."
_big = list(_rng.integers(0, 2, 80000))
_sym = qam16_map(_big)
_sigma = 0.12
_r = _sym + _sigma*(_rng.standard_normal(len(_sym)) + 1j*_rng.standard_normal(len(_sym)))
_rb = np.array(qam16_slice(_r)).reshape(-1, 4)
_ser = np.mean(np.any(_rb != np.array(_big).reshape(-1, 4), axis=1))
_ref = ser_16qam(1/(2*_sigma**2))
assert 0.85*_ref < _ser < 1.15*_ref, f"With noise σ = {_sigma} per part, Es/N0 = 1/(2σ²); the measured symbol error rate {_ser:.4f} should match the formula's {_ref:.4f}."
```

::: right
Right. Your 16-QAM slicer gets every bit back without noise, and its measured symbol error rate matches the formula.
:::
:::

::: check
given: M = 16 | 64 | 256 | 1024
answer: 10*log(4*(M - 1)/(6*log(M)/log(2)))
unit: dB
tolerance: 0.5%

## How much more Eb/N0 than QPSK does {M}-QAM need for a similar error rate, judging by minimum distance?

::: right
Right. $10\log_{10}\frac{4(M - 1)}{6\log_2 M}$ = {answer} dB.
:::

::: misses
- [10*log((M - 1)/3)] That compares energy per symbol; per bit, the extra bits pay back part of it.
- [any] Not yet. Compare $d_\min^2/E_b$ with QPSK's 4.
:::
:::

::: check
given: M = 16 | 64 | 256 | 1024
answer: 10*log(3*(sqrt(M) - 1)^2/(M - 1))
unit: dB
tolerance: 0.5%

## What's the peak-to-average power ratio of square {M}-QAM?

::: right
Right. $3(\sqrt M - 1)^2/(M - 1)$ = {answer} dB.
:::

::: misses
- [any] Not yet. The corner point's energy over the average.
:::
:::

::: check
given: b = 2 | 4 | 6 | 8 | 10
answer: 10*log(2^b - 1)
unit: dB
tolerance: 0.5%

## By Shannon's limit, what's the least SNR at which a symbol can carry {b} bits?

::: right
Right. $2^b - 1$ = {answer} dB.
:::

::: misses
- [any] Not yet. Solve $b = \log_2(1 + \text{SNR})$.
:::
:::

::: check
kind: parts
given: M = 4 | 16 | 64 | 256; R = 1200 | 2400

## {M}-QAM runs at {R} baud.

::: part
answer: R*log(M)/log(2)
unit: bit/s
tolerance: 0.5%

### What bit rate does it carry?

::: misses
- [any] Baud × $\log_2M$.
:::
:::

::: part
answer: 2*(M - 1)/3
tolerance: 0.5%

### What is its average energy with odd-integer levels?

::: misses
- [any] $2(M - 1)/3$.
:::
:::
:::

::: check
kind: parts
given: S = 10.3 | 17.6 | 24 | 30.1; k = 2 | 4 | 6 | 8

## A constellation of {k} bits per symbol needs $E_s/N_0$ = {S} dB.

::: part
answer: S - 10*log(k)
unit: dB
tolerance: 0.5%

### What $E_b/N_0$ is that?

::: misses
- [any] $E_s/N_0 - 10\log_{10}k$.
:::
:::

::: part
answer: 10^(S/10)
tolerance: 0.5%

### What linear ratio is $E_s/N_0$?

::: misses
- [any] $10^{S/10}$.
:::
:::
:::

::: explain
## Why does packing more points into a constellation make it more sensitive to noise?

::: model
A constellation has a fixed average energy, set by the transmitter's power. Fitting more points into the same energy means placing them closer together, so the distance from each point to its nearest neighbor shrinks. Noise pushes each received symbol randomly away from where it was sent, and an error happens when it crosses halfway to a neighbor, so a smaller distance means a smaller push is enough. To keep the same error rate with a denser constellation, the signal has to be stronger relative to the noise, roughly 6 dB more for every two extra bits per symbol once the constellation is large.
:::
:::

::: practice

::: check
given: M = 16 | 64 | 256 | 4096
answer: 2*(M - 1)/3
tolerance: 0.5%

## Average energy of {M}-QAM with spacing 2?

::: misses
- [any] $2(M - 1)/3$.
:::
:::

::: check
given: b = 3 | 5 | 7 | 12
answer: 10*log(2^b - 1)
unit: dB
tolerance: 0.5%

## Least SNR for {b} bits per symbol?

::: misses
- [any] $10\log_{10}(2^b - 1)$.
:::
:::
:::
