How to construct the optimal piece-wise linear continuous function fitting given curve and given number of knots (optimal knots positions also must be determined by this method)? 



Construct the best piece-wise linear continuous function fitting given curve
If the number and position of the knots are fixed, then the problem is a linear least squares problem for determining the coefficients of linear B-Splines (cf e.g <http://en.wikipedia.org/wiki/B-spline>); if the knot-positions also have to be determined, then the problem becomes non-linear, but is also studied in approximation theory. 


This article seems to fit your needs: *"Fixed- and Free-knot Univariate Least Squares Data Approximation by Polynomial Splines"* by **Maurice Cox, Peter Harris and Paul Kenward** (<http://www.dtic.mil/dtic/tr/fulltext/u2/p013744.pdf>) 


A heuristic for finding a good knot-placement would be to start with an approximation for evenly spaced knots and then move them to the places, where the error is maximal.  

The placing of the knots to the places where the error is maximal can then repeated as long as subsequent approximations with the new knot-placements yield better error measures.


