The work is devoted to the creation of a cubic splineS (x), which ensures the restoration of the functional dependence Y(x) when specifying conditions for the first derivative of a function on the boundaries of its definition. It is assumed that the function Y(x) is continuous, has continuous first and second derivatives on the interval [a,b], and at the nodal points x0=a, x1, x2, ...,xn=b takes known values equal, respectively, y0, y1, y2,... yn, k=0, 1, 2,…, n. A spline is represented as n polynomials of order no higher than three. The problem is reduced to finding 4n unknown spline coefficients. To determine them, a system of 4n-2 equations was formed: 2n equations taking into account the values of the function at the nodal points, n-1 equations reflecting the continuity of the first derivative and n-1 equations reflecting the continuity of the second derivative at the boundaries of neighboring polynomials, as well as two conditions, related to the values of the first derivative at the boundaries of the function. Solving the problem by the sweep method allowed us to develop algorithmic software for constructing the corresponding cubic spline S(x) in the case of a continuous function Y(x) with continuous first and second derivatives on the segment [a,b] with given values of the first derivative on its boundaries. A scheme for implementing a solution in an algorithmic language is proposed. The Scype program was developed in the Microsoft Visual Studio shell using the C++ language. The magnitude of the function recovery error using the proposed scheme was studied using the example of the function Y(x)=sin (x). The test results showed that the relative accuracy of interpolation with the number of nodal points n=10 on the segment [0,π/2] averaged about 1.4 • 10-3. The maximum accuracy was found in the first interval: (0.4-0.9)10-3. The minimum accuracy is recorded at the beginning of the second and last tenth interval: (4-6)10-2. An increase in the number of nodes to 102, 103 and 104 led to an increase in the average relative accuracy to 1•10-5, 1•10-7 and 2• 10-9, respectively. The data obtained can be used to interpolate functions and process experimental data. Key words: function recovery algorithm, interpolation polynomial, interpolation, cubic spline.
Read full abstract