---
title: "Antenna lab: patterns, directivity and array synthesis"
heading: Directivity by numerical integration, array factors with arbitrary weights, and Dolph–Chebyshev sidelobe control
eyebrow: S5 · Lesson 49 · Antenna lab
xp: 60
---

::: hook
Closed-form directivities exist only for a few ideal patterns. Real antenna work computes them: integrate the radiation intensity over the sphere and divide its peak by its average. In this lab you'll write that integral, then an array factor that takes any set of element weights, and then the classic synthesis problem: Dolph's choice of weights that makes every sidelobe exactly as low as the specification allows, with the narrowest beam possible at that level. The tests check your code against exact results, including the directivity of a half-wave dipole that many textbooks round to the wrong last digit.
:::

::: predict
## A uniform broadside array of 8 isotropic elements spaced exactly λ/2 apart: what's its directivity?

- [ ] About 8, by the approximation 2Nd/λ
- [x] Exactly 8
- [ ] 16
- [ ] 64

::: reveal
Exactly 8: at λ/2 spacing, the cross terms between elements integrate to zero over the sphere, so the average intensity is N times one element's while the peak is N² times, giving D = N exactly. At other spacings 2Nd/λ is only an approximation, and your numerical integral will show by how much.
:::
:::

::: nameit
## Directivity of an axially symmetric pattern

For a pattern U(θ) that doesn't depend on φ,

$$D = \frac{4\pi U_\text{max}}{\int_0^{2\pi}\!\int_0^\pi U\sin\theta\,d\theta\,d\phi} = \frac{2U_\text{max}}{\int_0^\pi U(\theta)\sin\theta\,d\theta}$$

The trapezoid rule on a fine grid (20,000 points) is accurate to many digits for smooth patterns. In NumPy, `np.trapezoid(y, x)`.

## The array factor along an axis

Elements along z, spacing d (in wavelengths), complex weights $w_n$, θ from the axis:

$$\text{AF}(\theta) = \left|\sum_{n=0}^{N-1}w_ne^{jn\psi}\right|, \qquad \psi = 2\pi d\cos\theta + \beta$$

(Broadside is θ = 90° here, with β = 0.) The pattern is $U \propto \text{AF}^2$ times the element pattern.

## Dolph–Chebyshev weights

Write the array factor of a symmetric N-element array as a polynomial in $\cos(\psi/2)$ of degree N − 1 and make it the Chebyshev polynomial $T_{N-1}(x_0\cos\frac{\psi}{2})$: Chebyshev polynomials ripple between ±1 on [−1, 1] and grow fast outside it, so every sidelobe has the same height and the main beam is R times higher. With the sidelobe ratio $R = 10^{\text{SLL}/20}$,

$$x_0 = \cosh\left(\frac{\cosh^{-1}R}{N - 1}\right)$$

Sample $T_{N-1}(x_0\cos\frac{\psi_k}{2})$ at $\psi_k = 2\pi k/N$ and invert the DFT (with the element index centered, $m = n - \frac{N - 1}{2}$) to get the weights; normalize the largest to 1. For |x| > 1, $T_n(x) = \cosh(n\cosh^{-1}|x|)$ with the sign of $x^n$.
:::

::: example
## What does numerical integration give for the half-wave dipole, and why do books disagree in the third digit?

::: solution
1. **The integral.**
   $$\begin{aligned} I &= \int_0^\pi \left(\frac{\cos(\frac{\pi}{2}\cos\theta)}{\sin\theta}\right)^2\sin\theta\,d\theta \\ &= 1.2188 \end{aligned}$$
2. **Directivity.**
   $$\begin{aligned} D &= \frac{2}{I} \\ &= 1.6409 \end{aligned}$$
3. **Closed form.** D is $4/\text{Cin}(2\pi)$, with
   $$\begin{aligned} \text{Cin}(2\pi) &= \gamma + \ln 2\pi - \text{Ci}(2\pi) \\ &= 2.4377 \end{aligned}$$
4. **Why books disagree.** Some textbooks use a rounded 2.435 and print 1.643. In decibels that's 2.16 dBi, against 2.15 dBi for 1.6409, and the integral settles it.

**Answer:** the integral gives D = 1.6409 (2.15 dBi); books that print 1.643 used a rounded Cin(2π) of 2.435.
:::
:::

::: example
## What weights does an 8-element, 30 dB Dolph–Chebyshev array need, and what does it cost?

::: solution
1. **The weights.** From the center out, 1, 0.812, 0.519 and 0.262 (symmetric).
2. **The sidelobes.** Every sidelobe sits at exactly −30 dB, against −13.3 dB for uniform weights.
3. **The cost.** The beam widens by about 30% and the directivity falls, because the outer elements contribute less.

**Answer:** the weights are 1, 0.812, 0.519 and 0.262 from the center out; the price is a beam about 30% wider and a lower directivity.
:::
:::

::: check
kind: python

## Step 1. Write `directivity(U)`: an axially symmetric pattern's directivity by numerical integration.

```python starter
import numpy as np

def directivity(U, n=20001):
    # U(theta): radiation intensity of an axially symmetric pattern, theta from 0 to pi.
    # D = 4*pi*U_max / (2*pi * integral of U(theta) sin(theta) dtheta)
    return 1.0

print(directivity(lambda t: np.sin(t)**2))
```

```python solution
import numpy as np

def directivity(U, n=20001):
    th = np.linspace(0.0, np.pi, n)
    u = np.array([U(t) for t in th], dtype=float)
    integral = np.trapezoid(u * np.sin(th), th)
    return 2.0 * u.max() / integral

print(directivity(lambda t: np.sin(t)**2))
```

```python tests
import numpy as np
hw = lambda t: (np.cos(np.pi/2*np.cos(t))/np.sin(t))**2 if np.sin(t) > 1e-12 else 0.0
assert abs(directivity(lambda t: np.sin(t)**2) - 1.5) < 1e-4, f"A short dipole's directivity is 1.5; got {directivity(lambda t: np.sin(t)**2)}."
assert abs(directivity(lambda t: np.sin(t)**4) - 1.875) < 1e-4, f"sin^4 gives 2/(16/15) = 1.875; got {directivity(lambda t: np.sin(t)**4)}."
assert abs(directivity(hw) - 1.6409) < 2e-4, f"A half-wave dipole's directivity is 4/Cin(2π) = 1.6409; got {directivity(hw)}."
for n in (2, 6, 10):
    D = directivity(lambda t: np.cos(t)**n if t < np.pi/2 else 0.0)
    assert abs(D - 2*(n + 1)) < 1e-3 * 2*(n + 1), f"cos^{n} over a hemisphere has D = {2*(n + 1)}; got {D}."
```

::: right
Right. One integral over θ turns any pattern into its directivity: 1.5 for the short dipole, 1.6409 for the half-wave dipole, 2(n + 1) for a cosine power.
:::
:::

::: check
kind: python

## Step 2. Write `array_factor(w, d, beta, theta)` for any weights.

```python starter
import numpy as np

def directivity(U, n=20001):
    th = np.linspace(0.0, np.pi, n)
    u = np.array([U(t) for t in th], dtype=float)
    integral = np.trapezoid(u * np.sin(th), th)
    return 2.0 * u.max() / integral

def array_factor(w, d, beta, theta):
    # |sum of w_n exp(j n psi)|, psi = 2*pi*d*cos(theta) + beta, d in wavelengths,
    # theta measured from the array's axis.
    return 0.0

print(array_factor([1, 1, 1, 1], 0.5, 0.0, np.pi/2))
```

```python solution
import numpy as np

def directivity(U, n=20001):
    th = np.linspace(0.0, np.pi, n)
    u = np.array([U(t) for t in th], dtype=float)
    integral = np.trapezoid(u * np.sin(th), th)
    return 2.0 * u.max() / integral

def array_factor(w, d, beta, theta):
    w = np.asarray(w, dtype=complex)
    n = np.arange(len(w))
    psi = 2 * np.pi * d * np.cos(theta) + beta
    return abs(np.sum(w * np.exp(1j * n * psi)))

print(array_factor([1, 1, 1, 1], 0.5, 0.0, np.pi/2))
```

```python tests
import numpy as np, random
for N in (4, 8, 12):
    D = directivity(lambda t: array_factor(np.ones(N), 0.5, 0.0, t)**2, n=40001)
    assert abs(D - N) < 1e-3 * N, f"A uniform broadside array of {N} elements at λ/2 has D = {N}; got {D}."
rng = random.Random(7)
for _ in range(30):
    N = rng.randint(2, 16); d = rng.uniform(0.2, 1.2); b = rng.uniform(-np.pi, np.pi); t = rng.uniform(0.01, np.pi - 0.01)
    psi = 2*np.pi*d*np.cos(t) + b
    want = abs(np.sin(N*psi/2)/np.sin(psi/2)) if abs(np.sin(psi/2)) > 1e-9 else N
    got = array_factor(np.ones(N), d, b, t)
    assert abs(got - want) < 1e-9 * N, f"N = {N}, d = {d:.3f}λ, β = {b:.3f}, θ = {t:.3f}: |AF| should be {want:.6f}; got {got:.6f}."
w = [1, 2, 3]
assert abs(array_factor(w, 0.5, 0.0, np.pi/2) - 6) < 1e-12, "At broadside the weights add: 1 + 2 + 3 = 6."
```

::: right
Right. With the array factor and the directivity integral together, any linear array's directivity can be computed: exactly N for a uniform λ/2 array at broadside.
:::
:::

::: check
kind: python

## Step 3. Write `dolph_chebyshev(N, sll_db)`: weights for equal sidelobes at a chosen level.

```python starter
import numpy as np

def array_factor(w, d, beta, theta):
    w = np.asarray(w, dtype=complex)
    n = np.arange(len(w))
    psi = 2 * np.pi * d * np.cos(theta) + beta
    return abs(np.sum(w * np.exp(1j * n * psi)))

def dolph_chebyshev(N, sll_db):
    # Weights (peak 1) for an N-element array whose sidelobes all sit sll_db below the beam.
    # Hint: AF(psi) = T_{N-1}(x0 cos(psi/2)) with x0 = cosh(acosh(R)/(N-1)), R = 10^(sll/20);
    # sample it at psi_k = 2*pi*k/N and invert the DFT.
    return np.ones(N)

print(np.round(dolph_chebyshev(8, 30), 4))
```

```python solution
import numpy as np

def array_factor(w, d, beta, theta):
    w = np.asarray(w, dtype=complex)
    n = np.arange(len(w))
    psi = 2 * np.pi * d * np.cos(theta) + beta
    return abs(np.sum(w * np.exp(1j * n * psi)))

def dolph_chebyshev(N, sll_db):
    R = 10 ** (sll_db / 20)
    x0 = np.cosh(np.arccosh(R) / (N - 1))
    k = np.arange(N)
    psi = 2 * np.pi * k / N
    x = x0 * np.cos(psi / 2)
    T = np.where(np.abs(x) <= 1, np.cos((N - 1) * np.arccos(np.clip(x, -1, 1))), np.cosh((N - 1) * np.arccosh(np.maximum(np.abs(x), 1))) * np.sign(x) ** (N - 1))
    n = np.arange(N) - (N - 1) / 2
    w = np.array([np.sum(T * np.exp(1j * m * psi)) for m in n]).real / N
    return w / w.max()

print(np.round(dolph_chebyshev(8, 30), 4))
```

```python tests
import numpy as np
w = dolph_chebyshev(8, 30)
ref = [0.2622, 0.5187, 0.8120, 1.0, 1.0, 0.8120, 0.5187, 0.2622]
assert len(w) == 8 and all(abs(a - b) < 1e-3 for a, b in zip(w, ref)), f"N = 8 at 30 dB should give {ref}; got {np.round(w, 4)}."
for N, s in ((6, 20), (9, 35), (12, 25), (15, 40)):
    w = np.asarray(dolph_chebyshev(N, s))
    assert len(w) == N and abs(w.max() - 1) < 1e-9 and np.allclose(w, w[::-1]), f"N = {N}: weights must number N, peak at 1 and be symmetric."
    th = np.linspace(0, np.pi, 30001)
    af = np.array([array_factor(w, 0.5, 0.0, t) for t in th]); af /= af.max()
    i = np.r_[False, (af[1:-1] > af[:-2]) & (af[1:-1] > af[2:]), False]
    peaks = af[i]; peaks = peaks[peaks < 0.999]
    sll = 20*np.log10(peaks.max())
    assert abs(sll + s) < 0.05, f"N = {N}: the highest sidelobe should be -{s} dB; it's {sll:.2f} dB."
```

::: right
Right. Dolph's design puts every sidelobe at exactly the chosen level, the narrowest beam possible for that sidelobe level.
:::
:::

::: explain
## Why do Dolph–Chebyshev arrays give the narrowest beam for a given sidelobe level?

::: model
A linear array's factor is a polynomial in a variable that runs over a fixed range as the observation angle sweeps through visible space, so designing the weights means choosing a polynomial of degree N − 1. The beamwidth is set by how quickly the polynomial rises from its sidelobe region to its peak, and the sidelobes by how high it gets anywhere in that region. Among all polynomials of a given degree that stay within ±1 on an interval, the Chebyshev polynomial grows fastest outside it, a classic result in approximation theory. Mapping the sidelobe region onto that interval and the beam onto the steep part outside it therefore gives the fastest possible rise, the narrowest beam, for the chosen sidelobe height, with all sidelobes equal because the polynomial ripples evenly.
:::
:::

::: practice

::: check
given: N = 4 | 10 | 20; d = 0.5 | 0.7
answer: 2*N*d
tolerance: 0.5%

## Approximate directivity of a {N}-element broadside array at {d}λ?

::: misses
- [any] $2Nd/\lambda$.
:::
:::

::: check
given: s = 20 | 30 | 40
answer: 10^(s/20)
tolerance: 0.5%

## Main-beam to sidelobe amplitude ratio R for {s} dB sidelobes?

::: misses
- [any] $R = 10^{\text{SLL}/20}$.
:::
:::

::: check
given: s = 20 | 30 | 40; N = 6 | 8 | 12
answer: (exp(ln(10^(s/20) + sqrt(10^(s/10) - 1))/(N - 1)) + exp(-ln(10^(s/20) + sqrt(10^(s/10) - 1))/(N - 1)))/2
tolerance: 0.5%

## Dolph–Chebyshev $x_0$ for N = {N}, {s} dB?

::: misses
- [any] $\cosh(\cosh^{-1}R/(N - 1))$.
:::
:::
:::
