Use the formula (22.3.3) to interpolate a few functions such as
-
\(f(x) = 1/(x^2+1)\) on \([-5, 5]\)
-
\(f(x) = \tan^{-1} x\) on \([-7, 11]\)
-
\(f(x) = \cos(2x)\) on \([1, 15]\)
-
\(f(x) = \sin(x^2)\) on \([0, 5]\)
-
\(f(x) = \operatorname{sign} x\) on \([-1, 1]\)
Use \(20\) Chebyshev extreme points (or more if you prefer).
Answer.
f = @(x) 1./(x.^2+1); % or another f n = 19; % there will be n+1 = 20 points a = -5; % or another a b = 5; % or another b x = cos(linspace(0, pi, n+1)) * (b-a)/2 + (a+b)/2; % Chebyshev extreme points y = f(x); w = (-1).^(0:n); % simple formula for weights w([1 end]) = w([1 end])/2; % trapezoidal adjustment p = @(t) (y.*w*(t - x').^(-1)) ./ (w*(t - x').^(-1)); t = linspace(a-0.01, b+0.01, 1000); plot(x, y, 'k*', t, f(t), 'r', t, p(t), 'b')
The plot includes the points of interpolation as black asterisks, the original function is a red curve, and the interpolating polynomial as a blue curve. Often the blue curve follows the red one so precisely that it covers it completely.

