Evaluation of a piecewise function