Review question

Can we find this integral involving the floor function? Add to your resource collection Remove from your resource collection Add notes to this resource View your notes for this resource

Ref: R7106

Solution

For a real number $x$ we denote by $[x]$ the largest integer less than or equal to $x$.

Let $n$ be a natural number. The integral $\int_0^n [2^x]\, dx$ equals

1. $\log_2 ((2^n-1)!)$;

2. $n2^n-\log_2 ((2^n)!)$;

3. $n2^n$;

4. $\log_2 ((2^n)!)$,

where $k! = 1\times 2 \times 3 \times \cdots \times k$ for a positive integer $k$.

The function $[x]$ is called the floor function (for obvious reasons). It can also be written as $\lfloor x \rfloor$.

You might wonder if there is a ceiling function, and indeed there is; $\lceil x \rceil$ represents the smallest integer greater than or equal to $x$.

The graph of $[2^x]$ looks roughly like this:

We can see that, in the range $0\le x\le n$, $[2^x]$ will take all integer values from $1$ to $2^n$. More precisely, we have $[2^x]=k \quad \text{for} \quad \log_2 k \le x < \log_2 (k+1).$

This means we can turn the integral into a sum of rectangles which equals $(\log_2 2-\log_2 1)+2(\log_2 3-\log_2 2)+3(\log_2 4-\log_2 3)+\cdots+(2^n-1)(\log_2 2^n-\log_2(2^n-1)).$

There is a lot of cancellation here, which leaves us with \begin{align*} -\log_2 1&{}-\log_2 2-\log_2 3-\cdots-\log_2(2^n-1)+(2^n-1)\log_2 2^n\\ &{}=2^n\log_2 2^n-(\log_2 1+\log_2 2+\log_2 3+\cdots+\log_2 2^n)\\ &{}=n2^n-\log_2((2^n)!). \end{align*}

An alternative way to think about the area is as horizontal strips instead of vertical strips.

The strip between height $k-1$ and $k$ has length $n-\log_2 k$, and so this is its area, too.

Adding these up for $k=1$ through to $k=2^n$ gives the same answer.

The strip between height $2^n-1$ and $2^n$ has zero width and zero area.