# Integration of some floor functions

Can anyone please answer the following questions ?

1) $\int\left \lfloor{x}\right \rfloor dx$

2) $\int$ $\left \lfloor{\sin(x)}\right \rfloor$ $dx$

3) $\int_0^2$ $\left \lfloor{x^2+x-1}\right \rfloor$ $dx$

4) $\int_o^\pi$ $\left \lfloor{x(1+\sin(\pi x)}\right \rfloor$

Also can anyone please make me understand the way in which to proceed in these types of sums?

$\left \lfloor{x}\right \rfloor$ is the floor function

Thanks

• Do you know the definition of $\lfloor x \rfloor$? – Mhenni Benghorbal Aug 13 '14 at 18:19
• Its in wikipedia. Check it out...en.wikipedia.org/wiki/Floor_and_ceiling_functions – NeilRoy Aug 13 '14 at 18:28
• what are the born integration of 1) and 2) ? – idm Aug 13 '14 at 18:28
• @neil_roy: Me myself I know it. I am just asking you because you are the one who is asking! Check this. – Mhenni Benghorbal Aug 13 '14 at 18:33

A related problem. I'll do number $(3)$. Note that for $n \in \mathbb{N}$ we have

$$n \leq x < n+1$$

$$\implies n^2 \leq x^2 < (n+1)^2$$

$$\implies n^2+n-1 \leq x^2+x-1 < (n+1)^2 +(n+1)-1$$

which yields

$$\lfloor{ x^2+x-1} \rfloor = n^2+n-1, \quad n \leq x < n + 1 .$$

Now, we go back to the integral

$$I = \int_{0}^{1}(-1) dx + \int_{1}^{2}(1) dx = 0.$$

Note: I believe You can generalize the above process for any polynomial $p(x)$.

• I think you may have made a mistake. If $x=1.6$ and $n=1$ we have $\lfloor{ 1.6^2+1.6-1} \rfloor = 3$, but $1^2 + 1 - 1 = 1$. Therefore, in this case $\lfloor{ x^2+x-1} \rfloor \neq n^2+n-1$ – Andrew Oct 7 '17 at 19:09

The floor function turns continuous integration problems in to discrete problems, meaning that while you are still "looking for the area under a curve" all of the curves become rectangles. In general, the process you are going to want to take will go something like this:

Consider the function (before taking the floor of it), and look at where the output is an integer. For instance, in your first example $f(x)=x$, $f(x)$ equals an integer when an integer is put in. The next step is to look at what happens between these points. Again considering your first example, for $1 \leq x < 2$, the floor function maps everything to 1, so you end up with a rectangle of width 1 and height 1. It is the areas of these rectangles you need to add to find the value of the integral (being careful to understand that rectangles below the x-axis have "negative areas").

In the case of the indefinite integrals you will end up with some summation since you don't know the bounds, on the others you should be able to find exact numerical answers.

I will show you how to perform the integral given by $3)$ on a slightly rough way.

• We know that $p(x) = x^2 + x-1$ lies between $(-1,5)$ when $x \in (0,2)$ and, furthermore, $p$ is monotone increasing in this interval.

• When applied to $p(x)$, the floor function gives us the greatest integer less than or equal to $x$, so it makes a good idea to compute for what values of $x$, $p(x)$ reach an integer value $p \in (-1,5)$. We have: \begin{array}{|c|c|} \hline p(x) & x \\ \hline -1 & 0 \\ 0 & \frac{1}{2} \left(-1+\sqrt{5}\right) \\ 1 & 1 \\ 2 & \frac{1}{2} \left(-1+\sqrt{13}\right) \\ 3 & 1/2 (-1 + \sqrt{17}) \\ 4 & 1/2 (-1 + \sqrt{21}) \\ 5 & 2 \\ \hline \end{array} where we have solved $p(x) = p^* = -1,0,\ldots,5,$ on each table entry.

• Now, we can see that: $$\color{blue}{\int^2_0 \lfloor p(x) \rfloor \, \mathrm{d}x = \sum_{i=0}^5 (x^*_{i+1} -x^*_i) p^*_i},$$ where $x^*_i$ are the corresponding values satisfying $p(x^*) = p^*$. I hope this gives you some ideas of what's going on.

Cheers!

I'm sure a plot of both $p(x)$ and $\lfloor p(x) \rfloor$ makes things clearer: $$\lfloor sinx\rfloor$$ is equal to either 0 or 1 or -1, so integrating it should be simple

• Why can't it be -1? – Kyle Delaney Dec 12 '15 at 6:14
• of course, fixed it, thank you Kyle Delaney – Asier Calbet Dec 13 '15 at 11:46

It seems to me that integrating the floor function gives you triangular numbers when the input is a whole number. So for those cases, you can use the triangular number formula but with $x-1$ instead of $x$ because the values are shifted to the right in this case.

$$\frac{(x-1)^2+(x-1)}2$$

Then to account for the portion of $x$ in between whole numbers, we do this:

$$\frac{(\lfloor x\rfloor-1)^2+(\lfloor x\rfloor-1)}2+(x-\lfloor x\rfloor)\lfloor x\rfloor$$

For negative integers, we have:

$$\frac{-(x-1)^2-(x-1)}2$$

And again we add on the non-integer portion:

$$\frac{-(\lfloor x\rfloor-1)^2-(\lfloor x\rfloor-1)}2-(x-\lfloor x\rfloor)\lfloor x\rfloor$$

It looks like the function for negative values of $x$ is the same as the function for positive values, but multiplied by $-1$. So if we want one function to be the answer for problem #1, we can have:

$$sgn(x)\left(\frac{(\lfloor x\rfloor-1)^2+(\lfloor x\rfloor-1)}2+(x-\lfloor x\rfloor)\lfloor x\rfloor\right)$$