TITLE: Counterexample to Riemann sum limit
QUESTION [11 upvotes]: For convergent Riemann sums of $f \in C^1([0,1])$ there is the property:
$$\tag{A}\lim_{n \to + \infty} \left[\, \sum_{k=0}^{n} f \left( \frac{k}{n+1} \right) - \sum_{k=0}^{n-1} f \left( \frac{k}{n} \right) \, \right] = \int_0^1 f (x) \ dx$$
Proof using the mean value theorem goes like
$$\, \sum_{k=0}^{n} f \left( \frac{k}{n+1} \right) - \sum_{k=0}^{n-1} f \left( \frac{k}{n} \right) = f \left( \frac{n}{n+1} \right) + \sum_{k=0}^{n-1}f'(\theta_k)\left(\frac{k}{n+1} - \frac{k}{n} \right)$$
and then shows the right side converges to $f(1) - \int_0^1 xf'(x) dx = \int_0^1f(x)dx.$  So it is very helpful that $f \in C^1$.
If we only have $f \in C[0,1]$, then equation (A) may not be true, and this was shown by Daniel Fischer using Banach-Steinhaus theorem in this  answer. Here a related statement was considered:
$$\tag{B}\lim_{n\to\infty}\left[\, \sum_{k=0}^{n-1} f\left(\frac{k}{n}\right) - n\int_0^1 f(x)\,dx\, \right] = \frac{f(0) - f(1)}{2}$$
My question: Can someone please show me a concrete counterexample, i.e., a continuous but not continuously differentiable function where (A) or (B) is false?

REPLY [6 votes]: Consider Weierstrass function
$$
f(x)=\sum_{l=1}^\infty 2^{-l/2}\cos \pi 2^l x.
$$
It is nowhere differentiable but is Holder continuous with exponent $1/2$. Also it is an example of a lacunary Fourier series.
Let's show that the expression under the limit sign in (B) is not bounded. The integral in the lhs is zero. For $n=2^m$
$$
\sum_{k=0}^{2^m-1}f\left(\frac{k}{2^m}\right)=
\sum_{l=1}^\infty 2^{-l/2}\sum_{k=0}^{2^m-1}\cos \pi 2^{l-m} k.
$$
It's straightforward to check, presenting cosine as a sum of imaginary exponents and evaluating the appearing geometric progression, that
$$
\sum_{k=0}^{2^m-1}\cos \pi 2^{l-m} k=
\left\{
\begin{array}{r,l}
2^m,&&m<l,\\
0,&&m\ge l.
\end{array}
\right.
$$
Therefore
$$
\sum_{k=0}^{2^m-1}f\left(\frac{k}{2^m}\right)=
\sum_{l=m+1}^\infty 2^{-l/2}2^m=\left(1+\sqrt{2}\right) 2^{m/2}\to \infty
$$
as $m\to\infty$.