I'm working on a project where I'm working with modulo functions. However, to continue, I need to integrate integral powers of a weighted sum of them (e.g of the form $\left(c+\operatorname{weighted sum} \right)^p$, with $c$ a real, positive constant, and $p \in \mathbb{Z}$). So, I first tried Fourier series. However, since the weights are pretty high, the errors blew up, and the amount of terms necessary to correct them are prohibitively high. So, I need another way to create the modulo functions.


This leads me to my question: just like the title says, is there some approximation of $a \operatorname{mod} \left(\frac xb,1 \right)$, $f(x)$ (with $a,b, \geq 1, \in \mathbb{R}$), that has an elementary, closed form antiderivative, has a scaling constant $N$ so that as $N \to \infty$, $|a \operatorname{mod} \left(\frac xb,1 \right)-f(x)| \to 0$ (hopefully $\sim \mathcal{O} \left(10^{-\operatorname{|poly(N)|}}\right)$, but not neccessary) at least on $\{ bk+0.1 \leq x \leq bk+0.9, k=\{0,1,2,3..,\lceil \frac nb \rceil\}\}$, with $n \in \mathbb{R}$ (but hopefully over all $x \in [0,n]$), and has a constant number of terms $k$ that independent of $N,n,a,b$.



How do you make an accurate, integrable approximation of $a \operatorname{mod} \left(\frac xb,1 \right)$ with a scaling constant $N$?
Let's consider the concrete example given by the OP in comments,
$$
f(x) = \left( 4\ \mbox{mod} \left( \frac{x}{5} ,1\right) + 10\ \mbox{mod} \left( \frac{x}{33} ,1\right) \right)^{p} \ .
$$
$f(x)$ is periodic with period $5\cdot 33 = 165$. It is discontinuous at the points $\{ 5n : n\in \mathbb{Z} \} \cup \{ 33n : n\in \mathbb{Z} \} $; these can be easily listed and sorted in ascending order within any integration range one may be interested in (and for a periodic example such as this, it's of course sufficient to be able to treat one period). The entire integral of $f$ can be assembled by summing up the integrals over individual intervals between consecutive discontinuities, for all such intervals contained in the integration range one is interested in.


Consider an arbitrary such interval, $[d\_i ,d\_{i+1} ]$, where the $d\_i $ denote the discontinuities. On this interval (caveat - for negative $x$, one might have to specify exactly how one interprets the mod function),
$$
f(x) = \left( 4\ \mbox{mod} \left( \frac{d\_i }{5} ,1\right) + 10\ \mbox{mod} \left( \frac{d\_i}{33} ,1\right) + \left( \frac{4}{5} + \frac{10}{33} \right) (x-d\_i ) \right)^{p} \ .
$$
or, to streamline the notation,
$$
f(x) = (s+tx)^p
$$
and one has the integral
$$
\int\_{d\_i}^{d\_{i+1} } dx\, f(x) = \frac{(s+td\_{i+1} )^{p+1} }{t(p+1)} - \frac{(s+td\_i )^{p+1} }{t(p+1)}
$$
It remains to sum up these contributions; note that the first and the last interval may be only partially integrated over and then the lower or upper integration limits, respectively, have to be appropriately adjusted.


