$(x)_d := (x)_{\pmod d} = \min\ \{ z \in \Bbb{Z} : z = x \pmod d, z \geq 0\}$.
Now how would we go about computing the maximum and minimum (expressionally) of:
$$ f(x) = (x)_d - \dfrac{(x)_{2d}}{2} $$
Attempt. Clearly whatever $y = (x)_{2d}$ is we know that $(y)_d = (x)_d$, by the homomorphism from $\Bbb{Z}/(2d) \twoheadrightarrow \Bbb{Z}/d$.
For example: $d = 5$:
$y = 0,1,2,\dots,9 \pmod {2d} \implies f(y) = 0, 1/2, 1, 3/2, 2, -5/2, -2, -3/2, -1, -1/2$ respectively. So I would guess the min/max are going to be $-\dfrac{d}{2}, \dfrac{ d-1}{2}$. But how can we prove that in general?
For $0\le x<d$, $f(x)=x-\dfrac{x}{2}=\dfrac{x}{2}$; for $d\le x<2d$, $f(x)=(x-d)-\dfrac{x}{2}=\dfrac{x}{2}-d$.
Also notice that $2d$ is a period of $f(x)$, so the min and max values are $-\dfrac{d}{2}$ and $\dfrac{d-1}{2}$.