Why does $ \int_0^1 \lceil { x\sin({1 \over x})} \rceil \,dx = 1 - \frac{\log(4)}{2\pi} $?

Solution 1:

The ceiling function gives one iff $\sin(1/x)> 0$, otherwise zero. So the integral is just a sum of interval lengths where the sin is positive, i.e. $$ \left(1-\frac{1}{\pi}\right)+\left(\frac{1}{2\pi}-\frac{1}{3\pi}\right)+\left(\frac{1}{4\pi}-\frac{1}{5\pi}\right)+\ldots=1-\frac{1}{\pi}\left(1-\frac12+\frac13-\frac14+\ldots\right)=\\ =1-\frac{1}{\pi}\ln(1+1)=1-\frac{\ln(2)}{\pi}. $$

Solution 2:

Note that $x \sin(1/x) \in [-1, 1]$ when $x \in [0,1]$ so your integral is the volume of the set on which $x \sin(1/x) > 0$. This set is

$$\left(\frac{1}{\pi}, 1\right) \cup \bigcup_{k=1}^{\infty}\left(\frac{1}{\pi (2k+1)}, \frac{1}{2\pi k}\right)$$ and its volume is $$1 - \frac{1}{\pi} + \sum_{k=1}^{\infty}\left(\frac{1}{2\pi k} - \frac{1}{\pi (2k+1)}\right)=1+\sum_{k=1}^{\infty} \frac{(-1)^k}{\pi k} = 1 - \frac{\log(2)}{\pi}.$$