Optimal piecewise works.  Now time to make it faster, then bake into compression algorithms