# Integral of floor function: $\int \,\left\lfloor\frac{1}{x}\right\rfloor\, dx$

How would you go about solving integral of a floor? The particular problem I have is:

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

• A simple picture should help with this one: en.wikipedia.org/wiki/File:Floor_function.svg – JavaMan Apr 17 '11 at 21:37
• If $\left\lfloor x\right\rfloor$ is constant on $[n,n+1)$, then $\left\lfloor\frac{1}{x}\right\rfloor$ is constanct on ... – Rasmus Apr 17 '11 at 21:56

The function:

$$\left\lfloor\frac{1}{x}\right\rfloor$$

is equal to $n$ on the interval $\left(\frac{1}{n+1},\frac{1}{n}\right)$,so if we try to determine the integral from $t>0$ to $1$, we can let $n=\left\lfloor\frac{1}{t}\right\rfloor$ and we have constant value $1$ on range $(\frac{1}{2},1)$, constant value $2$ on range $(\frac{1}{3},\frac{1}{2})$, etc. So since $t<\frac{1}{n}$, we get terms for each interval $(\frac{1}{k+1},\frac{1}{k})$ when $k<n.$ The length of the $k$th interval is $\frac{1}{k(k+1)}$ and the value of the function is $k$ on this interval, so the integral on this interval is $\frac{1}{k+1}$. So the integral from $\frac{1}{n}$ to $1$ is $1/2 + 1/3 + 1/4 + ... + 1/n$. Then then integral from $t$ to $\frac{1}{n}$ is the length of the interval times $n$, which is $n(\frac{1}{n} - t) = 1-nt$. So the total is:

$$\int_t^1 \,\left\lfloor\frac{1}{x}\right\rfloor\, dx = 1 - t{\left\lfloor\frac{1}{t}\right\rfloor} + \sum_{i=2}^{\left\lfloor\frac{1}{t}\right\rfloor}\frac{1}{i}$$

The indefinite integral, then, is the opposite of this:

$$x\left\lfloor\frac{1}{x}\right\rfloor - \sum_{i=2}^{\left\lfloor\frac{1}{x}\right\rfloor}\frac{1}{i} + C$$

• Ah I get it, so we basically interpret the floor function as a constant. Thanks for the detailed explanation. :) – Paul Manta Apr 19 '11 at 14:54
• @PaulManta yes indeed. I never realized that's what this answer does. It's actually much more competent than the other floor-based answers. :) – The Great Duck Mar 26 '17 at 1:41

I should right off the bat say that the floor function and vertical asymptotes do not mix very well. Don't expect the answer to be reducible beyond what I give. Anyway moving on...

A floor function integral is best separated into two portions,an integral assuming that the floor function is constant everywhere and then a special sum known as the jump series that represents the portion of the graphs that are jumps.

The equation written for this is a piece wise function using iverson brackets which return $1$ when an equation inside is true and $0$ when it is false:

$$\int f(x) dx - [x > 0]*\sum_{i=0}^{JC(x)} \lim_{a \to JI(x)^+} F(a) \lim_{a \to JI(x)^-} F(a) - [x < 0]*\sum_{i=0}^{JC(x)} \lim_{a \to JI(x)^-} F(a) \lim_{a \to JI(x)^+} F(a)$$

Remember that $F(x)$ is our "faulty" integral. $\ JC$ is the number of jumps between $0$ and $x$. It gives negative numbers on the left side of $0$. $\ JI$ is $x$ coordinate of the $n$'th jump. Once again, negative to the left of $0$. $\ JC$ is traditionally the floor of the integral of the absolute value of the derivative of the function within some floor term. This is supposed to work. For this it yields:

$$\ JC(x) = floor(INF*[x > 0] - INF*[x < 0] - 1/x)$$

This is ridiculously messy and fails by divergence yet there is no concept of $\ JC$ failure so let's keep going...

$\ JI$ is traditionally the inverse of JC without floor. We can try to find the inverse...

$\ JC(y) = [y > 0]*(1/(y-INF)) + [y < 0]*(1/(y+INF))$

This is arguably messier.

At this point every alarm bell in the cosmos is going off right now. I'm not going any farther. Unfortanately this is beyond divergent sums. This is just /messy/. If you want to do asymptotes, take an integral over a range that doesn't have a divergent sum (yeah, the integral over $0$ diverges) and simply split the integral. Anything greater than $1$ is $0$ for the function you gave, anyway, so it's hardly a worthwhile example beyond showing the insane messiness that can rear it's hideous head.