Compute $\int_{0}^{1}\left[\frac{2}{x}\right]-2\left[\frac{1}{x}\right]dx$

We have $$\left\lfloor \dfrac1x \right\rfloor = n \text{ if }x \in \left(\dfrac1{n+1}, \dfrac1n\right]$$ $$\left\lfloor \dfrac2x \right\rfloor = \begin{cases}2n+1 & \text{ if }x \in \left(\dfrac1{n+1}, \dfrac1{n+1/2}\right] \\ 2n & \text{ if }x \in \left(\dfrac1{n+1/2}, \dfrac1{n}\right] \end{cases}$$ We hence have $$\left\lfloor \dfrac2x \right\rfloor - 2 \left\lfloor \dfrac1x \right\rfloor = \begin{cases} 1 & \text{ if }\left(\dfrac1{n+1}, \dfrac1{n+1/2}\right] \\ 0 & \text{ if }x \in \left(\dfrac1{n+1/2}, \dfrac1{n}\right] \end{cases}$$ Hence, $$\int_0^1 \left( \left\lfloor \dfrac2x \right\rfloor - 2 \left\lfloor \dfrac1x \right\rfloor\right) dx = \sum_{n=1}^{\infty} \left(\dfrac1{n+1/2} - \dfrac1{n+1}\right) = 2\log2-1$$

One way to evaluate $$\sum_{n=1}^{\infty} \left(\dfrac1{n+1/2} - \dfrac1{n+1}\right)$$ is as follows. We have $$f(x) = \sum_{n=1}^{\infty} \left(x^{n-1/2} - x^{n} \right) = \sum_{n=1}^{\infty} x^{n-1}\left(\sqrt{x} -x\right) = \dfrac{\sqrt{x}-x}{1-x} = \dfrac{\sqrt{x}}{1+\sqrt{x}}$$ Now we have $$\int_0^1 f(x) dx = \sum_{n=1}^{\infty} \left(\int_0^1 x^{n-1} dx - \int_0^1 x^{n-1/2} dx\right) = \sum_{n=1}^{\infty} \left(\dfrac1n - \dfrac1{n+1/2}\right)$$ We also have \begin{align} \int_0^1 f(x) dx & = \int_0^1 \dfrac{\sqrt{x}dx}{1+\sqrt{x}} = \int_0^1 \dfrac{2t^2dt}{1+t} = 2\int_0^1 \dfrac{dt}{1+t} + 2\int_0^1 \dfrac{(t^2-1)dt}{1+t}\\ & = 2 \log(2) + 2 \int_0^1 (t-1) dt= 2\log(2)-1 \end{align}


You just have to figure out where the integrand is nonzero. In this case, the integrand really takes the value

$$\left\lfloor \frac{2}{x} \right\rfloor - 2\left \lfloor \frac{1}{x} \right\rfloor = \begin{cases} \\0 & x \in \left [ \frac{2}{2 n+1},\frac{2}{2 n}\right )\\ 1 & x \in \left [ \frac{2}{2 n},\frac{2}{2 n-1}\right ) \end{cases}$$

for $n \ge 1$ and $x \in [0,1]$. Here is a plot generated in Mathematica:

floorplot

Thus, the integral is just a sum of the interval lengths over which the integrand has the value of $1$:

$$\begin{align}\int_0^1 dx \, \left ( \left\lfloor \frac{2}{x} \right\rfloor - 2\left \lfloor \frac{1}{x} \right\rfloor \right ) &= \frac{2}{3} - \frac{2}{4} + \frac{2}{5} - \frac{2}{6} + \ldots \\ &= 2 \left [ \sum_{k=1}^{\infty} \frac{(-1)^{k+1}}{k} - \frac12 \right ]\\ &= 2 \log{2} - 1\end{align}$$

Tags:

Integration