I'm attempting to create a function such that, for any real number $x$, the result of the function is limited by predefined minimum and maximum values, $a$ and $b$:
$$a <= f(x) <= b$$

How would one do this using limited operators only: addition, subtraction, multiplication, division, powers and absolute values? I know how to individually find the maximum or minimum of two numbers and those can be used to limit in one direction:
$$a<=f(a) \; \equiv \; max(a,x) = \frac{a+x+|a-x|}{2}$$
$$f(x)<=b \; \equiv \; min(b,x) = \frac{b+x-|b-x|}{2}$$

This gives me two separate functions, each of which enforces one of the bounds. How would you go about combining these into a single function that can enforce both bounds? A simple attempt at layering these inside another minimum or maximum function just cancels out one of them, of course:
$$max(max(a,x),min(b,x))=max(a,x)$$
$$min(max(a,x),min(b,x))=min(b,x)$$