Compute $\lim_{n\to\infty}(n-(\arccos(1/n)+\cdots+\arccos(n/n)))$ How would you compute
$$\lim_{n\to\infty}(n-(\arccos(1/n)+\cdots+\arccos(n/n)))?$$
If we choose $n=10000$ and compute it with W|A, we get $0.78833$ that is
suspiciously close to $\pi/4.$ I also discussed the limit in the chatroom. Thanks!
 A: The expression being subtracted is $n$ times the result of applying the trapezoidal rule to the integration of $\arccos x$ from $0$ to $1$, except for a contribution $\frac12(\arccos(0)-\arccos(1))=\pi/4$. The integral is $1$, and since the error of the trapezoidal rule is quadratic in the interval size, and thus falls off as $1/n^2$, the overall error goes to zero as $1/n$ with $n\to\infty$, so only the contribution $\pi/4$ remains.
A: For $x\in[0,1]$, Taylor's Theorem says
$$
f\left(\frac{k-x}{n}\right)
=f\left(\frac{k}{n}\right)
-f'\left(\frac{k}{n}\right)\frac{x}{n}
+O\left(\frac1{n^2}\right)
$$
Summing in $k$ yields
$$
\sum_{k=1}^nf\left(\frac{k-x}{n}\right)
=\sum_{k=1}^nf\left(\frac{k}{n}\right)
-x\color{#C00000}{\sum_{k=1}^nf'\left(\frac{k}{n}\right)\frac1n}
+O\left(\frac1n\right)
$$
Integrating in $x$ over $[0,1]$ gives the first terms of the Euler-Maclaurin Sum Formula times $n$:
$$
\int_0^nf\left(\frac xn\right)\,\mathrm{d}x
=n\int_0^1f(x)\,\mathrm{d}x
=\sum_{k=1}^nf\left(\frac{k}{n}\right)
-\frac12\color{#C00000}{(f(1)-f(0))
+O\left(\frac1{\sqrt{n}}\right)}
$$
Setting $f(x)=1-\arccos(x)$ yields
$$
n-\sum_{k=1}^n\arccos\left(\frac kn\right)=\frac\pi4+O\left(\frac1{\sqrt{n}}\right)
$$
Therefore,
$$
\lim_{n\to\infty}\left(n-\sum_{k=1}^n\arccos\left(\frac kn\right)\right)=\frac\pi4
$$
Note about the red sum
When $f$ and $f'$ are monotonic, the error in the Riemann Sum approximation
$$
\sum_{k=1}^nf'\left(\frac{k}{n}\right)\frac1n=f(1)-f(0)
$$
is less than
$$
\left|f(1)-f\left(1-\frac1n\right)\right|+\left|f\left(\frac1n\right)-f(0)\right|
$$
In the case of $f(x)=1-\arccos(x)$, this error is $\sim\sqrt{\dfrac2n}$ .
