Lecture 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!
Lecture 4: Chapter 2: Solving nonlinear equations in 1d
Warning
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.
Notes for this lecture have not been updated since we met (stay tuned for updates)
Note
This lecture is based on Chapter 1 of [Fundamentals of Numerical Computation by Driscoll, Braun] which is avaliable online (opens in a new tab)
4.1 Recap
Last time: conditioning, stability;
Start of Chapter 2: roots (zeros), intermediate value theorem and change of sign theorem, example \(f(x) = e^x - 2x - 1\) on \([1,2]\), fixed points, Brouwer’s fixed point theorem.
Since \(f\) is continuous and we have \(f(1) = e - 3 < 0 < e^2 - 5 = f(2)\) and so we can apply change of sign theorem to \(f\) on the interval \([1,2]\): there exists \(\xi \in [1,2]\) with \(f(\xi) = 0\).
Since \(g\) is increasing we have \(1 < \log3 = g(1) \leq g(x) \leq g(2) = \log5 < 2\) for all \(x \in [1,2]\). We can therefore apply Brouwer’s fixed point theorem to conclude there exists \(\xi \in [1,2]\) such that \(g(\xi) = \xi\).
On the other hand \(h(1) = \frac{e-1}{2} < 1\) (and \(g(2) > 2\)) and so \(h\) does not map \([1,2]\) onto \([1,2]\) and we cannot apply Brouwer’s fixed point theorem to \(h\).
functionsimple_iteration(g, x1; N=100, tol=1e-10, flag=false) x =Vector{Float64}(undef, N) x[1] = x1for n ∈2:N x[n] =g(x[n-1])if !isfinite(x[n])return x[1:n], falseend# compute relative error rel_err =abs(x[n] - x[n-1]) /max(abs(x[n]), 1e-12)if rel_err < tolreturn x[1:n], trueendendif flag@warn"Fixed-point iteration did not converge within $N iterations."endreturn x, falseend
simple_iteration (generic function with 1 method)
Lemma 4.1 Suppose that \((x_{n}) \to \xi\) then \(\xi\) is a fixed point of \(g\).
Proof. Since \((x_{n+1}) \to \xi\), we have \(\xi = \lim_{n\to \infty} g(x_n) = g(\xi)\) by continuity of \(g\).
Example 4.1 Returning to Exercise 3.5 and Exercise 3.6 where \(f(x) = e^x - 2x - 1\). Recall that finding roots of \(f\) in \([1,2]\) is equivalent to finding fixed points of \(g\) and \(h\) as defined in (3.1).
Let’s see if the iterative methods \(x_{n+1} = g(x_n)\) and \(y_{n+1} = h(y_n)\) converge for \(x_1 = y_1 = 1\):
Here, we see that \(x_n \to \xi \approx 1.255 \in [1,2]\) but \(y_{n} \to \widetilde{\xi} \approx 0\) so the formulations \(g(x) = x\) and \(h(x) = x\) are equivalent, but they lead to different numerical methods.
If \(\alpha = 1\) and \(\mu \in (0,1)\), we say the convergence is linear,
If \(\alpha = 1\) but \(\mu = 0\), we say the convergence is superlinear (i.e. faster than linear),
If \(\alpha = 1\) and \(\mu = 1\), we say the convergence is sublinear (i.e slower than linear),
If \(\alpha = 2\), we say the convergence is quadratic,…
In the case where (i)\(\alpha = 1, \mu \in (0,1)\) or (ii)\(\alpha>1, \mu> 0\), we say
\(x_n \to \xi\) with order\(\alpha\),
\(\mu\) is the asymptotic error constant, and
\(\rho := - \log_{10} \mu\) is the asymptotic rate of convergence.
Define the errors \(e_n := |x_{n}-\xi|\). Then, we have \(e_{n+1} \approx \mu e_{n}^\alpha\),
For linear convergence, \(e_{N+1} \approx \mu e_N = 10^{-\rho} e_N\) and so \(\rho\) measures the number of decimal digits of accuracy gained in one iteration (for sufficiently large \(N\)).
Example 4.2 Let’s go back to our example: \(f(x) = e^x - 2x - 1\). We have defined \(g(x) = \log( 2x + 1 )\) and we are trying to solve the fixed point problem \(g(x) = x\).
(This is mathematically equivalent to \(f(x) = 0\).)
We have seen (numerically) that \(x_{n+1} = g(x_n)\) with \(x_1\) converges to \(\xi = g(\xi) \approx 1.26\). What is the order of convergence? What is the asymptotic error constant? Asymptotic rate of convergence?
(It turns out that \(\xi = g(\xi) \approx 1.256\) can be written in terms of the LambertW function.)
Since μₙ appears to converge to \(\mu \in (0,1)\), we have \(x_n \to \xi\) linearly with asymptotic error constant \(\mu\approx 0.569\) and asymptotic rate of convergence \(\rho \approx 0.245\).
We will prove that \(x_{n+1} = g(x_n)\) converges linearly and show that \(\mu = |g'(\xi)|\). Our computed value of \(\mu\) (after \(20\) iterations) is close to this theoretical value:
Code
g′ = x ->2/( 2*x +1);@showg′( ξ );
g′(ξ) = 0.569336274081677
Definition 4.2 We say \(g : [a,b] \to \mathbb R\) is a contraction if there exists an \(L \in [0,1)\) such that \(|g(x) - g(y)| \leq L|x-y|\) for all \(x\in[a,b]\).
Exercise 4.1
Suppose \(g :[a,b] \to \mathbb R\) is continuously differentiable with \(|g'(x)| \leq L < 1\) for all \(x \in [a,b]\). Show that \(g\) is a contraction with constant \(L\).
Use Taylor/mean value theorem.
By the mean value theorem, for \(x, y \in [a,b]\), there exists \(c \in [a,b]\) such that
Theorem 4.1 (Contraction Mapping Theorem (Banach fixed point theorem)) Suppose \(g:[a,b] \to[a,b]\) is a contraction. Then, there exists a unique fixed point \(\xi = g(\xi) \in [a,b]\). Moreover, the iteration \(x_{n+1} = g(x_n)\) converges to \(\xi\) for all \(x_1 \in [a,b]\)
Proof. By Brouwer’s fixed point theorem (\(g:[a,b] \to [a,b]\) is continuous), there exists a fixed point \(\xi \in [a,b]\). If \(\zeta\) is another fixed point, then there exists \(L \in (0,1)\) such that
Here, we used the fact that \(\xi, \zeta\) are fixed points of \(g\) and that \(g\) is a contraction. That is, \(0 \leq (1-L) |\xi - \zeta| \leq 0\) and so \(\xi = \zeta\). i.e. \(\xi\) is unique.
Defining \(x_{n+1} = g(x_n)\) for \(x_1 \in [a,b]\), we have
Since \(L \in (0,1)\), we have \(L^n \to 0\) as \(n \to \infty\) and thus \((x_n) \to \xi\).
Exercise 4.2
Take the simple iteration \(x_{n+1} = g(x_n)\) for some contraction \(g : [a,b] \to [a,b]\). Show that \((x_n)\) converges to the fixed point of \(g\) in \([a,b]\) at least linearly with asymptotic error constant \(\mu = |g'(\xi)|\).
Notice that, by the mean value theorem, there exists \(\eta_n\) between \(x_{n}\) and \(\xi\) for which
and the order of convergence is at least linear with asymptotic error constant \(\mu = |g'(\xi)|\).
(Recal that, if \(\mu = 0\), the order of convergence is superlinear)
Exercise 4.3
Show that \(g(x) = \log( 2x + 1)\) is a contraction on \([1,2]\) with \(L = \frac23\). Hence conclude that \(x_{n+1} := g(x_n)\) converges for all \(x_1 \in [1,2]\).
Notice that \(g'(x) = \frac{2}{2x+1}\) which is positive and decreasing on \([1,2]\). We therefore have \(\frac25 = g'(2) \leq g'(x) \leq g'(1) = \frac{2}{3}\) and so \(g\) is a contraction with \(L = \frac23\) by Exercise 4.1. Applying the contraction mapping theorem shows that \((x_n)\) converges linearly to the fixed point \(\xi \in [1,2]\) of \(g\).
TipTO-DO
Test 1: Wednesday,
Exercises throughout the notes,
(Sign-up to office hours if you like)
4.3 Extra exercises
Exercise 4.4
Assignment 2, Fall 2025, [25 pts]. Fix \(a, x_1 > 0\) and define the iteration \(x_{n+1} = \frac{1}{2}\big( x_n + \frac{a}{x_n} \big)\).
✍ Show that \(x_{n+1}\) has the same sign as \(x_n\),
✍ Suppose that \((x_n) \to \xi\). What is the value of \(\xi\)?
💻 Let \(x\) be as in question 2. Show numerically that \((x_n) \to \xi\) for a few different choices of \(a\) and \(x_1\),
💻 This iteration can be seen as a way of approximating \(\xi\). What is the correseponding order of convergence?
Note \(\frac12 x_n\) and \(\frac1{2 x_n}\) have the same sign as \(x_n\). Moreover, since \(a> 0\), \(\frac{a}{x_n}\) has the same sign as \(x_n\). As a result \(x_{n+1}\) has the same sign as \(x_n\). Since \(x_1 > 0\), we find that \(x_n > 0\) for all \(n\).
Since \(g(x) := \frac12\big( x + \frac{a}{x} \big)\) is continuous on \((0,\infty)\) and \((x_n)\to\xi\), we have \(\xi = g(\xi)\). Therefore, we have \(\frac12\xi = \frac12 \frac{a}{\xi}\) and so \(\xi^2 = a\). Since \(\xi > 0\) since \(x_n > 0\) for all \(n\), we have \(\xi = + \sqrt{a}\).
Code
A = [2, 4, 9, 81]X = [1., 2., 1e-2]for a ∈ Afor x1 ∈ X g = x -> (1/2) * (x + a/x)print( "(a, x₁) = (", a, ", ", x1, "); " ) x, boo =simple_iteration( g, x1 )if boo println( "converged to ", x[end] )elseprintln( " [didn't converge]" )endendprintln("")end
(a, x₁) = (2, 1.0); converged to 1.414213562373095
(a, x₁) = (2, 2.0); converged to 1.414213562373095
(a, x₁) = (2, 0.01); converged to 1.414213562373095
(a, x₁) = (4, 1.0); converged to 2.0
(a, x₁) = (4, 2.0); converged to 2.0
(a, x₁) = (4, 0.01); converged to 2.0
(a, x₁) = (9, 1.0); converged to 3.0
(a, x₁) = (9, 2.0); converged to 3.0
(a, x₁) = (9, 0.01); converged to 3.0
(a, x₁) = (81, 1.0); converged to 9.0
(a, x₁) = (81, 2.0); converged to 9.0
(a, x₁) = (81, 0.01); converged to 9.0
This method converges to \(\sqrt{a}\) for all \(a\) and \(x_1\) that we chose.
Here, we compute \(x_{n+1} = g(x_n)\) for \(a = 2\) and \(x_1 = 1\):
Assignment 3, Fall 2025. The Lambert W function (also called the product-log function) \(W : [0,\infty) \to [0,\infty)\) satisfies \(W(a) e^{W(a)} = a\). Define \(\Omega := W(1)\).
✍ Show that \(\Omega \in [0.56, 0.58]\).
✍ Show that \(\Omega\) is a fixed point of \(g\) and \(h\) as defined by
💻 Show numerically that \(x_{n+1} = g(x_n)\) converges and \(y_{n+1} = h(y_n)\) diverges for a few different choices of \(x_1\) and \(y_1\).
✍ Show that \(g:[\frac{1}{e}, 1]\to[\frac{1}{e},1]\) with \(|g'| < 1\),
✍ Explain why this means that the iteration \(x_{n+1} = g(x_n)\) converges for all \(x_1 \in [\frac{1}{e}, 1]\),
✍ Now fix \(x_1 \in \mathbb R\). Show that the sequence \((x_n)\) is eventually contained in \([0,1]\) and that \(g : [0,1] \to [\frac{1}{e}, 1]\). Explain why this means that \((x_n)\) converges for all \(x_1 \in \mathbb R\),
✍ What is the order of convergence of this method?
💻 Confirm this numerically.
✍ Show that \((y_n)\) doesn’t converge to \(\Omega\) for any choice of \(y_1 \not= \Omega\).