Compute $\lim \limits _{n\to \infty} \frac{1}{n^2}\sum_{1\le i < j \le n}^n \cos \left(\frac{i}{n}\right) \cos \left(\frac{j}{n} \right)$

Compute $$\lim \limits _{n\to \infty} \frac{1}{n^2}\sum_{1\le i < j \le n}^n \cos \left(\frac{i}{n}\right) \cos \left(\frac{j}{n} \right)$$.
I think that this limit can be computed by writing it as a Riemann sum. However, what puzzles me is that there are $$2$$ summation indices and I don't know how to find the integral.
Note: This should be solveable without double integrals since it comes from a single variable calculus book.

• Which single variable calculus book are you referring to? – Jack Jun 12 at 15:29
• The question in the title does not match the one in the post. – Jack Jun 12 at 15:30
• The sum is $\frac12\left(\left(\sum_i\cos\frac{i}{n}\right)^2-\sum_i\cos^2\frac{i}{n}\right)$. – J.G. Jun 12 at 15:41
• @JoMath In general,$$\sum_{i<j}a_ia_j=\frac12\sum_{i\ne j}a_ia_j=\frac12\left(\sum_{ij}a_ia_j-\sum_{i=j}a_ia_j\right)=\frac12\left(\left(\sum_ia_i\right)^2-\sum_ia_i^2\right).$$ – J.G. Jun 12 at 16:04
• I know you asked for a solution without double integrals - but as a comment, a solution with double integrals would be that roughly it's $\int_0^1 \int_0^x \cos x \cos y\,dy\,dx$. (This could be formalized by observing the sum is the integral of $\sum_{1\le i < j \le n} \cos(i/n) \cos(j/n) \chi_{[i/n, (i+1)/n}](x) \chi_{[j/n, (j+1)/n]}(y)$ which converges pointwise a.e. to $\cos x \cos y \chi_{[0,1]}(x) \chi_{[0,1]}(y) 1_{y < x}$ and then apply the dominated convergence theorem.) – Daniel Schepler Jun 12 at 16:22

Expanding on my first comment, we want to evaluate$$\frac12\left(\left(\lim_{n\to\infty}\left[\frac{1}{n}\sum_{i=1}^n\cos\frac{i}{n}\right]\right)^2-\lim_{n\to\infty}\frac{1}{n}\left[\frac{1}{n}\sum_{i=1}^n\cos^2\frac{i}{n}\right]\right)=\frac12\left(\int_0^1\cos xdx\right)^2=\frac12\sin^2 1.$$
$$L=\frac{1}{2}\left(\lim_{n\rightarrow \infty} \frac{1}{n} \sum_{k=1}^{n} \cos(k/n) \right)^2-\frac{1}{2} \left(\lim_{n\rightarrow \infty} \frac{1}{n^2} \sum_{k=1}^{n} \cos^2(k/n) \right).....(1)$$ $$L=\frac{1}{2} \left( \int_{0}^{1} \cos x dx \right)^2 = \frac{\sin^2 1}{2}....(2).$$ the second term vanishes because of $$n^2$$ in denominator.