A nice easy puzzle for the math lovers out there.
We're all familiar with the $\max$ function: $$\max \left( {x,y} \right) \triangleq \left\{ {\begin{array}{*{20}{l}} x&{{\text{if }}x \geq y} \\ y&{{\text{otherwise}}} \end{array}} \right.\,\,\,\forall\, x,y \in \mathbb{R}$$
Suppose we wish to implement this function using no conditional logic and only a basic set of operations:
- multiplication, division, addition, and subtraction
- real-valued numeric constants
- the floor function, $\left\lfloor \cdot \right\rfloor$, which yields the greatest integer $\leq$ its argument (e.g. $\left\lfloor -1.5 \right\rfloor = -2$)
Question
Can you realize the $\max$ function for all real inputs using only these basic operations?