Piecewise linear regression with automatic knot selection

Related: If you first perform an ordinary regression which returns a function for evaluating your regression model, then the problem reduces to finding a piecewise linear approximation to that function. This thread contains several methods for performing adaptive piecewise linear interpolation of an arbitrary function to a user-specified error tolerance.