1
$\begingroup$

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$.

$\endgroup$
15
  • $\begingroup$ Did you try to use the substitution $x=1/y$? $\endgroup$ Sep 19, 2020 at 5:56
  • $\begingroup$ @მამუკაჯიბლაძე How would that help me? $\endgroup$
    – DUO Labs
    Sep 19, 2020 at 20:20
  • $\begingroup$ There's something I don't understand here - $a\ \mbox{mod} (\frac{x}{b} )$ itself is elementary and has a closed form antiderivative, so why approximate it? Restricted to intervals between jumps, it's linear, and a square of a weighted sum thereof consists of pieces of parabolas. $\endgroup$ Sep 20, 2020 at 0:49
  • $\begingroup$ @MichaelEngelhardt While that is true, the square (and other integral powers) of the function does not have such a closed form antiderivative (however, if they do, I would like to know). $\endgroup$
    – DUO Labs
    Sep 20, 2020 at 1:40
  • $\begingroup$ Isn't the modulo function linear in each interval between jumps? Isn't the square of a linear function a parabola? $\endgroup$ Sep 20, 2020 at 1:55

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ While not exactly answering the question, it is the best (and only) answer given (at least so far), so as is my nature, I'll wait a day before accepting to allow for any new answers. But in the meantime, here's a +1 from me. Thanks! $\endgroup$
    – DUO Labs
    Sep 20, 2020 at 21:34
  • $\begingroup$ Since no one else responded, accepted! $\endgroup$
    – DUO Labs
    Sep 21, 2020 at 19:38
  • $\begingroup$ @DUO - I hope it helps in practice - this should be straightforward to implement computationally. $\endgroup$ Sep 21, 2020 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.