How to take limits of 'almost Riemann' sums like $\lim_{n \to \infty} \sum_{k=0}^n \frac{1}{n} \cos (a \pi k \log(n)/n)$ How can I solve limits of sums that are 'almost' Riemann, but can't be written in the typical form (i.e, $\lim_{n \to \infty} \sum_{k=0}^n \frac{1}{n} f(k/n)$ which we can rewrite as an integral $\int_0^1 f(x) dx$)?
For example, I'd like to turn $\lim_{n \to \infty} \sum_{k=0}^n \frac{1}{n} \cos (a \pi k \log(n)/n)$ into an integral.
More generally, is there a closed-form way to convert sums like $\lim_{n \to \infty} \sum_{k=0}^n \frac{1}{n} f(k h(n)/n)$ into integrals, when $h(n) = o(n)$? Clearly such sums don't always converge - if $h(n) = \log(n)$, and $f(kh(n)/n) = k\log(n)/n$, the limit is unbounded. What conditions on $f, h$ might we require for convergence?
 A: This is not a comprehensive solution to the general question posed in the OP, however it does give a solution to the first (and more specific) question in the OP and gives some sufficient conditions for the more general question.


*

*Suppose $h\geq0$, $h(n)\xrightarrow{n\rightarrow\infty}\infty$, and $h(n)=o(n)$.

Divide $[0,h(n)]$ in $n$ subintervals of same size. The size of each subinterval is $\frac{h(n)}{n}$ and the Riemann sum of the integral $\int^{h(n)}_0 f\,dx$ for the uniform partition is
$$\frac{h(n)}{n}\sum^n_{k=1}f\big(\frac{k}{n}h(n)\big)$$
Then
$$A_n:=\int^{h(n)}_0f(x)\,dx-\frac{h(n)}{n}\sum^n_{k=1}f\big(\frac{k}{n}h(n)\big)=\sum^{n}_{k=1}\int^{\tfrac{k}{n}h(n)}_{\tfrac{k-1}{n}h(n)}\Big(f(x)-f\big(\tfrac{k}{n}h(n)\big)\Big)\,dx$$


*Suppose  $f$ is uniformly continuous in $[0,\infty)$.

Then for any $\varepsilon>0$, there is $N\in\mathbb{N}$ for which
$$\begin{align}
\frac{1}{h(n)}|A_n|\leq \frac{1}{h(n)}\sum^{n}_{k=1}\int^{\tfrac{k}{n}h(n)}_{\tfrac{k-1}{n}h(n)}\Big|f(x)-f\big(\tfrac{k}{n}h(n)\big)\Big|\,dx\leq \varepsilon
\end{align}$$
for $n\geq N$. That is
$$\begin{align}
\frac{1}{h(n)}|A_n|\xrightarrow{n\rightarrow\infty}0\tag{0}\label{zero}
\end{align}$$
Notice that
$$\begin{align}
C_n:=\frac{1}{n}\sum^n_{k=1}f\big(\frac{k}{n}h(n)\big)
=\frac{1}{h(n)}\Big(\int^{h(n)}_0 f(x)\,dx -A_n\Big)\tag{1}\label{one}\end{align}$$
3. Let $F:x\mapsto \int^x_0 f(t)\,dt$, $x\geq0$. If  $F$ is bounded, then from \eqref{zero} and \eqref{one}
$$C_n\xrightarrow{n\rightarrow\infty}0$$
4. If $f(x)\xrightarrow{x\rightarrow\infty}b$, then from \eqref{zero} and \eqref{one}
$$C_n\xrightarrow{n\rightarrow\infty}b$$

Conditions 1-3 are satisfied for the function $f(x)=\cos(a\pi x)$ and sequence $h(n)=\log n$. Thus,
$$\frac1n\sum^n_{k=1}\cos(a\pi\tfrac{k}{n}\log n)\xrightarrow{n\rightarrow\infty}0$$
