How to define mod without using integer division or rounding My brother asked me what the definition of mod was, and I gave him the usual spiel about it being the "remainder" of division. However, he wanted a definition of mod based on functions he understood.
He's told me that he has an inherent sense of most basic operators (+, -, /, *, ^, log), but not the sorts of ones that I brought up at first when trying to define mod (ceil, floor, integer division). However, he also feels like he has a good understanding of trig as well, so basic trig functions are generally permitted (sin, cos, tan, arcsin, arccos, arctan) alongside usage of $\pi$.
Is it possible to define $a \pmod b$ in terms of these more elementary operators?
(Again, the list is: +, -, /, *, ^, log, sin, cos, tan, arcsin, arccos, arctan, $\pi$.)
I believe I have a solution using tan and arctan which I will post as an answer, so I'm especially curious about solutions that don't use trig functions, or a proof that it's impossible to do without the trig functions.
From a mathematics perspective, I'm particularly curious about answers to this question because each one of these definitions will likely have an extension into negatives or imaginary numbers that will give interesting extrapolations that our usual definition of "remainder" is difficult to bring to bear in those situations.
(As an additional note, the solution shouldn't just define mod as an "infinite piecewise function." In other words, the solution can be piecewise, it just can't have infinite pieces.)
EDIT:
As mentioned in the comments under my answer, I should also allow piecewise functions that check for domain and range. As L.F. put it, functions in the form "$f(x)$ if $x \in \mathrm{dom}(f)$, or $g(x)$ otherwise" are also permitted. (My brother does have an inherent understanding of domains and ranges.)
 A: The solution I found was to use the repeating nature of tangent in order to create a mod function.
The tangent function has a period of $\pi$, but it starts at this awkward $-\frac{\pi}{2}$. So the first thing I did was get rid of that, and shift the function over to the right by $\frac{\pi}{2}$. This looks like $\tan\left({x - \frac{\pi}{2}}\right)$. (Note that while it may seem like you can just remove this step, if you do, you may get negative numbers for your mod when you only input positive numbers, which is not desirable.)
Now, the trick is to turn a modulo operation like $a \pmod b$ into a number that's a fraction ($\frac{a}{b}$) of the period. Then, we can use the tan function to turn it into the same number whether it's $a$ or $a + b$ (or $a + 2*b$, etc.), because $\frac{a+b}{b} = \frac{a}{b} + 1$, which, when multiplied by the period, will put us on the same $\frac{a}{b}$ part of the tan function! So this gives us $\tan \left(\frac{a}{b} \pi - \frac{\pi}{2} \right)$.
Then, we can use $\arctan$ to recover the input to the $\tan$ function, but now that input will have been shifted to always be in the range of $\arctan$, which is exactly what we want for mod. So, then, all we need to do is recover the $a$, which we do by undoing the $-\frac{\pi}{2}$ with addition, undoing the multiplication by the period ($\pi$) by dividing by $\pi$, and then undoing the original divide by $b$ in the fraction by instead multiplying by $b$.
In the end, we get:
$$a \pmod b = \left( \arctan \left( \tan \left(\frac{a}{b} \pi - \frac{\pi}{2} \right) \right)+\frac{\pi}{2}\right) \frac{b}{\pi}$$
Here's a Desmos demo to show what I'm talking about.
The only other thing that needs fixing (as pointed out by @John Omielan) is that tan can become undefined when $a \pmod b$ is 0. So, to fix this, we can just turn it into a piecewise equation.
Let $m(a, b) = \left( \arctan \left( \tan \left(\frac{a}{b} \pi - \frac{\pi}{2} \right) \right)+\frac{\pi}{2}\right) \frac{b}{\pi}$. Then, $$a \pmod b = m(a, b) \text{ if } a, b \in \mathrm{dom}(m) \text{, and } 0 \text{ otherwise.}$$
(The "if $a, b \in \mathrm{dom}(m)$" just means "if $a$ and $b$ are in the domain of $m$." Another way of saying this would be "if $m(a, b)$ is defined.")
