Evaluate piecewise functions