How to define a piecewise functions ?