7

What is the integral of the floor of x? Furthermore, what is the integral of a power of the floor of x? I saw in one of the answers here that:

$$ \int \;\lfloor x \rfloor dx = x\lfloor x \rfloor - \frac12 \lfloor x \rfloor(\lfloor x \rfloor + 1)\; $$

But the person did not provide a proof. I do not quite understand how they arrived at that answer. I tried Googling it, but I can't seem to find a proof. Can anyone provide one please? Additionally, can you provide how you would take the integral of a power of the floor of x, such as:

$$ \int \;\lfloor x \rfloor^n dx $$

where n is a natural number. I'd appreciate it.

Kyan Cheung
  • 3,184
  • 2
    I worked out the definite integral $\int_0^x \lfloor x \rfloor , dx$ here. – cosmo5 Apr 09 '21 at 05:51
  • @cosmo5 Thank you. I'm starting to understand, but why is there a -1 in the upper bound on the sum? And do you know how to do powers? – RJ Onyx Moonshadow Apr 09 '21 at 06:07
  • The last unit interval of first integral is $[\lfloor x \rfloor -1 , \lfloor x \rfloor]$ where the value of function is $\lfloor x \rfloor -1$. The limits in integration and summation stand for different things. No, I do not know how to do $n$th power in general. – cosmo5 Apr 09 '21 at 06:14
  • 1
    @cosmo5 Thank you so much. You have been a huge help. The next step is figuring out the nth power. – RJ Onyx Moonshadow Apr 09 '21 at 06:19

2 Answers2

9

If $F(b)$ is the antiderivative of $\lfloor b\rfloor$, then

$$F(b)-F(0)=\int_0^b\lfloor x\rfloor dx$$ $$=\sum_{n=0}^{\lfloor b\rfloor-1}\int_n^{n+1}\lfloor x\rfloor dx+\int_{\lfloor b\rfloor}^b\lfloor x\rfloor dx$$ $$=\sum_{n=0}^{\lfloor b\rfloor-1}n+\int_{\lfloor b\rfloor}^b\lfloor b\rfloor dx$$ $$=\frac{\lfloor b\rfloor(\lfloor b\rfloor-1)}2+\lfloor b\rfloor(b-\lfloor b\rfloor)$$ $$=\frac{\lfloor b\rfloor(\lfloor b\rfloor-1)+2\lfloor b\rfloor(b-\lfloor b\rfloor)}2$$ $$=\frac{\lfloor b\rfloor(2b-\lfloor b\rfloor-1)}2$$ $$=\lfloor b\rfloor b-\frac{\lfloor b\rfloor(\lfloor b\rfloor+1)}2$$

If we define $F(0)=0$, then we have $F(b)=\lfloor b\rfloor b-\frac{\lfloor b\rfloor(\lfloor b\rfloor+1)}2$.


Similarly, if $F(b)$ is the antiderivative of $\lfloor b\rfloor^n$, then:

$$F(b)-F(0)=\int_0^b\lfloor x\rfloor^n dx$$ $$=\sum_{i=0}^{\lfloor b\rfloor-1}\int_i^{i+1}\lfloor x\rfloor^n dx+\int_{\lfloor b\rfloor}^b\lfloor x\rfloor^n dx$$ $$=\sum_{i=0}^{\lfloor b\rfloor-1}i^n+\int_{\lfloor b\rfloor}^b\lfloor b\rfloor^n dx$$ $$=\sum_{i=0}^{\lfloor b\rfloor-1}i^n+(b-\lfloor b\rfloor)\lfloor b\rfloor^n$$

Using robjob's Hockey-Stick Identity: $$\newcommand{\stirtwo}[2]{\left\{#1\atop#2\right\}}$$ $$\sum_{i=0}^{\lfloor b\rfloor-1}i^n=\sum_{j=0}^n\binom{\lfloor b\rfloor}{j+1}\stirtwo{n}{j}j!$$

Where $\stirtwo{m}{j}$ are Stirling Numbers of the Second Kind.

Hence,

$$F(b)-F(0)=\sum_{j=0}^n\left[\binom{\lfloor b\rfloor}{j+1}\stirtwo{n}{j}j!\right]+(b-\lfloor b\rfloor)\lfloor b\rfloor^n$$

If $F(0)=0$, then

$$F(b)=\sum_{j=0}^n\left[\binom{\lfloor b\rfloor}{j+1}\stirtwo{n}{j}j!\right]+(b-\lfloor b\rfloor)\lfloor b\rfloor^n$$


Alternately, applying the more well-known but less compact Faulhaber's formula:

$$\sum_{i=0}^{\lfloor b\rfloor-1}i^n= \frac{(\lfloor b\rfloor-1)^{n+1}}{n+1}+\frac12(\lfloor b\rfloor-1)^n+\sum_{k=2}^n \frac{B_{k}}{k!}\frac{n!}{(n-k+1)!}(\lfloor b\rfloor-1)^{n-k+1}$$

Where $B_k$ is the $k$th Bernoulli number.

Hence,

$$F(b)-F(0)=\frac{(\lfloor b\rfloor-1)^{n+1}}{n+1}+\frac12(\lfloor b\rfloor-1)^n+\sum_{k=2}^n\left[\frac{B_{k}}{k!}\frac{n!}{(n-k+1)!}(\lfloor b\rfloor-1)^{n-k+1}\right]+(b-\lfloor b\rfloor)\lfloor b\rfloor^n$$

If we let $F(0)=0$, then

$$F(b)=\frac{(\lfloor b\rfloor-1)^{n+1}}{n+1}+\frac12(\lfloor b\rfloor-1)^n+\sum_{k=2}^n\left[\frac{B_{k}}{k!}\frac{n!}{(n-k+1)!}(\lfloor b\rfloor-1)^{n-k+1}\right]+(b-\lfloor b\rfloor)\lfloor b\rfloor^n$$

Kyan Cheung
  • 3,184
  • This is awesome. I'm not familiar with Faulhaber's formula so I will have to study it. My only concern here is: is there a way to simplify this so that it does not include the $$\sum$$ or $$\prod$$? Thank you so much! – RJ Onyx Moonshadow Apr 09 '21 at 06:28
  • 1
    @RJOnyxMoonshadow No, you need the $\sum$. However, you can use alternative notation to represent the product (i.e. using the falling factorial or the quotient of two factorials, see the Wiki page on Faulhaber's formula). However, the falling factorial is a bit obscure, and the factorial has ambiguous definition for non integer $n$, so I would prefer not using either and use product notation instead. If you want, you can switch out the product. – Kyan Cheung Apr 09 '21 at 06:32
  • 2
    I'm not a huge fan of Faulhaber's formula--the Bernoulli numbers alternate in sign, so there's cancellation, and they're comparatively mysterious. I prefer one based on Stirling numbers of the second kind. Those have simple combinatorial meaning and a simple two-term recurrence relation. See robjohn's last formula here: https://math.stackexchange.com/questions/2035188/methods-to-compute-sum-k-1nkp-without-faulhabers-formula – Joshua P. Swanson Apr 09 '21 at 09:02
  • 1
    @Joshua P. Swanson Thanks for that link. I wasn't aware that there were alternate representations of $\sum k^p$. I'll look through it. – Kyan Cheung Apr 09 '21 at 09:04
  • I just want to thank you all for answering my question. This was a huge help. Although, as I said before, I wish there was a simple answer that did not involve a sum or product. The only question I have left is what if we have something more complicated in the floor than just x, like a fraction or a log or a power or an exponential? Anyway, I just wanted to say I appreciate you all! – RJ Onyx Moonshadow Apr 12 '21 at 05:35
  • Separate the integral into multiple integrals with bounds such that $\lfloor f(x)\rfloor$ is constant. – Kyan Cheung Apr 13 '21 at 12:49
5

When you are integrating the floor function, you are essentially adding rectangles

$$\int_0^x \lfloor t\rfloor dt = \int_0^10dt + \int_1^21dt + \int_2^32dt + ... + \int_{{\lfloor x \rfloor}-1}^{\lfloor x \rfloor}(\lfloor x \rfloor -1)dt + \int_{\lfloor x \rfloor}^{x} \lfloor x \rfloor dt$$

$$ = 0 + 1 + 2 + ... + \lfloor x \rfloor-1 + \lfloor x \rfloor(x-\lfloor x \rfloor) $$