Compute $\int_{0}^{1}\left[\frac{2}{x}\right]-2\left[\frac{1}{x}\right]dx$
Solution 1:
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}
Solution 2:
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:
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}$$
Solution 3:
Hint: If you start drawing this function, you will see that this integral can be expressed as a discrete (but infinite) sum of areas. So rather than evaluating an integral, you can evaluate a series instead. Finding that series is a big part of this problem.
Solution 4:
Here is another solution using some advanced concept:
Let $I$ denote the integral in question. With the substitution $x \mapsto \frac{1}{x}$, we have
$$ I = \int_{1}^{\infty} \frac{[2x] - 2[x]}{x^2} \, dx. $$
Now performing the integration by parts,
\begin{align*} I &= \left[ - \frac{[2x] - 2[x]}{x} \right]_{1^{-}}^{\infty} + \int_{1^{-}}^{\infty} \frac{1}{x} d([2x] - 2[x]) \\ &= 1 + \lim_{n \to \infty} \int_{1^{-}}^{n^{+}} \frac{1}{x} d([2x] - 2[x]) \\ &= 1 + \lim_{n \to \infty} \left( \int_{1^{-}}^{n^{+}} \frac{1}{x} d[2x] - 2 \int_{1^{-}}^{n^{+}} \frac{1}{x} d[x] \right) \\ &= 1 + 2 \lim_{n \to \infty} \left( \int_{2^{-}}^{2n^{+}} \frac{1}{x} d[x] - \int_{1^{-}}^{n^{+}} \frac{1}{x} d[x] \right) \\ &= 1 + 2 \lim_{n \to \infty} \left( \sum_{k=2}^{2n} \frac{1}{k} - \sum_{k=1}^{n} \frac{1}{k} \right) \\ &= 1 + 2 \lim_{n \to \infty} \left(-1 + \sum_{k=1}^{n} \frac{1}{n+k} \right) \\ &= 2 \log 2 - 1. \end{align*}