TITLE: Doubt about the convergence of $\displaystyle \sum_k^{n-1}f(\frac{k+\theta} n)-n\int_0^1 f(x)\,dx$
QUESTION [6 upvotes]: Let $\theta\in[0,1]$ be a constant and $f\in C^1[0,1] $. Show that $$\sum_k^{n-1}f\left(\frac{k+\theta} n\right)-n\int_0^1 f(x)\,dx$$
converges to $(\theta-\frac{1}{2})(f(1)-f(0))$, as $n\to\infty.$

\begin{align}
& S_n=\sum_k^{n-1}f\left(\frac{k+\theta} n\right)-n\int_0^1 f(x)\,dx \\[10pt]
={} & n\sum_k^{n-1} \int_{k/n}^{(k+1)/n} \left( f \left(\frac{k+\theta} n\right)-f(x)\right) \, dx \\[10pt]
= {} & n\sum_k^{n-1} \int_{k/n}^{(k+1)/n} \int_x^{(k+\theta)/n} f'(s) \, ds \, dx \\[10pt]
= {} &  n\sum_k^{n-1} \left( \int_{k/n}^{(k+\theta)/n} \int_x^{(k+\theta)/n}-\int_{k+\theta/n}^{(k+1)/n} \int_{(k+\theta)/n}^x \right)f'(s)\,ds\,dx
\end{align}
\begin{align}
& n\sum_k^{n-1} \int_{k/n}^{(k+1)/n} \int_x^{(k+\theta)/n} f'(s) \, ds \, dx \\[10pt]
= {} & n\sum_k^{n-1} \left( \int_{k/n}^{(k+\theta)/n}\int_x^{(k+\theta)/n}-\int_{k+\theta/n}^{(k+1)/n} \int_{(k+\theta)/n}^x \right) f'(s) \, ds \, dx
\end{align}
\begin{align}\int_{k/n}^{(k+\theta)/n}\int_x^{(k+\theta)/n} f'(s) \, ds \, dx=\int_{k/n}^{(k+\theta)/n}\int_{(k)/n}^s f'(s) \, ds \, dx=\int_{k/n}^{(k+\theta)/n}f'(s)(s-\frac{k}{n}) \, ds 
\int_{k+\theta/n}^{(k+1)/n}\int_{(k+\theta)/n}^x f'(s) \, ds \, dx=\int_{k+\theta/n}^{(k+1)/n}\int_s^{(k+1)/n} f'(s) \, ds \, dx=\int_{k+\theta/n}^{(k+1)/n}f'(s)(\frac{k+1}{n}-s) \, ds\end{align}
Therefore
\begin{align}
\sum_k^{n-1} \int_{k/n}^{(k+1)/n} f'(s)\phi_k(s) \, ds \end{align}
where \begin{align}
\phi_k(s)=ns-k-\begin{cases}
0, & \mbox{ if }(k\leqslant ns <k+\theta)\\1, & \mbox{ if }k+\theta\leqslant ns <k+1\end{cases}\end{align},
Denoting by $\{x\}$ the fractional part of $x$ and noticing that $k=[ns]$ for $k\leqslant ns\leqslant k+1$, we see that $\phi_k(s)=g(ns)$, where
\begin{align}g(x)=\{x\}-\begin{cases}
0, & \mbox{ if }(\{x\}<\theta)\\1, & \mbox{ if }(\{x\}\geqslant \theta)\end{cases}=\{x-\theta\}+\theta-1\end{align}
is a piecewise linear periodic function of period 1.Any piecewise continuous periodic function $g(x)$, we conclude that \begin{align}S_n=\int_0^1 f'(x)g(nx)dx\to \mathscr{M}_[0,1](g)\times \int_0^1 f'(x) dx=(\theta-\frac{1}{2})(f(1)-f(0))\end{align} as $n\to\infty$ because $f'\in\mathscr{C}_[0,1]$
Question:
I do not understand what the author does when it is defined  $g(x)=\{x\}-\begin{cases}
0, & \mbox{ if }(\{x\}<\theta)\\1, & \mbox{ if }(\{x\}\geqslant \theta)\end{cases}=\{x-\theta\}+\theta-1$ Where does this come from? How did he derive it?
How does the author prove \begin{align}S_n=\int_0^1 f'(x)g(nx)dx\to \mathscr{M}_[0,1](g)\times \int_0^1 f'(x) dx=(\theta-\frac{1}{2})(f(1)-f(0))\end{align}
Where did $\sum_{k=0}^{n-1}$ go to?
Thanks in advance!

REPLY [3 votes]: You can simplify things by noting the expression equals
$$\tag 1 \sum_{k=0}^{n-1}[f(k/n+\theta/n)- f(k/n)] + \sum_{k=0}^{n-1}f(k/n)- n\int_0^1 f.$$
By the MVT, the first sum in $(1)$ equals
$$\sum_{k=0}^{n-1}f'(c(k,n))\cdot (\theta/n) = \theta\sum_{k=0}^{n-1}f'(c(k,n))\cdot (1/n).$$
This converges to $\theta\int_0^1 f' =\theta(f(1)-f(0)).$
The rest of $(1)$ equals
$$\tag 2 n \left (\sum_{k=0}^{n-1}\int_{k/n}^{(k+1)/n}[f(k/n)-f(x)]\,dx\right ).$$
For $n$ large we expect $f(x) \approx f(k/n) +f'(k/n)(x-(k/n))$ for $x$ in the $k$th interval. Let's just brazenly insert that into $(2).$ We get
$$n \left (-\sum_{k=0}^{n-1}\int_{k/n}^{(k+1)/n}f'(k/n)(x-(k/n))\,dx \right )$$ $$ = n \left (-\sum_{k=0}^{n-1}f'(k/n)(1/(2n^2)) \right ) = -(1/2)\sum_{k=0}^{n-1}f'(k/n)(1/n).
 $$
The last expression $\to -(1/2)\int_0^1 f' = -(1/2)f(1)-f(0)).$ So this looks very good. All we need to verify is that the approximations $f(x) \approx f(k/n) +f'(k/n)(x-(k/n))$ are good enough. This follows from the uniform continuity of $f'.$ I'll leave this verification to the reader for now.