# 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
That integral isn't correct. That sum should be adding up the length of jump discontinuities according to your form but it's not it doesn't seem right. -1/x + INF would be the number of jumps from 0 to x, and the length of any single jump isn't 1/x. Mind clarifying this solution better with that taken into consideration. I think your somehow doing something superior to deal with asymptotic divergence but I'm not sure what. – TheGreatDuck May 2 at 7:32
I'm thinking you forgot negative t's for one. And you also might have been right with the first answer. Why the "opposite"? – TheGreatDuck May 2 at 7:35
I might be wrong, but isn't x*floor(x) impossible to make continuous? It has the same general form and flow of 1/x so I would think making it continuous is literally impossible. – TheGreatDuck May 5 at 5:56
It can't be made continuous at $x=0$. So? Neither can the integrand. There are jump discontinuities which are covered by the $\sigma$ part of the definite integral. @TheGreatDuck – Thomas Andrews May 5 at 12:00

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 us the number of jumps betwee 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.

-