# Integrating the floor of a function

The integral that I'm trying to simplify is this: (both $x$ and $c$ are natural numbers, if that helps)

$$\mathrm{F}\left(x,c\right) \equiv \int_{0}^{c}\left\lbrace\vphantom{\LARGE A}% \left\lfloor 10^{-\lfloor t \rfloor} x \right\rfloor - 10\left\lfloor 10^{-\lfloor t \rfloor - 1}x\right\rfloor \right\rbrace^{2}\, \mathrm{d}t$$

I know this is fairly ugly, please let me know if I need to modify it for the question. Thank you.

Edit: This integral came from the following sum:

$$\sum_{n = 0}^{c}\left\lbrace\vphantom{\LARGE A}% \left\lfloor 10^{-n} x \right\rfloor - 10\left\lfloor 10^{-n - 1}x \right\rfloor \right\rbrace^{2}$$

Is there a way to simplify either that does not lead to a different sum ?.

• If I am right, this computes the sum of the $c$ rightmost digits of $x$, squared. – Yves Daoust May 31 '16 at 20:38
• Have you tried out a few test values of $x$ and $c$ to see what's happening? – Fimpellizieri May 31 '16 at 20:38
• I think you'll find this answer very helpful. math.stackexchange.com/questions/360323/… – Mathemagician1234 May 31 '16 at 20:47
• Yves Daoust, that is precisely what this does. C would be the number of non-fractional digits of the number – diligar Jun 1 '16 at 19:03

As $\lfloor t\rfloor$ remains constant between two integers, you can rewrite the integral as a simple sum
$$\int_0^c \left(\left\lfloor 10^{-\lfloor t \rfloor} x \right\rfloor -10\left\lfloor 10^{-\lfloor t \rfloor-1}x \right\rfloor \right)^2 dt=\sum_{t=0}^{c-1} \left(\left\lfloor 10^{-\lfloor t \rfloor} x \right\rfloor -10\left\lfloor 10^{-\lfloor t \rfloor-1}x \right\rfloor \right)^2.$$
Now you can find the relation of the summand to the decimal representation of $x$.
The integrand is $$f(x,t) = \left\lfloor 10^{-\lfloor t \rfloor} x \right\rfloor -10\left\lfloor 10^{-\lfloor t \rfloor-1}x \right\rfloor$$ so for $x \in \mathbb{N}$, $x = (d_{m-1}\dotsb d_0)_{10}$ this gives $$f(x,t)\vert_{t\in[0,1)} = \left\lfloor x \right\rfloor -10\left\lfloor 10^{-1}x \right\rfloor = d_0$$ which is the last digit of $x$. Further $$f(x,t)\vert_{t\in[1,2)} = \left\lfloor 10^{-1} x \right\rfloor -10\left\lfloor 10^{-2}x \right\rfloor = d_1$$ to $$f(x,t)\vert_{t\in[m-1,m)} = \left\lfloor 10^{-(m-1)} x \right\rfloor -10\left\lfloor 10^{-(m-1)-1}x \right\rfloor = d_{m-1}$$ and $$f(x,t)\vert_{t\in[m,m+1)} = \left\lfloor 10^{-m} x \right\rfloor -10\left\lfloor 10^{-m-1}x \right\rfloor = 0$$ This gives $$F(x,c) = \int\limits_0^c f(x,t)^2 \,dt = \sum_{i=0}^{c-1} \left( f(x,t)\vert_{t\in[i,i+1)} \right)^2 = \begin{cases} \sum\limits_{i=0}^{c-1} d_i^2 & ; c \le m \\ \sum\limits_{i=0}^{m-1} d_i^2 & ; c > m \end{cases}$$
• the condition $x \in \mathbb{N}$ can be relaxed, and consider the digits of the decimal representation of $x$ before the point. – G Cab May 31 '16 at 22:42
• Yes, I think it would work for non-negative real $x$. – mvw May 31 '16 at 23:02