Simplifying an equation (mod, floor) In what ways can I simplify the equation $$y=(1-\lfloor \bmod(x,3)\rfloor)(\bmod(x,1))+\frac{\lfloor \bmod(x,3)\rfloor-\frac{1}{2}}{2|\lfloor \bmod(x,3)\rfloor-\frac{1}{2}|}+\frac{1}{2}$$ or at least make it look nicer?

Notice that


*

*$\text{mod}(x+3,3)=\text{mod}(x,3)$

*$\text{mod}(x+3,1)=\text{mod}(x,1)$


So the function is periodic with period $p=3$.
So you can describe the function on the interval $[0,3)$ in a piecewise fashion, then use that to obtain a general piecewise formula.
The graph looks like this:

On the interval $[0,3)$, $\text{mod}(x,3)=x$ so the expression can be simplified on that interval to
$$ y=(1-\lfloor x\rfloor)\cdot\text{mod}(x,1)+\frac{1}{2}\left[\text{sign}\left( \lfloor x\rfloor-\frac{1}{2}\right)+1\right] $$
On the interval $[0,1)$, $\text{mod}(x,1)=x$, and $\lfloor x\rfloor=0$ and $\text{sign}(0-\frac{1}{2})=-1$, so the expression simplifies to
$$y=x\text{ on }[0,1)$$
On the interval $[1,2)$, $\text{mod}(x,1)=x-1$, $\lfloor x\rfloor=1$ and $\text{sign}(1-\frac{1}{2})=1$, so the expression simplifies to
$$y=1\text{ on }[1,2)$$
On the interval $[1,2)$, $\text{mod}(x,1)=x-2$, $\lfloor x\rfloor=2$ and $\text{sign}(2-\frac{1}{2})=1$, so the expression simplifies to
$$y=3-x\text{ on }[2,3)$$
To make this general we must replace each $x$ with $\text{mod}(x,3)$ and write it as a piecewise function
$$ y=\begin{cases}
\text{mod}(x,3)&\text{ if }0\le\text{mod}(x,3)<1\\
1&\text{ if }1\le\text{mod}(x,3)<2\\
3-\text{mod}(x,3)&\text{ if }2\le\text{mod}(x,3)<3\\
\end{cases} $$
