# How can $\int_0^1 \lfloor ax^2+bx+c \rfloor \,\Bbb dx$ be generalized?

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)

• It seems like $\frac{d}{dx} x\lfloor{ax^2 + bx + c\rfloor} = \lfloor{ax^2 + bx + c\rfloor}$ (where the function is differentiable, of course), so perhaps $\int \lfloor{ax^2 + bx + c\rfloor}dx = x\lfloor{ax^2 + bx + c\rfloor} + C$. Commented May 1, 2023 at 21:50
• No, your function is not continuous and it needs to be absolutely continuous to be the integral of its derivative. Take the example of the OP and you'll see it doesn't work. Commented May 16, 2023 at 7:45
• should not be able to give a closed solution, because if the value changes drastically, it will end up with $\sum\sqrt{k}$ form Commented May 19, 2023 at 13:14

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\}}. }$$

• Worth noting that by using Riemann-Stieltjes integral, as demonstrated here, the induction step can be deduced rather painlessly. Commented May 16, 2023 at 4:18

I do not know if this helps, but this was too long for a comment.

Well, using the fact that:

$$\left\lfloor x\right\rfloor=x-\frac{1}{2}+\frac{1}{\pi}\sum_{n\ \geq\ 1}\frac{\sin\left(2\pi nx\right)}{n}\tag1$$

So, we get:

\begin{align} \mathcal{I}\left(\alpha,\beta,\gamma\right)&=\int\limits_0^1\left\lfloor \alpha x^2+\beta x+\gamma\right\rfloor\,\Bbb dx\\ &=\int\limits_0^1\left(\alpha x^2+\beta x+\gamma-\frac{1}{2}+\frac{1}{\pi}\sum_{n\ \geq\ 1}\frac{\sin\left(2\pi n\left(\alpha x^2+\beta x+\gamma\right)\right)}{n}\right)\,\Bbb dx\\ &=\frac{\alpha}{3}+\frac{\beta}{2}+\gamma-\frac{1}{2}+\frac{1}{\pi}\sum_{n\ \geq\ 1}\frac{1}{n}\int\limits_0^1\sin\left(2\pi n\left(\alpha x^2+\beta x+\gamma\right)\right)\,\Bbb dx\tag2 \end{align}

• @User0 See Fresnel integrals Commented May 15, 2023 at 16:05

Let $$f(x)=ax^2+bx+c$$ be a quadratic. The floor function can be written as

$$\lfloor x \rfloor=\sum_{n=1}^\infty \theta(x-n)-\sum_{n=0}^\infty \theta(-x-n)$$ where $$\theta(x)=1$$ if $$x\ge0$$ and $$\theta(x)=0$$ otherwise.

This transforms the integral into a sum

$$\int_\alpha^\beta \lfloor f(x) \rfloor dx= \sum_{n=1}^\infty \int_\alpha^\beta\theta(f(x)-n) dx-\sum_{n=0}^\infty \int_\alpha^\beta\theta(-f(x)-n) dx$$

Each integral appearing in this sum measures the size of the solution set (in $$[\alpha,\beta]$$) to $$f(x)\ge n$$ or $$f(x)\le -n$$ for $$n>0$$. For a quadratic, $$f(x)=ax^2+bx+c$$ let $$r_1,r_2$$ be the two roots of $$f(x)-n=0$$. Then the solutions to $$f(x)\ge n$$ or $$f(x)\le -n$$ are either $$[r_1,r_2]$$ or $$\mathbb{R}\setminus[r_1,r_2]$$ according to the sign of $$a$$. The roots can of course be written in terms of the coefficients $$a,b,c$$ using the quadratic formula.

Let's see how this works in your example, $$f(x)=-8x^2+6x-1$$. In this case, the stationary point is at $$(\frac{3}{8},\frac{17}{8})$$ so $$f(x)\ge n$$ has no solutions for $$n>0$$. Moreover, for $$n>2$$, $$f(x)\le -n$$ has no solutions in $$[\alpha,\beta]=[0,1]$$. Therefore, the whole thing is a sum of just a few terms:

\begin{align*} -8x^2+6x-1\le 0 & \iff x\in [0,1]\setminus(\frac{1}{4},\frac{1}{2})\\ -8x^2+6x-1\le -1 & \iff x\in [0,1]\setminus(0,\frac{3}{4})\\ -8x^2+6x-1\le -2 & \iff x\in [0,1]\setminus(\frac{3-\sqrt{17}}{8},\frac{3+\sqrt{17}}{8})\\ \end{align*} To get the answer, you add the negative length of each solution-set. So, \begin{align*} \int_\alpha^\beta \lfloor -8x^2+6x-1 \rfloor dx&=-\left(1-\left(\frac{1}{2}-\frac{1}{4}\right)\right)-\left(1-\left(\frac{3}{4}-0\right)\right)-\left(1-\left(\frac{3+\sqrt{17}}{8}-\frac{3-\sqrt{17}}{8}\right)\right)\\ &=-\frac{3}{4}-\frac{1}{4}-\frac{4-\sqrt{17}}{4}\\ &=\frac{-8+\sqrt{17}}{4} \end{align*}