---
title: Chebyshev approximation
heading: Chebyshev polynomials, near-best polynomial fits and equal ripple
eyebrow: A13 · Lesson 13 · Chebyshev approximation
xp: 40
---

::: hook
A calculator's sine routine and a microcontroller's temperature conversion both replace a function with a polynomial. A Taylor polynomial is the obvious choice, but it's accurate only near its center point and wastes accuracy there. What you want is the polynomial whose worst error over the whole interval is as small as possible, the **minimax** polynomial. Chebyshev polynomials get you almost all the way there with no search at all, and their equal-ripple shape is the same one behind Chebyshev filters.
:::

::: play
- The curve is the Chebyshev polynomial $T_n(x) = \cos(n\cos^{-1}x)$ on $[-1, 1]$. Step n.
- It stays between −1 and 1, touching each extreme n + 1 times, while its leading coefficient is $2^{n-1}$, as large as possible for that. No other polynomial with the same leading coefficient stays this small.
- The readout gives $2^{1-n}$: the smallest possible maximum of a monic degree-n polynomial on the interval, reached by $T_n/2^{n-1}$.
:::

```sim plot
view: graph
x: x = -1..1
y: T = -1.3..1.3
slider: n = 1..10 step 1 = 4
plot: cos(n*acos(x)) | label: Tₙ(x) | samples: 600
readout: smallest max of a monic polynomial = 2^(1 - n) | digits: 4
```

::: predict
## On [−1, 1], how do the worst errors of the cubic Taylor polynomial of $e^x$ and of its cubic Chebyshev truncation compare?

- [ ] They're about the same
- [x] The Chebyshev one is about 8 times smaller
- [ ] The Taylor one is smaller, since it matches more derivatives
- [ ] The Chebyshev one is about 100 times smaller

::: reveal
About 8 times smaller: 0.0061 against 0.052. The Taylor cubic is perfect at 0 and poor at the ends, where its error reaches $e - 2.667$. The Chebyshev cubic spreads its error evenly across the interval, wiggling up and down almost like $T_4$.
:::
:::

::: nameit
## Chebyshev polynomials

$T_0 = 1$, $T_1 = x$ and $T_{n+1} = 2xT_n - T_{n-1}$, so $T_2 = 2x^2 - 1$, $T_3 = 4x^3 - 3x$ and $T_4 = 8x^4 - 8x^2 + 1$. On $[-1, 1]$, $T_n(\cos\theta) = \cos n\theta$: it oscillates between ±1, with n + 1 extremes and n zeros (the Chebyshev nodes of lesson 11).

## Chebyshev series

A smooth f on $[-1, 1]$ has an expansion $f = \frac{c_0}{2} + \sum_{k\ge1}c_kT_k(x)$ with $c_k = \frac2\pi\int_0^\pi f(\cos\theta)\cos k\theta\,d\theta$: a Fourier cosine series in disguise. For analytic f the coefficients fall geometrically. Truncating after $T_n$ leaves an error close to $c_{n+1}T_{n+1}(x)$, which nearly equioscillates, so the truncated series is **near-minimax**: its worst error is within a small factor of the best possible.

## Minimax and equioscillation

The best degree-n polynomial in the worst-case sense is characterized by its error reaching its maximum size n + 2 times with alternating signs (the equioscillation theorem). The Remez algorithm finds it by moving those extreme points until they balance; in practice, Chebyshev truncation is often good enough and far simpler.

## Economization

To lower a polynomial's degree with the least damage on $[-1, 1]$, subtract a multiple of a Chebyshev polynomial: $x^n$ can be replaced by $x^n - \frac{T_n}{2^{n-1}}$, a degree n − 2 polynomial, at a cost of at most $2^{1-n}$.

## Chebyshev filters

A Chebyshev low-pass filter has $\lvert H\rvert^2 = \frac{1}{1 + \varepsilon^2T_n^2(\omega/\omega_c)}$. In the passband $T_n$ wiggles between ±1, so the gain ripples by $10\log_{10}(1 + \varepsilon^2)$ dB; outside it, $T_n$ grows as fast as any degree-n polynomial can, giving the steepest roll-off for that ripple.
:::

::: example
## Find the Chebyshev coefficients of $e^x$ and the error of truncating after $T_3$.

::: solution
1. **The coefficients.** For $e^x$ they are $c_k = 2I_k(1)$, with $I_k$ the modified Bessel functions:
   $$\begin{aligned} \frac{c_0}{2} &= 1.266066 \\ c_1 &= 1.130318 \\ c_2 &= 0.271495 \\ c_3 &= 0.044337 \\ c_4 &= 0.005474 \\ c_5 &= 0.000543 \end{aligned}$$
   Each is about a tenth of the one before.
2. **Truncate after $T_3$.** The error left is mostly $c_4T_4$, so its worst size should be a bit over 0.0055; measuring gives 0.0061.
3. **Compare with Taylor.** The cubic Taylor polynomial's worst error is 0.052. At the same degree and the same cost to evaluate, the Chebyshev cubic is about 8 times more accurate.

**Answer:** $\frac{c_0}{2} = 1.266066$, $c_1 = 1.130318$, $c_2 = 0.271495$, $c_3 = 0.044337$, $c_4 = 0.005474$ and $c_5 = 0.000543$; truncating after $T_3$ leaves a worst error of 0.0061.
:::
:::

::: example
## What is the best quadratic approximation to $x^3$ on [−1, 1], in the worst-case sense?

::: solution
1. **Subtract the Chebyshev term.**
   $$\begin{aligned} x^3 - \frac{T_3}{4} &= x^3 - \frac{4x^3 - 3x}{4} \\ &= \frac34x \end{aligned}$$
2. **The error equioscillates.** The error, $x^3 - \frac34x = \frac{T_3}{4}$, equioscillates four times between ±¼, at x = −1, −½, ½ and 1, so by the equioscillation theorem nothing does better.
3. **Compare with Taylor.** The best quadratic happens to be a straight line, $\frac34x$, with worst error 0.25. Taylor's suggestion (drop $x^3$ entirely) would have a worst error of 1.
4. **Economization.** Economization does this degree by degree to shorten long series.

**Answer:** the straight line $\frac34x$, with worst error 0.25.
:::
:::

::: example
## A fourth-order Chebyshev low-pass filter has ε = 0.5. What is its passband ripple, and how much does it attenuate at twice the cutoff?

::: solution
1. **Passband ripple.**
   $$10\log_{10}(1 + 0.25) = 0.97\ \text{dB}$$
2. **$T_4$ at twice the cutoff.**
   $$\begin{aligned} T_4(2) &= 8 \times 16 - 8 \times 4 + 1 \\ &= 97 \end{aligned}$$
3. **Attenuation there.**
   $$\begin{aligned} \lvert H\rvert^2 &= \frac{1}{1 + 0.25 \times 97^2} \\ &= \frac{1}{2353} \end{aligned}$$
   an attenuation of 33.7 dB.
4. **Compare with Butterworth.** A fourth-order Butterworth filter gives
   $$10\log_{10}(1 + 2^8) = 24.1\ \text{dB}$$
   at the same point.
5. **What the ripple buys.** Allowing ripple in the passband buys almost 10 dB of extra stopband attenuation, because $T_4$ grows faster than $\omega^4$ outside the band.

**Answer:** 0.97 dB of passband ripple and 33.7 dB of attenuation at twice the cutoff.
:::
:::

::: check
kind: parts
given: x = 0.3 | 0.8 | -0.6

## Chebyshev polynomials at x = {x}.

::: part
answer: 4*x^3 - 3*x
tolerance: 0.5%

### What is $T_3(x)$?

::: misses
- [any] $T_3 = 4x^3 - 3x$.
:::
:::

::: part
answer: 8*x^4 - 8*x^2 + 1
tolerance: 0.5%

### What is $T_4(x)$?

::: misses
- [any] $T_4 = 2xT_3 - T_2$.
:::
:::
:::

::: check
given: n = 3 | 5 | 8
answer: 2^(1 - n)
tolerance: 0.5%

## What is the smallest possible worst error on [−1, 1] when $x^{\given{n}}$ is replaced by a polynomial of lower degree?

::: right
Right. $2^{1-n}$, by subtracting $\frac{T_n}{2^{n-1}}$.
:::

::: misses
- [1] That's for dropping the term entirely.
- [any] The monic polynomial with smallest maximum is $T_n/2^{n-1}$.
:::
:::

::: check
given: e = 0.35 | 0.5 | 1
answer: 10*log(1 + e^2)
unit: dB
tolerance: 0.5%

## A Chebyshev filter has ripple factor ε = {e}. What is its passband ripple?

::: right
Right. $10\log_{10}(1 + \varepsilon^2)$.
:::

::: misses
- [20*log(1 + e^2)] $\lvert H\rvert^2$ swings between 1 and $\frac{1}{1 + \varepsilon^2}$; use $10\log_{10}$ of the power ratio.
- [any] The gain swings between 1 and $1/\sqrt{1 + \varepsilon^2}$.
:::
:::

::: check
given: e = 0.5 | 1; w = 1.5 | 2 | 3
answer: 10*log(1 + e^2*(8*w^4 - 8*w^2 + 1)^2)
unit: dB
tolerance: 0.5%

## A fourth-order Chebyshev low-pass with ε = {e}: how much does it attenuate at {w} times its cutoff?

::: right
Right. $10\log_{10}(1 + \varepsilon^2T_4^2)$, with $T_4$ growing fast outside the band.
:::

::: misses
- [10*log(1 + w^8)] That's a Butterworth filter.
- [any] $T_4(w) = 8w^4 - 8w^2 + 1$.
:::
:::

::: check
given: r = 5 | 10 | 100
answer: ceil(10/log(r))
tolerance: 0

## A function's Chebyshev coefficients fall by a factor {r} from each term to the next, starting near 1. How many terms come before one falls below $10^{-10}$?

::: right
Right. Each term gains $\log_{10}r$ digits.
:::

::: misses
- [any] Solve $r^{-k} \le 10^{-10}$.
:::
:::

::: check
given: a = 0 | 2; b = 4 | 10; t = 30 | 60
answer: (a + b)/2 + (b - a)/2*cos(t*pi/180)
tolerance: 0.5%

## Chebyshev points on [{a}, {b}] are $x = \frac{a + b}{2} + \frac{b - a}{2}\cos\theta$. Where is the one with θ = {t}°?

::: right
Right. The standard points on [−1, 1], scaled and shifted.
:::

::: misses
- [cos(t*pi/180)] Map from [−1, 1] to the interval.
- [any] Shift by the midpoint and scale by the half-width.
:::
:::

::: check
kind: choice

## Why is a truncated Chebyshev series nearly the best polynomial in the worst-case sense?

- [ ] Because it interpolates f at the Chebyshev nodes
- [x] Because its error is dominated by the next term, $c_{n+1}T_{n+1}$, which nearly equioscillates
- [ ] Because Chebyshev polynomials are orthogonal
- [ ] Because it matches the derivatives at the center

::: right
Right. An error that equioscillates n + 2 times is the hallmark of the minimax polynomial, and $T_{n+1}$ does exactly that.
:::

::: misses
- [1] Interpolation at Chebyshev nodes is also near-best, but it's a different construction.
- [3] Orthogonality gives the formula for the coefficients; the near-best property comes from the error's shape.
- [4] That's Taylor's approach, which concentrates accuracy at one point.
:::
:::

::: check
kind: derivation
vars: x = -1..1

## Build Chebyshev polynomials from $T_{n+1} = 2xT_n - T_{n-1}$, with $T_0 = 1$ and $T_1 = x$.

::: step
answer: 2*x^2 - 1

### What is $T_2$?
:::

::: step
answer: 4*x^3 - 3*x

### What is $T_3$?
:::

::: step
answer: 8*x^4 - 8*x^2 + 1

### What is $T_4$?
:::

::: right
Right. Each has leading coefficient $2^{n-1}$ and stays within ±1 on the interval.
:::
:::

::: explain
## Why does a Taylor polynomial waste accuracy when used over a whole interval?

::: model
A Taylor polynomial matches the function and its derivatives at one point, so its error grows like $(x - x_0)^{n+1}$: tiny near the center and largest at the ends. When the polynomial must work everywhere on the interval, only the worst point matters, and the accuracy near the center is wasted. A Chebyshev approximation trades some of that unneeded accuracy in the middle for a smaller error at the ends, spreading the error evenly in a ripple of equal height. For the same degree and the same cost to evaluate, the worst error drops, often by an order of magnitude.
:::
:::

::: practice

::: check
given: x = -0.9 | -0.6 | -0.4 | 0.2 | 0.5 | 0.9
answer: 8*x^4 - 8*x^2 + 1
tolerance: 0.5%

## $T_4(\given{x})$?

::: misses
- [any] $8x^4 - 8x^2 + 1$.
:::
:::

::: check
given: n = 2..10 int
answer: 2^(1 - n)
tolerance: 0.5%

## Best worst error for lowering $x^{\given{n}}$?

::: misses
- [any] $2^{1-n}$.
:::
:::

::: check
given: e = 0.1 | 0.2 | 0.35 | 0.5 | 0.8 | 1
answer: 10*log(1 + e^2)
unit: dB
tolerance: 0.5%

## Ripple for ε = {e}?

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