I am trying to derive an asymptotic expression for $N\to \infty$ for the classic sum:
$$ \sum_{n\leq N} \log n = \log (N!)$$
But with the error of the size $O(1/N)$.
I am using the standard methodology of applying Euler's summation but (obviously) I can only get the usual result:
$$\sum_{n\leq N} \log n = N\log N-N+2 +\int_1^N\{t\}t^{-1} dt - \{N\}\log N $$
which gives
$$ \sum_{n\leq N} \log n = N\log N-N+ O(\log N) $$
Is there really any way to derive an asymptotic formula with error $O(1/N)$?
Thanks in advance for any hints on how can I proceed!
You can use the Euler–Maclaurin formula in the form $$ \sum\limits_{k = 1}^n {f(k)} = \int_1^n {f(x){\rm d}x} + \frac{{f(n) + f(1)}}{2} + \int_1^n {f'(x)\left( {\left\{ x \right\} - \tfrac{1}{2}} \right){\rm d}x} . $$ Taking $f(x)=\log x$ yields $$ \sum\limits_{k = 1}^n {\log k} = \left( {n + \tfrac{1}{2}} \right)\log n - n + 1 + \int_1^n {\frac{1}{x}\left( {\left\{ x \right\} - \tfrac{1}{2}} \right){\rm d}x} . $$ Integration by parts gives \begin{align*} \int_1^n {\frac{1}{x}\left( {\left\{ x \right\} - \tfrac{1}{2}} \right){\rm d}x} = & - \int_1^n {\frac{1}{{2x^2 }}(\left\{ x \right\} - \left\{ x \right\}^2{\rm )d}x} \\ =& - \int_1^{ + \infty } {\frac{1}{{2x^2 }}(\left\{ x \right\} - \left\{ x \right\}^2{\rm )d}x} + \int_n^{ + \infty } {\frac{1}{{2x^2 }}(\left\{ x \right\} - \left\{ x \right\}^2{\rm )d}x} . \end{align*} The first integral converges to a constant, the second integral is clearly $\mathcal{O}\!\left( \frac{1}{n} \right)$ (you can show in fact that its value is between $0$ and $ \frac{1}{8n}$). Thus $$ \sum\limits_{k = 1}^n {\log k} = \left( {n + \tfrac{1}{2}} \right)\log n - n + C + \mathcal{O}\!\left( {\frac{1}{n}} \right) $$ as $n\to +\infty$. One can then show, using for example the Wallis product, that $C=\frac{1}{2}\log(2\pi)$.