Piecewise linear approximation for set of points
This can be solved with a straightforward dynamic programming algorithm.  If you have $n$ data points, it can be solved in $O(n^2)$ calls to BestFit plus $O(n^2 k)$ time.  See https://cs.stackexchange.com/tags/dynamic-programming/info for our resources on how to construct dynamic programming algorithms.