# Finding Bounds in proof of Stirling's Formula

In a proof of Stirling's Formula, my professor claims that

$$\frac 12$$($$ln$$k + $$ln$$(k+1)) $$\le$$ $$\int_k^{k+1}ln$$x $$dx$$ $$\le$$ $$\frac 12$$($$ln$$k + $$ln$$(k+1)) + $$\frac 1{k^2}$$.

I can see that the first inequality is true by concavity of the natural log function (hence the area of the trapezoid beneath natural log is less than the integral of the function itself), but can someone provide insight into the second inequality??

I know $$\frac 1{k^2}$$ must be a bound for the area beneath $$ln$$x but above the trapezoid described by the leftmost expression, but it is not clear how to check that this is true.

\begin{align} \int_{\ln(k)}^{\ln(k+1)} &= \int_0^1 \ln(k+x) dx = \int_0^{1/2} \ln(k+x) + \int_{1/2}^{1} \ln(k+1 - x) dx \\ &= \int_0^{1/2} \ln(k) + \frac{x}{k} - \frac{x^2}{2k^2} + o(\frac{1}{k^2}) dx \\ &\quad + \int_{1/2}^1 \ln(k+1) - \frac{x}{k+1} - \frac{x^2}{(k+1)^2} + o(\frac{1}{(k+1)^2}) dx \\ &= \frac{1}{2} (\ln(k) + \ln(k+1)) + \frac{1}{8k} + \frac{1}{8(k+1)} - \frac{1}{2(k+1)} \\ &\quad - \frac{1}{48k^2} + \frac{1}{48(k+1)^2} - \frac{1}{6k^2} + o(\frac{1}{k^2}) \end{align}
Clearly the terms of order $$1/k$$ and $$1/k^2$$ have negative sums, hence the bound is actually quite brutal, but probably sufficient for what your professor wants to do.