Lagrange working, moving to piecewise functions