I have a periodic function with fmod() like this (in C):
float f(float x) {
x = fmod(x, 1);
if (x < 0.5f) return 1 - x;
else return x
}
If I need a formal math formula for this function, what is the prettiest way?
Do people use fmod or mod functions in formulas like this? It looks strange.
$$ f(x) = \left\{ \begin{array}{**lr**} 1-\mathrm{fmod} (x,1), & 0 \leq \mathrm{fmod} (x,1) < 0.5 \\ \mathrm{fmod}(x,1), & 0.5 \leq \mathrm{fmod} (x,1) < 1 \end{array} \right. $$
fmod()is the real number version of 'divide and find remainder' operation. Sofmod(x, c)produces periodic effect with cycle c. I wonder if there's a way to express this operation. (I don't know if mathematicians use $n \ \rm{mod} \ m$ for integers) – landings Jul 20 '20 at 08:40fmod(x,1)is certainly understood. – Hagen von Eitzen Jul 20 '20 at 11:19