3. For the first question consider $f(x) = \left\{ \begin{array}{c}1\mbox{ if }x\in \mathbb{Q} \\ -1\mbox{ if }x\not \in \mathbb{Q} \end{array} \right.$.
For second question use $\max (a,b) = \frac{1}{2}(a+b) - \frac{1}{2}|a-b|$.