Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

8
Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Transcript of Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Page 1: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Page 2: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

“rjlfdm”2007/6/1page 266✐

✐✐

✐✐

✐✐

266 Appendix B. Polynomial Interpolation and Orthogonal Polynomials

−1 −0.5 0 0.5 1−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

Figure B.1. The Chebyshev polynomial T7.x/ of degree 7.

−1.5−1

−0.50

0.51

1.5

−1

0

1

−2

−1

0

1

2

−1.5 −1 −0.5 0 0.5 1 1.5−2

−1.5

−1

−0.5

0

0.5

1

1.5

2

Figure B.2. The Chebyshev polynomial viewed as a function Cm.!/ on the unitdisk ei! and when projected on the x-axis, i.e., as a function of x D cos.!/. Shown form D 15.

Property 3. Consider the function

Cm.!/ D Re.eim! / D cos.m!/ (B.28)

for 0 ! ! ! " . We can view this as a function defined on the upper half of the unit circle inthe complex plane. If we identify x D cos.!/ or ! D arccos x, then this reduces to (B.26),so we can view the Chebyshev polynomial on the interval Œ"1; 1# as being the projection ofthe function (B.28) onto the real axis, as illustrated in Figure B.2. This property is usefulin relating polynomial interpolation at Chebyshev points to trigonometric interpolation atequally spaced points on the unit circle and allows the use of the Fast Fourier Transform(FFT) algorithm to efficiently implement Chebyshev spectral methods. Orthogonality ofthe Chebyshev polynomials with respect to the weight function (B.22) also can be easilyinterpreted in terms of orthogonality of the trigonometric functions cos.m!/ and cos.n!/.

Page 3: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press
Page 4: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Review of DFT – Chebyshev relationships

Chebyshev Fourier x = cos θ, 1 ≥ x ≥ -1 θ, 0 ≤ θ ≤ π (even extn to 0 ≤ θ ≤ 2π) Tn(x) cos nθ Chebyshev points xj = cos θj, j=0,…,N θj = jπ/N, j=0,…, 2N-1

QN(x) = q̂nn=0

N

∑ Tn (x) qN(θ) = q̂nn=0

N

∑ cosnθ

dQN(x)/dx; can take any value at x = -1,1 -(1/sin θ)dqN/dθ; dqN/dθ = 0 at θ = 0, π Polynomial interpolation/differentiation Fourier interpolation/differentiation

Page 5: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

This algorithm can be viewed as an N+1 x N+1 derivative matrix DN operating on the vector of function values Qj at the Chebyshev points to give the derivative at those points to spectral accuracy. With some work, the elements of DN can be explicitly computed (Dcheb.m). Multiplication by DN is less computationally efficient than using the DFT, but it is conceptually easy, fast enough to use for large enough N to achieve high accuracy for smooth problems, and flexible for setting up the solution of two-point BVPs.

Another way to compute the derivative matrix is by remembering that the Chebyshev interpolating function is the unique N’th order polynomial that passes through the given values Qj at the vector x of the Chebyshev points, so the form of the p’th derivative at each of those points xj can be computed using fdcoeffF(p,x(i),x). This approach is used in RJL’s example BVP_spectral.m

Page 6: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Output of p11.m, showing accuracy of Chebyshev method for differentiation of a smooth function

Output of p13.m, showing Chebyshev solution (N =16) of ′′u = e4x, u(−1) = u(1) = 0.

−1 −0.5 0 0.5 1−3

−2

−1

0

1

2u(x), N=10

−1 −0.5 0 0.5 1−0.03

−0.02

−0.01

0

0.01

0.02 error in u’(x), N=10

−1 −0.5 0 0.5 1−3

−2

−1

0

1

2u(x), N=20

−1 −0.5 0 0.5 1−5

0

5

10x 10−10 error in u’(x), N=20

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−2.5

−2

−1.5

−1

−0.5

0max err = 1.261e−10

Page 7: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press
Page 8: Reference: Trefethen, N: Spectral Methods in Matlab, SIAM Press

Output of p13.m, showing Chebyshev solution (N =16) of ′′u = e4x, ′u (−1) = u(1) = 0.

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−4

−3.5

−3

−2.5

−2

−1.5

−1

−0.5

0max err = 3.0965e−09