Evaluate: $\int_{-n}^n max \{x+|x|,x-[x]\} \mathrm{d}x$ where $[x]$ is the floor function  When $x > 0$ we see that $x+|x| = 2x$.  Let $k \leq x < k+1, k = 0,1,2,.........,n-1$ $\Rightarrow [x] = k, therefore, x-[x] = x-k$  $So, x+|x| = 2x > x - k = x-[x] \Rightarrow max \{x+|x|,x-[x]\} = 2x$  $\int_{0}^n max \{x+|x|,x-[x]\} \mathrm{d}x = 2 \int_{0}^n x \mathrm{d}x = x^2|_{0}^{n^2} = n^2 \dots (A)$  When $x < 0$ we see that $x+|x| = x-x = 0$.  Let $-(k+1) \leq x < -k, k = 0,1,2,.........,n-1$ $\Rightarrow [x] = -(k+1), therefore, x-[x] = x+(k+1)$  $So, x+|x| = 0 < x + (k+1) = x-[x] \Rightarrow max \{x+|x|,x-[x]\} = x-[x]$  $\int_{-(k+1)}^{-k} max \{x+|x|,x-[x]\} \mathrm{d}x = \int_{-(k+1)}^{-k} x+(k+1) \mathrm{d}x$  $\int_{-n}^0 max \{x+|x|,x-[x]\} \mathrm{d}x$=  $\int_{-n}^{-(n-1)} x+(k+1) \mathrm{d}x + \int_{-(n-1)}^{-(n-2)} x+(k+1) \mathrm{d}x +\dots+ \int_{-1}^{0} x+(k+1) \mathrm{d}x= \sum_{k=0}^{n-1} \int_{-(k+1)}^{-k} x+(k+1) \mathrm{d}x$  $= \int_{-n}^0 x \mathrm{d}x+\sum_{k=0}^{n-1} \int_{-(k+1)}^{-k} (k+1) \mathrm{d}x = {{-n^2} \over {2}}+\sum_{k=0}^{n-1} (k+1) x|_{-(k+1)}^{-k} = {{-n^2} \over {2}}+\sum_{k=0}^{n-1} (k+1) = {{-n^2} \over {2}} + {{n(n+1) \over {2}}} \dots (B)$ Adding A and B we have, $\int_{-n}^0 max \{x+|x|,x-[x]\} \mathrm{d}x + \int_{0}^n max \{x+|x|,x-[x]\} \mathrm{d}x =$ $\int_{-n}^n max \{x+|x|,x-[x]\} \mathrm{d}x = {{-n^2} \over {2}} + {{n(n+1) \over {2}}} + n^2 = {{n^2} \over {2}} + {{n(n+1) \over {2}}}$