Chebyshev Approximation Polynomial

← Numerical Methods

Source inspiration: (Mathew 2000-2019).

Description

A Chebyshev approximation polynomial approximates a function \(f\) on an interval \([a,b]\) by the polynomial \(P_{n-1}\) of degree at most \(n-1\) that interpolates \(f\) at \(n\) Chebyshev nodes, \(P_{n-1}(x_k)=f(x_k)\). Chebyshev-node interpolation uses clustered nodes near interval endpoints to reduce oscillation compared with equally spaced interpolation at the same degree. This is why Chebyshev-based polynomial approximation is a standard remedy for Runge-type endpoint blow-up.

On an interval \([a,b]\), the \(n\) Chebyshev nodes are the roots \(t_k=\cos\bigl((2k-1)\pi/(2n)\bigr)\) of the Chebyshev polynomial \(T_n(t)=\cos(n\arccos t)\), mapped from \([-1,1]\) to \([a,b]\):

\[ x_k = \frac{a+b}{2} + \frac{b-a}{2}\cos\!\left(\frac{(2k-1)\pi}{2n}\right),\qquad k=1,\ldots,n. \]

Mathews writes the interpolant as a sum of Chebyshev polynomials in \(t\), where \(x=\frac{a+b}{2}+\frac{b-a}{2}t\), with coefficients computed from the node values:

\[ P_{n-1}(x)=\sum_{j=0}^{n-1}c_j\,T_j(t),\qquad c_0=\frac1n\sum_{k=1}^{n}f(x_k),\qquad c_j=\frac2n\sum_{k=1}^{n}f(x_k)\cos\!\left(\frac{j(2k-1)\pi}{2n}\right). \]

The animations evaluate the same polynomial in barycentric Lagrange form.

Building \(P_{n-1}\) needs only the values \(f(x_k)\). The error bound needs more: in general, Mathews’ Lagrange–Chebyshev theorem states that if \(f\in C^{n}[a,b]\), then for every \(x\in[a,b]\)

\[ |f(x)-P_{n-1}(x)| \le \frac{2\,(b-a)^{n}}{4^{n}\,n!}\max_{a\le x\le b}\bigl|f^{(n)}(x)\bigr|. \]

Its factor \(2(b-a)^n/4^n\) is the largest value of \(\bigl|\prod_{k=1}^{n}(x-x_k)\bigr|\) on \([a,b]\), and no other choice of \(n\) nodes in \([a,b]\) makes that largest value smaller; for 16 nodes on \([-1,1]\), equally spaced nodes make it 44 times larger. For \(e^x\) on \([-2,3]\) (Case 15), the largest error with 16 nodes is \(7.1\times10^{-12}\), within the bound’s \(6.8\times10^{-11}\). For \(1/(1+10x^2)\) on \([-1,1]\) (Case 08), the error falls by a factor of about 3.47 for every four nodes added, from \(1.4\times10^{-2}\) at 16 nodes to \(9.5\times10^{-5}\) at 32, while 16 equally spaced nodes leave an error of 0.48. There the bound misleads: it is about 3050 at 16 nodes and grows with \(n\), so it says nothing although the error shrinks.

Two failures matter in the cases below. The bound covers only \([a,b]\): beyond it the interpolant is extrapolation and leaves \(f\) quickly, as in Case 04, where 16 nodes on \([0,2]\) give \(P_{15}(3)\approx 5.0\times10^{4}\) against \(\sqrt3\approx1.73\). And when \(f\) has an infinite derivative at an endpoint, the theorem does not apply and convergence is slow: for \(\sqrt{x}\) on \([0,2]\) (Case 04) and \(\arcsin x\) on \([-1,1]\) (Case 19), the largest error sits at an endpoint and only halves when the number of nodes doubles from 8 to 16.

The same interpolation with equally spaced nodes is on the Lagrange and Newton pages, and Newton’s Case 08 shows the Runge oscillation of \(1/(1+10x^2)\); Rational Approximation also uses Chebyshev nodes, and Least-Squares Polynomials and Legendre Polynomials fit by least squares instead.

Animations

Each animation steps through 2, 3, 4, 5, 6, 8, 10, 12, 14 and 16 Chebyshev nodes (case 08 continues to 20, 24, 28 and 32) for a fixed function and approximation interval. With \(n\) nodes the interpolant has degree at most \(n-1\); for an even function on a symmetric interval and even \(n\) it is at most \(n-2\). Green dashed vertical lines mark the ends of the approximation interval. Outside them the blue curve is extrapolation and can leave the frame; with 8 or fewer nodes its overshoot can also leave the frame inside the interval (cases 08, 12, 13, 22, 23 and 27).

Julia source for all cases

Case 01

Case 01 caption: f(x)=1/(1-x), interval [-1.6, 0.9].

Case 02

Case 02 caption: f(x)=1/(1+x), interval [-0.9, 1.5].

Case 03

Case 03 caption: f(x)=1/(1-x)^2, interval [-1.5, 0.8].

Case 04

Case 04 caption: f(x)=sqrt(x), interval [0, 2].

Case 05

Case 05 caption: f(x)=sqrt(x), interval [0, 8].

Case 06

Case 06 caption: f(x)=sqrt(x), interval [0, 10].

Case 07

Case 07 caption: f(x)=1/sqrt(1-x), interval [-1.5, 0.95].

Case 08

Case 08 caption: f(x)=1/(1+10x^2), interval [-1, 1], up to 32 nodes.

Case 09

Case 09 caption: f(x)=log(x), interval [0.02, 2].

Case 10

Case 10 caption: f(x)=log(x), interval [0.02, 4].

Case 11

Case 11 caption: f(x)=log(1+x), interval [-0.98, 1].

Case 12

Case 12 caption: f(x)=sin(x), interval [-3pi, 3pi].

Case 13

Case 13 caption: f(x)=cos(x), interval [-3pi, 3pi].

Case 14

Case 14 caption: f(x)=tan(x), approximation interval [-1.45, 1.45] inside singularities.

Case 15

Case 15 caption: f(x)=exp(x), interval [-2, 3].

Case 16

Case 16 caption: f(x)=cos(x)*exp(-x), interval [-2, 4].

Case 17

Case 17 caption: f(x)=cosh(x), interval [-4, 4].

Case 18

Case 18 caption: f(x)=atan(x), interval [-2.2, 2.2].

Case 19

Case 19 caption: f(x)=asin(x), interval [-1, 1].

Case 20

Case 20 caption: f(x)=besselj(0,x), interval [-10.2, 10.2].

Case 21

Case 21 caption: f(x)=besselj(1,x), interval [-10.2, 10.2].

Case 22

Case 22 caption: f(x)=normal_pdf(x), interval [-3, 3].

Case 23

Case 23 caption: f(x)=normal_cdf(x), interval [-3, 3].

Case 24

Case 24 caption: f(x)=gamma(x), interval [0.05, 2].

Case 25

Case 25 caption: f(x)=gamma(x), interval [0.05, 4].

Case 26

Case 26 caption: f(x)=gamma(x), interval [0.05, 5].

Case 27

Case 27 caption: f(x)=bessely(0,x), interval [0.5, 20].

Case 28

Case 28 caption: f(x)=bessely(0,x), interval [0.5, 10].

Case 29

Case 29 caption: f(x)=bessely(0,x), interval [0.5, 4].

References

Mathew, John H. 2000-2019. Numerical Analysis - Numerical Methods Modules. https://web.archive.org/web/20190808102217/http://mathfaculty.fullerton.edu/mathews/n2003/NumericalUndergradMod.html.