An optimal choice of segment boundaries in piecewise approximation is shown to be soluble by means of a dynamic programme in a scalar state variable. It is shown that the composite error function is continuous in modulus, and that for approximation of concave or convex functions by linear segments, the composite approximation is continuous. Provided the residual term satisfies certain requirements, the solution has uniqueness properties and can be found by means of a grid search method.