https://drlvk.github.io/nm/section-chebyshev-polynomials-interpolation.html
Chebyshev polynomials and interpolation
22.2 Chebyshev polynomials and interpolation
In Chapter 15 we studied Legendre polynomials which are orthogonal on the interval in the sense that when We also use Laguerre polynomials which are orthogonal on with the weight function meaning that when The Chebyshev polynomials are orthogonal on the interval with the weight function meaning that
As for other families of orthogonal polynomials, we have a recursive formula for Chebyshev polynomials: starting with and we can compute the rest as
The recursion is simpler than for or there is no division, so all polynomials have integer coefficients.
Example 22.2.1. Plot Chebyshev polynomials .
Example 22.2.1 indicates that Chebyshev polynomials oscillate between and on the interval The following remarkable identity confirms this observation:
Example 22.2.1. Plot Chebyshev polynomials .
Recursively find the coefficients of Chebyshev polynomials for Plot all of them on the interval
This is a straightforward modification of Example 15.4.1.
p = [1]; q = [1 0]; x = linspace(-1, 1, 1000); hold on plot(x, polyval(p, x), x, polyval(q, x)); for n = 1:5 r = 2*[q 0] - [0 0 p]; p = q; q = r; plot(x, polyval(r, x)) end hold off
for all The proof is by induction. Base of induction is for and the validity of (22.2.2) is obvious. For the inductive step, assume (22.2.2) holds for and use (22.2.1):
where the second step involves the identity
The right hand side of (22.2.2) is zero when is an odd multiple of hence Plugging we find that
and since the polynomial can have at most real roots, these are all of its roots. They are easy to visualize: draw a semi-circle with interval as diameter, divide it into equal arcs, and project the midpoint of each arc back to the interval.
The recursive formula shows that the leading coefficient of is Therefore,
where are the roots (22.2.3). It follows that the absolute value of the product is bounded by It can be proved that is as small as one can get for any choice of points on the interval This suggests that Chebyshev points should work well for polynomial interpolation, and they do. Let us re-do Example 21.2.2 with random data to illustrate this.
Example 21.2.2. Plot the Lagrange polynomial through 10 points.
Plot the Lagrange polynomial each of the following data sets:
- the points
- the points with as above, and chosen randomly from the standard normal distribution.
n = 10; x = 1:n; y = sin(x); % or y = randn(1, n); w = ones(1, n); for k = 1:n for j = 1:n if j ~= k w(k) = w(k)/(x(k)-x(j)); end end end p = @(t) (y.*w*(t - x').^(-1)) ./ (w*(t - x').^(-1)); t = linspace(min(x)-0.01, max(x)+0.01, 1000); plot(t, p(t), x, y, 'r*')
The double loop computes the weights w
which do not involve the argument of the interpolating polynomial p
. This argument is called t
because x
is already used for the data points. The interval for plotting is chosen to contain the given x-values with a small margin on both sides: this helps both visualization and evaluation, because we avoid plugging in The barycentric evaluation of the polynomial is vectorized. When t
is a scalar, t - x'
is a column vector. Taking reciprocals element-wise gives another column vector. Dot-product with w
or y.*w
implements the sums such as
How does p
accept a row vector as t
? The expression t - x'
is the difference of a row vector and a column vector; in Matlab this creates a matrix where entry is Subsequent operations proceed as above, and the result is a row vector of values
Example 22.2.3. An interpolating polynomial using Chebyshev points.
Running the code Example 22.2.3 several times, we see that the interpolating polynomial behaves reasonably, without unnatural oscillations that come from interpolating at equally spaced points.
Example 22.2.3. An interpolating polynomial using Chebyshev points.
Let be the roots of Choose randomly from the standard normal distribution, and draw the interpolating polynomial through the points
The only change to Example 21.2.2 is replacing the x-coordinates.
n = 10; x = cos((2*(1:n)-1)*pi/(2*n)); y = randn(1, n); w = ones(1, n); for k = 1:n for j = 1:n if j ~= k w(k) = w(k)/(x(k)-x(j)); end end end p = @(t) (y.*w*(t - x').^(-1)) ./ (w*(t - x').^(-1)); t = linspace(min(x)-0.01, max(x)+0.01, 1000); plot(t, p(t), x, y, 'r*')
No hay comentarios:
Publicar un comentario