Problem sheet 3

Please submit the question marked * to your tutor.

E3.1*

In this exercise, you will write a function to compute the error of the piecewise linear interpolant. Your function takes as input arguments $a,b \in \mathbb{R}$ with $a<b$, a positive integer $J$, and a function $f$.

Your function should then calculate $h = (b-a)/J$, the points $y_j = a + jh$, $j = 0,\ldots , J$, and evaluate $$ e_h := \max_{j = 1, \ldots , J}|f(z_j) - p_{1,J}(z_j)|. $$ where $p_{1,J}$ is the piecewise-linear interpolant of $f$ with respect to the mesh $y_j$, and $z_j$ is the midpoint of the interval $[y_{j-1},y_j]$.

For $a=0$, $b=1$ and each of $f(x) = \exp (x)$ and $f(x) = \sin x$, draw up a table of $e_h$ against $h$ for $h = 1/8,1/16,1/32,\ldots$.

Experimentally assess the rate of convergence as $h \to 0$. Explain the results (theoretically).

Repeat for $f(x) = | x -1/2|^{1/4}$ and $[a,b] = [0,1]$. Explain the results as well as you can also in this case.

E3.2

Let $[a,b] = [0,1]$ and consider a general mesh $0 = y_0 < y_1 < \cdots < y_J =1$

Let $p_{1,J}$ denote the piecewise-linear interpolant of $f$ that coincides with $f$ at the end-points of the subintervals. A measure of the error is $$ {e_J} = \max_{j = 1, \ldots , J} |(f - p_{1,J})(z_j)|, $$ where $z_j$ is the mid-point of $[y_{j-1},y_j]$. I have changed the the notation from $e_h$ to $e_J$ because I want to focus on how the error decreases as $J$ increases. $J$ is a reasonable measure of the amount of computation needed to compute the interpolant.

Consider the function $f(x) = x^{1/4}$.

(a) For the uniform mesh $y_j = j/J$ with $ j = 0, \ldots , J$, draw up a table of $e_J$ against $J$ and show experimentally that the rate of convergence of $e_J$ to $0$ is about $\mathcal{O}(J^{-1/4})$.

(b) Repeat this experiment with the same $f(x)$ but use instead the adapted mesh $y_j = (j/J)^8$. What rate of convergence do you now observe as $J$ increases?

E3.3*

In this question, you will theoretically prove the convergence behaviour observed in E2.

(a) For the uniform mesh, explain the $\mathcal{O}(J^{-1/4})$ convergence by proving an estimate for $e_J$.

Hint: when estimating the error on the first subinterval, use the triangle inequality to get $ \| f - p_{1,J}\|_{\infty, [y_0,y_1]} \leq \| f \|_{\infty, [y_0,y_1]} + \| p_{1,J}\|_{\infty, [y_0,y_1]} \le 2 y_1^{1/4}. $ For all other subintervals, use error estimates from lectures.

(b) For the adapted mesh in the previous question, explain your calculations by proving an estimate for $e_J$ that explains the $\mathcal{O}(J^{-2})$ convergence.