# Integrate $\log(x)$ with Riemann sum

In a homework problem I am asked to calculate $\int_1^a \log(x) \mathrm dx$ using a Riemann sum. It also says to use $x_k := a^{k/n}$ as steps for the stair functions.

So far I have this:

My step size is $x_k - x_{k-1}$ which can be reduced to $a^{\frac{k-1}{n}} (a^{\frac{1}{n}} -1)$.

The total sum then is:

$$S_n = \sum_{k=0}^n \frac{k}{n} \log(a) a^{\frac{k-1}{n}} (a^{\frac{1}{n}} -1)$$ $$S_n = \log(a) \frac{a^{\frac{1}{n}}}{n} (a^{\frac{1}{n}} -1) \sum_{k=0}^n k a^{\frac{k}{n}}$$

When I punch this into Mathematica to derive the Limit $n \rightarrow \infty$, it gives me $1-a+a \log(a)$ which seems fine to me.

The problem gives a hint, that I should show the Limit of $n(a^{\frac{1}{n}} - 1)$ by setting it equal to a difference quotient. Mathematica says that the limit is $\log(a)$, but that does not really help me out either.

How do I tackle this problem?

Thanks!

-
add comment

## 2 Answers

First, notice that $1-a+a \ln (a)$ can't be the (final) answer. It is an antiderivative of $\ln (a)$, but it is not the antiderivative you are looking for : it does not vanish at $0$. The subtelty is that the Riemann sums approximate the integral of the logarithm between $1$ and $a$, and not between $0$ and $a$.

1) The limit of $n (a^{1/n}-1)$

We can assume that $a$ is positive. I will put $f(x) = a^x = e^{x \ln (a)}$ for non-negative $x$. We can see that :

$$\lim_{n \to + \infty} n (a^{1/n}-1) = \lim_{n \to + \infty}\frac{f(1/n)-f(0)}{1/n} = \lim_{h \to 0} \frac{f(h)-f(0)}{h} = f' (0).$$

Interpretating a limit as the derivative of some well-chosen function is a useful trick (that is, before you learn more powerful and general methods). Now, find by yourself the result of Mathematica :)

2) Back to your problem

As a preliminary remark, I advise you to be careful about the bounds in your sums. A nice Riemann sum is a sum going from $0$ to $n-1$, or from $1$ to $n$, so that it has exactly $n$ terms and does not overflow from the domain of integration. here, we are looking at :

$$S_n = \sum_{k=1}^n (x_k^{(n)} - x_{k-1}^{(n)}) \ln(x_k^{(n)}) = \sum_{k=1}^n a^{\frac{k-1}{n}} (a^{\frac{1}{n}}-1) \ln(a^{\frac{k}{n}}) = \ln (a) a^{-\frac{1}{n}} n (a^{\frac{1}{n}}-1) \left[ \frac{1}{n} \sum_{k=1}^n \frac{k}{n} a^{\frac{k}{n}} \right]$$

(I prefer sums going from $0$ to $n-1$, but since $\ln (0) = - \infty$ it is a tad easier to use a sum from $1$ to $n$)

As $n$ goes to $+ \infty$, we know that $a^{-1/n}$ converges to $1$ and that $n (a^{1/n}-1)$ converges to $\ln (a)$, so that :

$$\int_1^a \ln (x) dx = \lim_{n \to +\infty} S_n = \ln (a)^2 \lim_{n \to + \infty} \left[ \frac{1}{n} \sum_{k=1}^n \frac{k}{n} a^{\frac{k}{n}} \right].$$

To compute the expression in brackets, look at Joriki's post. As a side note, we can remark that it is a Riemann sum. Hence, with a change of variable ($u = x \ln (a)$):

$$\int_1^a \ln (x) dx = \ln (a)^2 \int_0^1 x a^x dx = \int_0^{\ln (a)} u e^u du,$$

or equivalently:

$$\int_0^a \ln (x) dx = \int_{- \infty}^{\ln (a)} u e^u du.$$

Alas, this integral is usually computed with an integration by parts, in other words by the same trick on usually compute an antiderivative of the logarithm, so that we are back at the beginning (one could have obtained this equality with a mere change of variable).

-
Thanks a lot for the explanations, quite some tricks one has to know for this :-) –  queueoverflow Jan 15 '12 at 14:27
If I take your $\ln(a)^2$ term into Mathematica, it gives me $1-a+a \log(a)$ as the limit. So this off-by-one error is still in there I think. –  queueoverflow Jan 15 '12 at 16:10
I'll restate it : with the intervals $(x_k)$ you have chosen, you are looking at the Riemann sum of the logarithm between $1$ and $a$. In other words, $\int_1^a \ln (x) dx = \lim_{n \to + \infty} S_n = 1-a+a \ln (a)$. To get $\int_0^a \ln (x) dx$ you have to substract $1$. –  D. Thomine Jan 15 '12 at 19:28
Sorry, I have to calculate from 1 to $a$ actually. So that would be the right solution after all then? –  queueoverflow Jan 15 '12 at 19:52
Then that would be the right solution. –  D. Thomine Jan 15 '12 at 20:26
add comment

$$\begin{eqnarray} \lim_{n\to\infty}a^{1/n}\frac{a^{1/n}-1}n\sum_{k=0}^n k a^{k/n} &=& \lim_{n\to\infty}a^{2/n}\frac{a^{1/n}-1}n \sum_{k=0}^n k \left(a^{1/n}\right)^{k-1} \\ &=&\lim_{n\to\infty}\left.q^2\frac{q-1}n\sum_{k=0}^n k q^{k-1}\right|_{q=a^{1/n}} \\ &=&\lim_{n\to\infty}\left.q^2\frac{q-1}n\frac{\partial}{\partial q}\sum_{k=0}^n q^k\right|_{q=a^{1/n}} \\ &=&\lim_{n\to\infty}\left.q^2\frac{q-1}n\frac{\partial}{\partial q}\frac{q^{n+1}-1}{q-1}\right|_{q=a^{1/n}} \\ &=&\lim_{n\to\infty}\left.q^2\frac{q-1}n\frac{nq^{n+1}-(n+1)q^n+1}{(q-1)^2}\right|_{q=a^{1/n}} \\ &=&\lim_{n\to\infty}\left.q^2\frac{q^{n+1}-(1+1/n)q^n+1/n}{q-1}\right|_{q=a^{1/n}} \\ &=&\lim_{x\to0}a^{2x}\frac{a^xa-(1+x)a+x}{a^x-1} \\ &=&\lim_{x\to0}\frac{a^xa-(1+x)a+x}{a^x-1} \\ &=&\lim_{x\to0}\frac{a^xa\log a -a+1}{a^x\log a} \\ &=&a+\frac{1-a}{\log a}\;. \end{eqnarray}$$

-
Thanks for the detailed answer. What is this trick with the $\partial$ called? I haven't seen anything like this for a sum yet. –  queueoverflow Jan 15 '12 at 14:29
add comment