Generalize Integral – How Can Integral of Floor Function Be Generalized?

calculusdefinite integralsintegrationreal-analysis

Let $$I = \int_0^1 \lfloor -8x^2+6x-1 \rfloor \,\Bbb dx$$ (where $\lfloor \cdot \rfloor$ represents the floor function/greatest integer function) which on solving gives the value $$I = \frac{\sqrt{17}-13}{8} = -0.876.$$

Solving this integral took me a lot of time (manually graphing the quadratic and breaking it at integral values) and I was wondering if there can be a generalized result possible for, let $a$, $b$, $c$ be integers, $$J = \int_0^1 \lfloor ax^2+bx+c \rfloor \,\Bbb dx$$ If evaluating $J$ is not conceptually possible/correct, can there be generalized solution for [1] or [2]?

[1] $\displaystyle\int \lfloor ax^2+bx+c \rfloor \,\Bbb dx$

[2] $\displaystyle\int_n^m \lfloor ax^2+bx+c \rfloor \,\Bbb dx$ ($m$ and $n$ are integers)

Best Answer

The function $ax^2+bx+c$ can be converted into either $x^2+r$ if $a>0$ or $-x^2+r$ if $a<0$. We therefore calculate the integrals $\int_0^x \lfloor u^2+r\rfloor du$ and $\int_0^x \lfloor -u^2+r\rfloor du$ when $x\ge 0$.

Since $r=\lfloor r\rfloor +\{r\}$, without loss of generality, we assume $0\le r<1$. For calculating $\int_0^x \lfloor u^2+r\rfloor du$, we have $$ \int_0^x \lfloor u^2+r\rfloor du=\begin{cases} 0&,\quad 0\le x\le \sqrt{1-r}\\ x-\sqrt{1-r}&,\quad \sqrt{1-r}\le x\le \sqrt{2-r}\\ \sqrt{2-r}-\sqrt{1-r}+2(x-\sqrt{2-r})&,\quad \sqrt{2-r}\le x\le \sqrt{3-r}\\ \vdots\\ i(x-\sqrt{i-r})+\sum_{j=1}^{i-1}j(\sqrt{j+1-r}-\sqrt{j-r})&,\quad \sqrt{i-r}\le x\le \sqrt{i+1-r}\\ \vdots \end{cases}. $$ Therefore, for any $r\in \Bbb R$ and $x\ge 0$ we have $$ \int_0^x \lfloor u^2+r\rfloor du{ =\int_0^x \lfloor u^2+\lfloor r\rfloor +\{r\}\rfloor du \\=\int_0^x \lfloor u^2 +\{r\}\rfloor +\lfloor r\rfloor du \\=\int_0^x \lfloor u^2 +\{r\}\rfloor du +\lfloor r\rfloor x \\=\lfloor r\rfloor x+x\lfloor x^2+\{r\}\rfloor-\sum_{j=1}^{\lfloor x^2+\{r\}\rfloor} \sqrt{j-\{r\}} \\=x\lfloor x^2+r\rfloor-\sum_{j=1}^{\lfloor x^2+\{r\}\rfloor} \sqrt{j-\{r\}}. } $$ Similarly, for any $r\in \Bbb R$ and $x\ge 0$ we have $$ \int_0^x \lfloor -u^2+r\rfloor du=-x\lfloor x^2-r+1\rfloor +\sum_{j=0}^{\lfloor x^2-\{r\}\rfloor}\sqrt{j+\{r\}}. $$ By using $\int_0^x f(u)du=\text{sgn}(x)\int_0^{|x|} f(u)du$ for even $f(u)$, we can write $${ \int_0^x \lfloor u^2+r\rfloor du=x\lfloor x^2+r\rfloor-\text{sgn}(x)\sum_{j=1}^{\lfloor x^2+\{r\}\rfloor} \sqrt{j-\{r\}}, \\ \int_0^x \lfloor -u^2+r\rfloor du=-x\lfloor x^2-r+1\rfloor +\text{sgn}(x)\sum_{j=0}^{\lfloor x^2-\{r\}\rfloor}\sqrt{j+\{r\}}. } $$