Lecture 16: QR factorisation onlineLecture 15: Linear least squares onlineAssignment 5 onlineLecture 14 (Pivoted LU decomposition) onlineLecture 13 (Linear systems of equations) onlineLecture 12 (Gaussian quadrature) onlineA4 onlineTypos in L1-11 fixed, Quiz 3 in the exercise bank, solutions published, study guide availableLecture 10/11: Newton-Cotes quadratureLecture 9: Hermite interpolation availableAssignment 3 availableLecture 8 onlineLecture 7 onlineSchedule now available in "Admin"Problem class exercises now onlineLecture 6 onlineQuiz 1 solutions onlineLectures 2-3 exercises have solutions!Lecture 1 exercises have solutions!
These lecture notes are mainly a record of what we discussed in class. They should not be used as a replacement for attending lectures or reading books. Please let me know if you find any errors or have any questions about the material.
TipHypothesis
You can use the Hypothesis commenting system available on the right side panel (you can login with your U/Google account). This allows you annotate the notes (private) and leave comments or reply to other people’s comments (public).
Note
I encourage you to download the lecture notes and play around with the Julia code.
Lagrange interpolation problem (find \(p\in \mathcal P_n\) such that \(p(x_j) = f(x_j) =: f_j\) for all \(x_j \in X = \{x_0 < \cdots < x_n\}\))
Theorem: there exists unique polynomial interpolation \(I_Xf \in \mathcal P_n\) solving the Lagrange interpolation problem,
Theorem: “Taylor-like” error estimate involving the node polynomial\(\ell_X(x) := (x-x_0)(x-x_1)\cdots (x- x_n)\): there exists \(\xi \in [a,b]\) such that
over all choices of \(X = \{x_0,\dots,x_n\}\). Equivalently, we are minimising \(\| p \|_{L^\infty}\) over all monic polynomials \(p\) of degree \(n+1\): that is, over all \(p\) such that \(p(x) = x^{n+1} + q(x)\) with \(q\in \mathcal P_n\). We will show that scaled Chebyshev polynomials (of the first kind) solve this (so-called Chebyshev) problem.
7.3 A Very Brief Introduction to Chebyshev Polynomials
Definition 7.1 For \(x \in [-1,1]\) there exists \(\theta \in [0,\pi]\) such that \(x = \cos\theta\). We can therefore define \(T_n\) on \([-1,1]\) by the condition that
We will show that \(T_n\) is a polynomial of degree \(n\). We define \(X_{\mathrm{I}}\) to be the set of \(n+1\) zeros of \(T_{n+1}\) and \(X_{\mathrm{II}}\) to be the set of \(n+1\) extreme points of \(T_n\). We will show that
\(X_{\mathrm{I}}\) and \(X_{\mathrm{II}}\) are the Chebyshev nodes of the first and second kind, respectively.
Exercise 7.1
Show that \(T_0(x) = 1\) and \(T_1(x) = x\).
For \(x\in[-1,1]\) write \(\cos \theta = x\) for some \(\theta\in[0,\pi]\). Then \[
\begin{align}
T_0(x) &= \cos(0\cdot\theta) = 1, \nonumber\\
T_1(x) &= \cos\theta = x.
\end{align}
\]
Exercise 7.2
Use \(\cos(x+y) = \cos x \cos y - \sin x \sin y\) to show that
\(T_{n+1}(x) = 2x T_{n}(x) - T_{n-1}(x)\) for \(n =1,2,\dots\),
Hence show that \(T_n\) is a polynomial of degree \(n\),
Show that the coefficent of \(x^n\) in \(T_n\) is \(2^{n-1}\) for \(n \geq 1\).
(i) Let \(x=\cos\theta\) with \(\theta\in[0,\pi]\). Using the hint, we have \[
\begin{aligned}
T_{n+1}(x) &= \cos(n\theta+\theta) \nonumber\\
&= \cos n\theta\cos\theta - \sin n\theta\sin\theta,\\
T_{n-1}(x) &= \cos(n\theta-\theta) \nonumber\\
&= \cos n\theta\cos\theta + \sin n\theta\sin\theta .
\end{aligned}
\] Adding, \(T_{n+1}(x) + T_{n-1}(x) = 2\cos\theta\cos n\theta = 2x\,T_n(x)\), which is the recursion. It holds for every \(x\in[-1,1]\) and \(n\ge1\).
(ii) and (iii) If \(T_{n-1}, T_n\) are polynomials of degree \(n-1,n\) (resp.) and \(T_n\) has leading coefficient \(2^{n-1}\) then \(T_{n+1} = 2x T_n - T_{n-1}\) is a polynomial of degree \(n+1\) with leading coefficient \(2^n\). This combined with the fact that \(T_0, T_1\) are polynomials of degree \(0\) and \(1\) and the leading coefficient of \(T_1\) is \(1 = 2^{1-1}\) we can conclude (by induction).
Exercise 7.3
Show that
\(\|T_n\|_{L^\infty([-1,1])} = 1\),
\(T_{n}\big( \cos\tfrac{j\pi}{n} \big) = (-1)^j\) for \(j = 0,\dots,n\) (extreme points; Chebyshev nodes of the second kind),
\(T_{n+1} = 0\) on \(\big\{ \cos \frac{(2j+1)\pi}{2(n+1)} \big\}_{j=0}^{n}\) (zeros; Chebyshev nodes of the first kind).
(i) We can write \(x\in[-1,1]\) as \(\cos\theta\) for some \(\theta\in[0,\pi]\), so \(|T_n(x)| = |\cos n\theta|\le1\). Also \(T_n(1) = \cos 0 = 1\). Hence \(\max_{x\in [-1,1]}|T_n(x)| = 1\).
(ii) Let \(n\ge1\). For \(j=0,\dots,n\), \(\theta_j = j\pi/n\in[0,\pi]\), so \(T_n(\cos\theta_j) = \cos(n\theta_j) = \cos(j\pi) = (-1)^j\). Since \(\cos\) is strictly decreasing on \([0,\pi]\), these are \(n+1\) distinct points, and by (i) they are points where \(|T_n|\) attains its maximum \(1\). They are the only such points in \([-1,1]\), because \(|\cos n\theta|=1\) with \(\theta\in[0,\pi]\) forces \(n\theta\in\{0,\pi,\dots,n\pi\}\).
(iii) For \(j=0,\dots,n\), \(\theta_j = \frac{(2j+1)\pi}{2(n+1)}\in(0,\pi)\) and \[
\begin{align}
T_{n+1}(\cos\theta_j) &= \cos\big((n+1)\theta_j\big) \nonumber\\
%
&= \cos\Big(\frac{(2j+1)\pi}{2}\Big) = 0 .
\end{align}
\] Again these \(n+1\) points are distinct (as \(\cos\) is strictly decreasing on \([0,\pi]\)). Since \(T_{n+1}\) has degree \(n+1\) (Exercise 7.2), it has at most \(n+1\) roots, so these are all the zeros of \(T_{n+1}\). Hence \[
\begin{align}
T_{n+1}(x) &= 2^n\prod_{j=0}^n\Big(x-\cos\tfrac{(2j+1)\pi}{2(n+1)}\Big), \nonumber\\
%
\text{i.e.}\qquad \ell_{X_{\rm I}} &= 2^{-n}T_{n+1} = t_{n+1}.
\end{align}
\]
Proof. Firstly, \(T_0(\cos\theta) =\cos 0 = 1\) and so \(T_0 = 1\). Moreover, \(T_{1}(\cos \theta) = \cos\theta\) and so \(T_1 = x\).
Using the fact that \(\cos(x+y) = \cos x \cos y - \sin x \sin y\) (which follows from e.g. \(e^{i(x+y)} = e^{ix} e^{iy}\)), we find that
The sum of these equations is therefore \(T_{n+1}(\cos\theta) + T_{n-1}(\cos\theta) = 2 \cos \theta \cos n\theta = 2 \cos(\theta) T_n(\cos\theta)\) and thus the recursion relation follows.
One can therefore show inductively that \(T_n\) is a polynomial of degree \(n\). Using the recursion, the coeficient of \(x^{n+1}\) in \(T_{n+1}\) is \(2\) times the coefficient of \(x^n\) in \(T_{n}\). You can therefore argue inductively that the coeficient of \(x^n\) in \(T_{n}\) is \(2^{n-1}\).
We have \(|T_n(\cos\theta)| = |\cos n\theta| \leq 1\) and this maximum is achieved when \(n\theta = j\pi\) for some \(j \in \mathbb Z\). Restricting this to \(\theta = \frac{j\pi}{n} \in [0,\pi]\) gives \(j = 0,\dots,n\). At these values, we have \(T_n( \cos\tfrac{j\pi}{n} ) = \cos j\pi = (-1)^j\).
\(T_{n+1}\) is a polynomial of degree \(n+1\) and thus has at most \(n+1\) zeros in the interval \([-1,1]\). We have \(T_{n+1}(\cos\theta) = \cos (n+1)\theta = 0\) when \((n+1)\theta = \frac{\pi}{2} + j \pi\) for \(j \in \mathbb Z\) such that \(\theta = \frac{ (2j+1) \pi }{ 2(n+1) } \in [0,\pi]\). That is, for \(j = 0,\dots,n\).
Here, we plot the first \(5\) Chebyshev polynomials on \([-1,1]\) together with \((x, T_n(x))\) for \(x \in X_{\mathrm{II}}\) with \(n=5\)
We define the monic (with leading coefficient equal to \(1\)) Chebyshev polynomials as \(t_0(x) = 1\) and \(t_n(x) := 2^{1-n} T_n(x)\) for \(n \geq 1\). We are ready for the main result of this lecture:
Theorem 7.1 The monic Chebyshev polynomials solve the Chebyshev problem (on \([-1,1]\)). That is,
By the change of sign theorem, there exists \(x_1,\dots,x_{n+1}\) such that \(z_j \leq x_{j+1} \leq z_{j+1}\) and \(r(x_j) = 0\). As a result, \(r\) is a polynomial of degree at most \(n\) with \(n+1\) zeros and thus \(r = 0\) and \(p = t_{n+1}\).
We have therefore shown that, choosing \(X =X_{\mathrm{I}}= \{ \text{zeros of }t_{n+1} \}\) minimises the node polynomial in the following sense
It turns out that \(\ell_{X_{\mathrm{II}}}(x) = 2^{-n} \big( T_{n+1}(x) - T_{n-1}(x) \big)\) and so \(\|\ell_{X_{\mathrm{II}}}\|_{L^\infty([-1,1])} \leq 2^{1-n}\) (here, we used \(|T_{n}|\leq 1\)) and so, in practice, one expects the same approximation rates when using \(X = X_{\mathrm{II}} = \{\text{extreme points of } T_n \}\).
7.4 Next time….
Barycentric formula for Chebyshev interpolation
Newton form & divided differences
TipTO-DO
Wednesday morning: Quiz 2
Exercises throughout the notes,
(Sign-up to office hours if you like)
7.5 Extra exercises
Exercise 7.4
Recall that \(T_{n+1}(x) = 2x T_n(x) - T_{n-1}(x)\) for \(n=1,2,...\).
Use the recursion to write down \(T_2\), \(T_3\) and \(T_4\) in the monomial basis.
Write down the Chebyshev nodes of the first kind \(X_{\mathrm I}\) for \(n = 2\) (i.e. the zeros of \(T_3\)) and check directly that \(\ell_{X_{\mathrm I}}(x) = t_3(x) = x^3 - \tfrac34 x\).
Find \(\| \ell_{X_{\mathrm I}} \|_{L^\infty([-1,1])}\) for \(n=2\) by calculus, and compare with the equispaced nodes \(\{-1, 0, 1\}\).
3. Let \(g(x) = x^3-\frac34x\). Then \(g'(x) = 3x^2-\frac34 = 0 \iff x=\pm\frac12\). Comparing values at the critical points and endpoints: \[
\begin{align}
g\big(\tfrac12\big) &= \tfrac18-\tfrac38 = -\tfrac14,\nonumber\\
g\big(-\tfrac12\big) &= \tfrac14,\nonumber\\
g(1) &= \tfrac14,\nonumber\\
g(-1) &= -\tfrac14 .
\end{align}
\] So \(\|\ell_{X_{\rm I}}\|_{L^\infty} = \frac14 = 2^{-2}\), attained at the four points \(\pm\frac12,\pm1\) with alternating signs. These are \(\cos\frac{j\pi}{3}\), \(j=0,\dots,3\), the extreme points of \(T_3\).
For the equispaced nodes, \(\ell(x) = x^3-x\) has critical points \(x=\pm\frac1{\sqrt3}\) and vanishes at \(\pm1\), so \[
\begin{align}
\|\ell_{\{-1,0,1\}}\|_{L^\infty} &= \frac1{\sqrt3}\Big(1-\frac13\Big) \nonumber\\
%
&= \frac{2}{3\sqrt3}\approx0.385,
\end{align}
\] about \(1.54\) times larger than \(\frac14\). Because the factor \(\frac{\max|f^{(3)}|}{3!}\) in the error bound is the same for both node sets, the Chebyshev nodes give an error bound about \(35\%\) smaller.
Exercise 7.5
In the notes, we claimed that \(\ell_{X_{\mathrm{II}}}(x) = 2^{-n} \big( T_{n+1}(x) - T_{n-1}(x) \big)\) for \(n \geq 1\). Since \(\|T_n\|_{L^\infty} = 1\), this gives \(\| \ell_{X_{\rm II}} \|_{L^\infty} \leq 2^{1-n}\).
Prove the claim as follows:
Show that \(T_{n+1}(\cos\theta) - T_{n-1}(\cos\theta) = -2 \sin\theta \sin n\theta\).
Deduce that \(T_{n+1} - T_{n-1}\) vanishes on \(X_{\mathrm{II}} = \big\{ \cos\frac{j\pi}{n} \big\}_{j=0}^n\).
Show that \(2^{-n} \big( T_{n+1} - T_{n-1} \big)\) is monic of degree \(n+1\), and conclude.
1. From the two addition-formula identities in Exercise 7.2, subtracting instead of adding: \[
\begin{align}
T_{n+1}(\cos\theta) - T_{n-1}(\cos\theta) &= \big(\cos n\theta\cos\theta - \sin n\theta\sin\theta\big) - \big(\cos n\theta\cos\theta + \sin n\theta\sin\theta\big) \nonumber\\
&= -2\sin\theta\,\sin n\theta .
\end{align}
\]
2. At \(x_j = \cos\theta_j\) with \(\theta_j = j\pi/n\), \(j=0,\dots,n\), we have \(\sin(n\theta_j) = \sin(j\pi) = 0\), so \((T_{n+1}-T_{n-1})(x_j) = 0\). (At the endpoints \(j=0,n\) the factor \(\sin\theta_j\) vanishes too.) The \(n+1\) points \(x_j\) are distinct, since \(\cos\) is strictly decreasing on \([0,\pi]\).
3. By Exercise 7.2, \(T_{n+1}\) has degree \(n+1\) and leading coefficient \(2^n\), and \(T_{n-1}\) has degree \(n-1<n+1\). So \(P := 2^{-n}(T_{n+1}-T_{n-1})\) is a monic polynomial of degree \(n+1\). Both \(P\) and \(\ell_{X_{\rm II}}\) are monic of degree \(n+1\), so \(P-\ell_{X_{\rm II}}\in\mathcal P_n\). This difference vanishes at the \(n+1\) distinct points of \(X_{\rm II}\), so it is the zero polynomial (a nonzero polynomial of degree \(\le n\) has at most \(n\) roots). Hence \[
\ell_{X_{\rm II}} = 2^{-n}\big(T_{n+1}-T_{n-1}\big).
\] Finally, \(\|\ell_{X_{\rm II}}\|_{L^\infty} \le 2^{-n}\big(\|T_{n+1}\|_{L^\infty}+\|T_{n-1}\|_{L^\infty}\big) = 2^{1-n}\).
Exercise 7.6
Suppose we want to interpolate on a general interval \([a,b]\) rather than \([-1,1]\).
Let \(\phi(t) = \frac{a+b}{2} + \frac{b-a}{2} t\), so that \(\phi\) maps \([-1,1]\) onto \([a,b]\). If \(Y = \{y_0,\dots,y_n\} \subset [-1,1]\) and \(X = \phi(Y) = \{\phi(y_0), \dots, \phi(y_n)\}\), show that \[
\ell_X\big(\phi(t)\big) = \left( \frac{b-a}{2} \right)^{n+1} \ell_Y(t).
\]
Deduce that, if \(X\) is the image of \(X_{\mathrm I}\) under \(\phi\), then \(\max_{x \in [a,b]} |\ell_X(x)| = 2 \left( \frac{b-a}{4} \right)^{n+1}\).
Let \(f(x) = \sin x\) on \([0, \pi]\), interpolated at the image of \(X_{\mathrm I}\). Write down an error bound and find the smallest \(n\) that guarantees \(\max_{x\in[0,\pi]} |f(x) - I_Xf(x)| \leq 10^{-6}\).
2. By Exercise 7.3, \(\ell_{X_{\rm I}} = t_{n+1} = 2^{-n}T_{n+1}\), so \(\max_{t\in[-1,1]}|\ell_{X_{\rm I}}(t)| = 2^{-n}\). Since \(\phi\) is a bijection from \([-1,1]\) onto \([a,b]\), every \(x\in[a,b]\) is \(\phi(t)\) for exactly one \(t\in[-1,1]\), so by Part 1 \[
\begin{align}
\max_{x\in[a,b]}|\ell_X(x)| &= \left(\frac{b-a}{2}\right)^{n+1}\max_{t\in[-1,1]}|\ell_{X_{\rm I}}(t)| \nonumber\\
%
&= \frac{(b-a)^{n+1}}{2^{n+1}2^{n}} \nonumber\\
&= 2\left(\frac{b-a}{4}\right)^{n+1}.
\end{align}
\]
3. All derivatives of \(\sin\) are \(\pm\sin\) or \(\pm\cos\), so \(|f^{(n+1)}|\le1\). With \(b-a=\pi\), the Lagrange error formula and Part 2 give \[
\max_{x\in[0,\pi]}|\sin x - I_Xf(x)| \;\le\; \frac{1}{(n+1)!}\cdot 2\left(\frac{\pi}{4}\right)^{n+1} =: B_n .
\] Evaluating: \[
\begin{align}
B_6 &\approx 7.3\times10^{-5},\nonumber\\
B_7 &\approx 7.2\times10^{-6},\nonumber\\
B_8 &\approx 6.3\times10^{-7},
\end{align}
\] and \(B_n\) decreases in \(n\). So the smallest \(n\) with \(B_n\le10^{-6}\) is \(n=8\), (that is, \(9\) interpolation nodes).