Implement an algorithm to approximate $f_a$ by a piecewise constant function on
the uniform parition of $[-1,1]$ consisting of $n$ subintervals.
For example, one could use the value of $f_a$ at the midpoint of each subinterval (as happens in the midpoint rule).
Plot a couple of illustrative examples with different $a$ and $n$.
In the asymptotic regime where $n$ is large,
we expect the error of the approximation to behave like $n^{-r}$ for some $r$, which we call the rate of convergence.
Implement a procedure to approximately compute the error of the approximation in the maximum norm
(You don't need to do anything too complicated),
and estimate the rate of convergence for a number of differerent values of $a$, focusing around the point $a=1$
(e.g., for $a=0.5, 0.6,..., 1.5$).
Note that what happens in the preasymptotic regime (i.e., when $n$ is moderate) might pollute your estimate of the convergence rate
(especially if you are doing it automatically),
so you need to remove small values of $n$ from considerations.
To identify roughly where the asymptotic regime starts, some manual fiddling, combined with theoretical insights might be necessary.
How does the rate of convergence depend on the regularity of the function?
Have a guess at the dependence $r=r(a)$.
Explain the behaviour in the context of approximation theory.
Note: The following exercises are the same as this one, except that they concern different approximation procedures.
The general remarks, suggestions, and questions from this exercise will also apply to them.