0

I'm trying to show that the partial sums of $\log(j) = n\log(n) - n + \text{O}(\log(n))$

I know that $$\int_1^n\log(x)dx = n\log(n) - n + 1$$

so that this number is pretty close to what I want.

Now I look at the difference between sum and integral of log:

$$\sum_{j=1}^n \log(j) - \int_1^n \log(x)dx$$

My work:

Working out the arithmetic and simplifying as much as possible, I am now at $$\sum_{j=1}^n \log(j) - \int_1^n \log(x)dx = \log(n) + \sum_{j=1}^{n-1} \big[\log(\large \frac{1}{1+\frac{1}{j}}) - \log(1 + \frac{1}{j})(j) + 1]$$

Where can I go from here? I think I would want to show that this difference, i.e. the R.H.S., is actually $O(\log(n))$ ...

Thanks,

user26857
  • 52,094
  • 1
    Note that $\log(1) + \log(2) + \ldots + \log(n) = \log(n!)$. Now we have this very useful result which is proven in several answers on this site, see e.g. this one and this one – Winther Dec 05 '15 at 03:24
  • Thanks so much for your quick response @Winther. I will work out a derivation, while taking a peak at the link that you provided :-) – user296012 Dec 05 '15 at 03:28
  • Come to think of it, you don't need the power of Strilings here. Just consider the integral $\int_{1}^n\log(x){\rm d}x = n\log(n) - n+1$ and try to bound this above and below by sums $\sum \log(i)$. This is easy as $\log(x)$ is increasing so for example the integral is $\leq \log(2) + \log(3) \ldots + \log(n)$. Combinding the upper and lower bound is enough to get the result you want. – Winther Dec 05 '15 at 03:42
  • I was wondering the same thing too, @Winther. I have noticed now a pattern in the old exam questions that I practice with. Usually, what I need to prove, although difficult at first, can be done with pretty basic tools. And it turns out that a Google search afterwards shows that the result is actually a famous one. So, since I am practicing for exams, it would be better to not use the power of Stirling's formula, I think. I am trying to figure out your derivation of why the integral of $log(x)dx$ is $nlog(n) - n+1$ ... – user296012 Dec 05 '15 at 03:48
  • Try using integration by parts $\int u' v{\rm d}x = uv - \int uv'{\rm d}x$ with $u' = 1$ and $v = \log(x)$. – Winther Dec 05 '15 at 03:51
  • This is how physicists usually "proove" Stirling formula. Simply "replace" the sum with an integral. If you want more accuracy you can use the Euler-Maclaurin formula – lcv Dec 05 '15 at 04:27
  • 1
  • Hi @Winther, I agree with your derivation of the integral of $log(x)dx$ -- it looks very close to the result I want to prove. Now, I look at the difference between the sum and integral of log(j) and of log(x), respectively. Working out the arithmetic and simplifying a bit, I am now at $\sum log(j) - \int log(x)$ = $log(n)$ + $\sum log(\frac{1}{1+\frac{1}{j}}) - log(1 + \frac{1}{j})(j) + 1$. Where can I go from here? I think I would want to show that this difference is actually $O(log(n))$ ... – user296012 Dec 05 '15 at 06:09
  • Note that we can write $\int_1^n f(x){\rm d}x = \sum_{k=1}^{n-1}\int_{k}^{k+1}f(x){\rm d}x$. Next note that $f(x) = \log(x)$ is increasing so we have $f(k) = \int_{k}^{k+1}f(k){\rm d}x \leq \int_{k}^{k+1}f(x){\rm d}x \leq \int_{k}^{k+1}f(k+1){\rm d}x = f(k+1)$. – Winther Dec 05 '15 at 06:25
  • Hi @Winther, hmm...I've already used the rewriting technqiue that you suggested, but I am now stuck with a $log(n)$ plus a sum of a difference of logs, plus the number 1. And it doesn't look like the difference telescopes either. I posted my work on the question post as an edit... – user296012 Dec 05 '15 at 06:29
  • Rearranging the inequality I mentioned above gives you $0 \leq \sum_{i=1}^n \log(i) - \int_1^n \log(x){\rm d}x \leq \log(n)$. Now you only have to use the value for the integral to arrive at $1 \leq \sum_{i=1}^n \log(i) - [n\log(n) - n] \leq \log(n) + 1$ and you are basically there. – Winther Dec 05 '15 at 06:31
  • Hi @Winther, I have a lot of messy scratchwork so I started over again and now notice that there's indeed telescoping sums to take advantage of with the logarithms. Can I just ask you one final question, if you don't mind? Is this number $log(n) + \sum_{j=1} (-log(n+1) - j(log(n)) + 1) \in O(log(n))$? I'm pretty sure it is, but just want to confirm. Thanks, – user296012 Dec 05 '15 at 07:40
  • That expression, as written, do not make much sense to me. Taken litterary and computing the sum it says $\log(n) - n\log(n+1) - n(n+1)/2\log(n) + n$ which is not $O(\log(n))$. – Winther Dec 05 '15 at 08:13
  • Right, I just computed this directly to check, too @Winther ... hmmm...I have messed up somewhere. I really want to go home and sleep :-( but I'll try this again now... thanks, – user296012 Dec 05 '15 at 08:23
  • Hi @ClementC., I just read your integration proof -- thanks so much for the link. However, in your proof you show $nlog(n) - n + O(n)$ ... can your proof be tweaked to get $O(log(n))$? – user296012 Dec 05 '15 at 10:18

2 Answers2

2

It is a direct application of Abel's summation. We have $$\sum_{k\leq n}\log\left(k\right)=\sum_{k\leq n}1\cdot\log\left(k\right)=n\log\left(n\right)-\int_{1}^{n}\frac{\left\lfloor t\right\rfloor }{t}dt $$ where $\left\lfloor t\right\rfloor $ is the floor function and using $\left\lfloor t\right\rfloor =t+O\left(1\right) $ we have $$\sum_{k\leq n}\log\left(k\right)=n\log\left(n\right)-n+1+O\left(\int_{1}^{n}\frac{1}{t}dt\right)=n\log\left(n\right)-n+O\left(\log\left(n\right)\right).$$

Marco Cantarini
  • 33,062
  • 2
  • 47
  • 93
  • Hi @MarcoCantarini, is $log(n) + \sum_{j=1} (-log(n+1) - j(log(n)) + 1) \in O(log(n))$? I computed the difference between the sum and the integral, and got this number. If it is indeed $O(log(n))$, then I am done, since the integral, by integration by parts is equal to $nlog(n) - n + 1$ ... – user296012 Dec 05 '15 at 07:47
  • And the number $1$ can get absorbed into $O(log(n))$, I think? Thanks, – user296012 Dec 05 '15 at 07:48
  • @user296012 Yes, $1$ is absorbed into $O(\log(n))$. I linked the wikipedia page of Abel's summation, it is a direct application of it. – Marco Cantarini Dec 05 '15 at 07:53
  • 1
    Ok, got it - thanks so much @MarcoCantarini :-) – user296012 Dec 05 '15 at 08:00
  • Hi @MarcoCantarini, to be honest, I've still been trying to use other kinds of brute force methods / approximations to show this, rather than learning Abel's summation. Finally, I gave up -- the best approximation was only $O(n)$. And now that I've read up briefly on Wikipedia Abel's summation formulas, it's actually surprisingly very easy to remember -- with very few assumptions and requirements (just need one function to be $C^1$.) Can I ask you a question about the integration term? We are integrating a discrete object, $A_n$ against a continuous function d(log(t)). How does it work? – User001 Dec 06 '15 at 06:36
  • Since the $A_n$ is 1...for every n...then it is counting the number of 1s. Then, $A_n = 1+ 1 + ... +1 = n$. But this is discrete and not integrable, right? I am talking about Riemann-integrability, since I am not studying measure theory currently. So, why do you change it to the floor function? Does doing that turn the $A_n$ into a ...constant? Then you pull it outside of the integral? But doing that would give ... $-n$ + $O(\int 1/t dt)$. But where did you find the extra term +1? – User001 Dec 06 '15 at 06:37
  • Thanks for your time. (I am so stubborn, but I finally learned the Abel summation formula now. Just need to understand how does integration of a discrete object work...) Thanks @MarcoCantarini, – User001 Dec 06 '15 at 06:37
  • Oo I see it now @MarcoCantarini, you expand the floor function as $t+ O(1)$, then integrating a function with a integrand of $1dt$, which gives the $(n-1)$, which then gives the $-n + 1$. I guess the only thing left is to understand why the expansion is just $t+O(1)$ for a sequence of partial sums $1+1+1 + ... $ .... what do you think? Thanks, – User001 Dec 06 '15 at 06:48
  • so...I feel that the floor function should just be $1+1+ ... + 1 = t$. Why is there a remainder term $O(1)$? Thanks @MarcoCantarini, – User001 Dec 06 '15 at 06:51
  • Hi @MarcoCantarini, nevermind - I finally understand it all now :-) Wohooo, thanks for your patience. Have a great night :-) – User001 Dec 06 '15 at 08:00
  • 1
    @LebronJames You answered by yourself, so good work! ;) – Marco Cantarini Dec 06 '15 at 08:58
0

You have $\log(1+1/j) = 1/j+O(1/j^2)$, so $\sum_{j=2}^n \frac1{\log(1+1/j)} \approx \sum_{j=2}^n (-1/j+O(1/j^2)) \approx -\log(n)+O(1) $ and (I think you mean $n$ in this expression instead of $j$) $n\log(1+1/n) \approx 1$ , which, I think, gives you what you want.

marty cohen
  • 107,799