[Math] Indefinite Integral of Modulo Function

integration

By defining the modulo function with the floor function:

$$ x \bmod y = x – y \left\lfloor \frac xy \right\rfloor $$

Is it possible to find the antiderivative of the Modulo function?
I attempted at integrating with the and approximate indefinite integral of the floor function, but completely got lost due to my limited knowledge in calculus.

Can someone explain to me how this will or will not work?

Best Answer

Between $0$ and $y$ it is easy enough to integrate; you get $\frac12x^2+C$.

Since the integrand is periodic, the integral in the other periods is just a translated version of the integral in the base period, with the constants of integration chosen such that neighboring periods fit together. The translation is excatly what the modulo operation itself does, so we'll get something like $$ \frac12(x\bmod y)^2 + \frac{y^2}2\left\lfloor \frac xy\right\rfloor + C $$ Here $\frac{y^2}2$ is the integral of one period (and therefore the amount we need to raise the side-translated next period to fit), and $\lfloor x/y\rfloor$ counts how many periods to the right of the base period we are.

Related Question