The actual application for the problem of best approximation of grid functionby linear splines was formulated. A mathematical model and a method for its solution were developed. Complexity of the problem was that it was multi - extremal and could not be solved analytically. The method was developed in order to solve the problem of dynamic programming scheme, which was extended by us. Given the application of the method to the problem of flow control in the pressure-regulating systems, the pipeline network for transport of substances (pipelines of water, oil, gas, and etc.) that minimizes the amount of substance reservoirs and reduces the discharge of substance from the system. The method and the algorithm developed here may be used in computational mathematics, optimal control and regulation system, and regressive analysis.