# integral $\int_{0}^{1}\left( \left\lfloor{\frac{2}{x}} \right\rfloor-2 \left\lfloor{\frac{1}{x}} \right\rfloor \right)dx$

Evaluate $$\int_{0}^{1}\left( \left\lfloor{\frac{2}{x}} \right\rfloor-2 \left\lfloor{\frac{1}{x}} \right\rfloor \right)dx$$

My Attempt

$$I_{1}=\int_{0}^{1}\left\lfloor{\frac{2}{x}} \right\rfloor dx$$

Put $x=2t$

$$I_{1}=\int_{0}^{\frac{1}{2}}2\left\lfloor{\frac{1}{t}} \right\rfloor dt=\int_{0}^{\frac{1}{2}}2\left\lfloor{\frac{1}{x}}\right\rfloor dx$$

let $$I_{2}=\int_{0}^{1} \left\lfloor{\frac{1}{x}} \right\rfloor dx=\int_{0}^{\frac{1}{2}}\left\lfloor{\frac{1}{x}}\right\rfloor dx+\int_{\frac{1}{2}}^{1}\left\lfloor{\frac{1}{x}}\right\rfloor dx$$

Given integral \begin{align} \int_{0}^{1}\left(\left\lfloor{\frac{2}{x}}\right\rfloor-2\left\lfloor{\frac{1}{x}}\right\rfloor \right)dx&=I_{1}-2I_{2}\\ &=2\int_{0}^{\frac{1}{2}}\left\lfloor{\frac{1}{x}}\right\rfloor dx-2\int_{0}^{\frac{1}{2}}\left\lfloor{\frac{1}{x}}\right\rfloor dx-2\int_{\frac{1}{2}}^{1}\left\lfloor{\frac{1}{x}}\right\rfloor dx\\ &=-2\int_{\frac{1}{2}}^{1}\left\lfloor{\frac{1}{x}}\right\rfloor dx\\ &=(-2)(1)=-2. \end{align}

But answer given is $\ln(\frac{4}{e})$

What mistake am I making?

• "What mistake am I making?" You neglected the fact that $I_1=I_2=+\infty$ hence one cannot compute the integral $I$ of interest using the identity $I=I_1-2I_2$. A sure sign that something is wrong in your result is that $I$ integrates a nonnegative function hence one knows that $I>0$.
– Did
Jul 5, 2018 at 20:19
• A tough mistake to spot, to be sure! I couldn't figure it out, myself. Jul 5, 2018 at 20:29
• @Did, why not turn this into an answer? Jul 5, 2018 at 20:31
• @Sambo Please feel free to expand this concise comment into a full answer and to post it as such below.
– Did
Jul 5, 2018 at 20:41

The function $\lfloor \frac{2}{x} \rfloor$ is unbounded near $x = 0$ so if you try to split your integral, at best you can hope to interpret $I_1 = \int_0^1 \lfloor \frac{2}{x} \rfloor \, dx$ as an improper integral. Unfortunately, this integral actually diverges (it behaves like $\int_0^1 \frac{1}{x} \, dx$) and so is $I_2$ (this also follows from the calculations below) so you can't do all the manipulations as you are subtracting $+\infty$ from $+\infty$...

Let's see how the integrand (which I will denote by $f(x)$) behaves. Divide the interval $\left( 0, 1 \right]$ into intervals $$\cdots, \left( \frac{2}{k+1}, \frac{2}{k} \right],\cdots,\left( \frac{2}{4}, \frac{2}{3} \right], \left( \frac{2}{3}, 1 \right].$$

1. If $x \in \left( \frac{2}{k+1}, \frac{2}{k} \right]$ then $\frac{2}{x} \in [k,k+1)$ so $\lfloor \frac{2}{x} \rfloor = k$.
2. If $x \in \left( \frac{2}{k+1}, \frac{2}{k} \right]$ then $\frac{1}{x} \in [\frac{k}{2},\frac{k+1}{2})$. Now, if $k$ is even then $2\lfloor \frac{1}{x} \rfloor = 2 \frac{k}{2} = k$ while if $k$ is odd then $2 \lfloor \frac{1}{x} \rfloor = 2\frac{k-1}{2} = k - 1$.
3. Hence, we have for all $x \in (0,1]$ $$f(x) = \lfloor \frac{2}{x} \rfloor - 2 \lfloor \frac{1}{x} \rfloor = \begin{cases} 1 & x \in \left( \frac{1}{l+1}, \frac{2}{2l + 1} \right], l \geq 1, \\ 0 & \textrm{otherwise}. \end{cases}$$

Hence,

$$\int_0^1 f(x) \, dx = \lim_{n \to \infty} \int_{\frac{2}{2n+1}}^1 f(x) \, dx = \lim_{n \to \infty} \left( \sum_{l=1}^n \left( \frac{2}{2l+1} - \frac{1}{l+1} \right) \right) \\ = 2 \cdot \sum_{l=1}^{\infty} \left( \frac{1}{2l+1} - \frac{1}{2l+2} \right) = 2 \sum_{n=3}^{\infty} \frac{(-1)^{n+1}}{n} = 2 \left( \sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n} - \left( 1 - \frac{1}{2} \right) \right) = 2 \left( \ln(2) - \frac{1}{2} \right) = 2 \ln(2) - 1 = \ln(4) - \ln(e) = \ln \left( \frac{4}{e} \right)$$

where I used the Taylor series of $\ln(1 + x)$ which converges at $x = 2$ to $\ln(2)$ to evaluate the infinite sum.

\begin{align*}\int_0^1 \left( \left\lfloor \dfrac{2}{x} \right\rfloor - 2\left\lfloor \dfrac{1}{x} \right\rfloor \right)dx & = \sum_{n=1}^\infty \left[\int_{\tfrac{1}{n+1}}^{\tfrac{2}{2n+1}}\left( \left\lfloor \dfrac{2}{x} \right\rfloor - 2\left\lfloor \dfrac{1}{x} \right\rfloor \right)dx + \int_{\tfrac{2}{2n+1}}^{\tfrac{1}{n}}\left( \left\lfloor \dfrac{2}{x} \right\rfloor - 2\left\lfloor \dfrac{1}{x} \right\rfloor \right)dx \right] \\ & = \sum_{n=1}^\infty \left[ \left( \dfrac{2}{2n+1}-\dfrac{1}{n+1} \right)(2n+1-2n) + \left(\dfrac{1}{n}-\dfrac{2}{2n+1} \right)(2n-2n) \right] \\ & = \sum_{n=1}^\infty \left(\dfrac{2}{2n+1}- \dfrac{1}{n+1} \right) = \ln\left( \dfrac{4}{e} \right)\end{align*}

The mistake you made was assuming the integral could be evaluated directly over intervals of length 1/2 (because neither $I_1$ nor $I_2$ is finite). Instead, you could use an infinite number of intervals (each time that $\left\lfloor \dfrac{2}{x} \right\rfloor > 2\left\lfloor \dfrac{1}{x} \right\rfloor$, which occurs when $\dfrac{1}{n+1} < x < \dfrac{2}{2n+1}$ for any positive integer $n$ because on that interval, $2n+1=\left\lfloor \dfrac{2}{x} \right\rfloor < 2n+2$ and $2n=2\left\lfloor \dfrac{1}{x}\right\rfloor < 2n+2$).

• I'm a bit confused by your explanation. You're saying the integral can't be evaluated directly on $[0, 1/2]$? When in the asker's attempt is this done? Jul 5, 2018 at 20:20
• By not evaluated directly, I mean it must be broken into smaller intervals. You need every interval where the two values being subtracted are not equal. Jul 5, 2018 at 20:21
• Confused as well by the explanation starting at "The mistake you made" (which happens to be the only part addressing the question).
– Did
Jul 5, 2018 at 20:22
• I believed Did's explanation (which showed up as I was typing) is much clearer Jul 5, 2018 at 20:22
• @peterh Why implicitely slander downvoters? One might also wonder why a post actually not addressing the question got two upvotes, don't you think?
– Did
Jul 5, 2018 at 21:28