piecewise smooth function