Accuracy of Chebyshev coefficients via aliasing
1. One dimension
As shown in [1, Thm. 4.2], the Chebyshev coefficients of the degree polynomial interpolant
Now, smooth functions have rapidly decaying Chebyshev coefficients, and in particular, if is analytic, its Chebyshev coefficients decay geometrically at the rate for some constant . This geometric decay, combined with the aliasing formulae above, tells us that the Chebyshev coefficients of the interpolant have errors of predictably varying magnitude, for the dominant term in the error is for , for , and for the rest. From this we expect that a Chebyshev interpolant for an analytic would have high accuracy in and very high accuracy in , relative to the other .
Here is an illustration. For an analytic function , we find its Chebyshev expansion coefficients. We then compute a low-degree interpolant and examine the accuracy of its Chebyshev coefficients.
clear, close all
LW = 'linewidth'; MS = 'markersize'; FS = 'fontsize';
CO = 'color'; green = [0 .7 0];
lw = 2; ms = 10; fs = 16;
fori = @(x) log(sin(10*x)+2);
f = chebfun(fori);
p = chebfun(fori,round(length(f)/3));
pc = p.coeffs;
fc = f.coeffs;
plotcoeffs(f,'.',CO,green,LW,lw,MS,ms), hold on
plotcoeffs(p,'.b',LW,lw,MS,ms)
plot(0:length(pc)-1,abs(pc-fc(1:length(pc)))+eps,'.r',LW,lw,MS,ms)
h_legend = legend('f','p','f-p');
set(h_legend,FS,fs)
The green and blue dots show the absolute values of the Chebyshev coefficients for and the interpolant . Our focus here is on the red dots, showing the error in Chebyshev coefficients. Two observations can be made: (i) the error grows geometrically with the degree until degree , and (ii) (note the rightmost red dot) at the end the error is much much smaller. These effects clearly reflect the aliasing formulae given above.
Let us note the connection between the aliasing in and Gauss quadrature. The exact integral of is equal to the degree 0 coefficient in its Legendre expansion , where is the Legendre polynomial of degree . Gauss quadrature approximates this by , the degree 0 coefficient of the degree polynomial interpolant. The error in Gauss quadrature, can accordingly be interpreted as the result of aliasing the term and terms of higher degree. See section 8 of [2] for more details.
The extremely high accuracy of the coefficient is peculiar to the Chebyshev interpolation process, and this coefficient is exact if is a polynomial of degree up to . Although we are unaware of a practical application of this fact, it does suggest that if only the Chebyshev coefficient is of interest, then a -point Chebyshev interpolation could suffice, even if the corresponding interpolant is rather poor.
Let's repeat the computation with a non-analytic function.
fori = @(x)abs((x - 0.5).^3); % twice differentiable but not analytic
f = chebfun(fori);
p = chebfun(fori,round(length(f)/6));
pc = p.coeffs;
fc = f.coeffs;
clf
plotcoeffs(f,'.',CO,green,LW,lw,MS,ms), hold on
plotcoeffs(p,'.b',LW,lw,MS,ms)
plot(0:length(pc)-1,abs(pc-fc(1:length(pc)))+eps,'.r',LW,lw,MS,ms)
xlim([0 length(f)/2])
h_legend = legend('f','p','f-p');
set(h_legend,FS,fs,'Location','Best')
For non-analytic functions the difference in accuracy is less prominent, because the Chebyshev coefficients decay more slowly. The red plot is still roughly a 'mirrored' version of the green one, and the first and coefficients still have higher accuracy than most of the rest. Again, these are all consequences of the aliasing formula.
2. Two dimensions
Let's try an analogous experiment in Chebfun2. As before we start with a smooth bivariate function, form its chebfun2, and construct a low-degree interpolant (degree 5 in each direction). Then we examine the accuracy in the coefficients, which we show in matrix form.
p = chebfun2(@(x,y)sin(x+y)+cos(x-y));
pc = chebcoeffs2(p);
[x,y] = chebpts2(6); % construct chebfun2 of degree [5 5] from values on 6x6 grid
pt = chebfun2(p(x,y));
ptc = chebcoeffs2(pt);
format shortE
ptc-pc(1:size(ptc,1),1:size(ptc,2))ans =
-8.0518e-10 7.5521e-09 1.4432e-07 -2.2991e-06 -3.2044e-05 -2.6284e-13
7.5521e-09 1.8437e-08 1.6345e-07 -2.6448e-06 -3.6856e-05 5.2322e-12
1.4432e-07 1.6345e-07 -8.6613e-08 6.8312e-07 9.6245e-06 9.4133e-11
-2.2991e-06 -2.6448e-06 6.8312e-07 2.3513e-07 1.6237e-06 -1.5009e-09
-3.2044e-05 -3.6856e-05 9.6245e-06 1.6237e-06 -4.1310e-07 -2.0918e-08
-2.6281e-13 5.2322e-12 9.4133e-11 -1.5009e-09 -2.0918e-08 -2.5887e-20The entry of this matrix is the error in the coefficient for . Observations similar to the 1-d case can be made: looking horizontally or vertically, the low-degree coefficients are more accurate than the higher ones, except at the very ends, where the accuracy is much better. Note the exceptional accuracy at the lower-right corner.
Reference
[1] L. N. Trefethen, Approximation Theory and Approximation Practice, SIAM, 2013.
[2] L. N. Trefethen and J. A. C, Weideman. The exponentially convergent trapezoidal rule, SIAM Review (2014) 56 (3), 385-458.