TITLE: Why does $ \int_0^1 \lceil { x\sin({1 \over x})} \rceil \,dx = 1 - \frac{\log(4)}{2\pi} $?
QUESTION [45 upvotes]: One time I was bored and played around a bit with integrals and wolfram alpha and tested the following integral: 
http://www.wolframalpha.com/input/?i=integral_0%5E1+ceil%28x*sin%281%2Fx%29%29
Note: The result at my laptop shows: $ \int_0^1 \lceil { x\sin({1 \over x})} \rceil  \,dx  = 1 - \frac{\log(4)}{2\pi} $
I was a bit surprised seeing this and wondered, if this result makes any sense and if yes, if there were an explanation, where $\frac{\log(4)}{2\pi}$ exactly comes from. The numbers look too neat to be random, so there might be a way to derive those values directly without using the help of a calculator etc. 
As always: Thanks in advance for any constructive answer/comment.

REPLY [55 votes]: 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}.
$$

REPLY [27 votes]: 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}.$$