Algorithm of piece-linear interpolation

Many of those who encounter scientific and

engineering calculations often have to use sets of values ??obtained experimentally

or by random selecting.

As a rule, on the basis of these sets, it is necessary to construct a function with

values ??that could coincide with the high accuracy of other values ??obtained.

Such a task is called the approximation of the curve. An interpolation is called

a kind of approximation, in which the curve of the constructed function passes precisely

through the available data points.

There is also a problem close to interpolation,

which consists of approximating some complex function to another, a simpler function.

If some function is too complicated for productive computations, you can try to

calculate its value in several points, and then construct, i.e. interpolate,

a simpler function. Of course, the use of a simplified function does not allow for

the same precise results that would give the original function. However, for some

classes of tasks, the gain achieved in simplicity and speed of computing can outweigh

the resulting flaws in the results.

Approximation is used to handle the built-in

dependency graph. Approximation is the process of approaching the expression of

one object by others. Suppose the values ??of some function are known at given points.

You need to find the intermediate values ??of this function. This is the so-called

task of restoring the function. When performing calculations, complex functions

are conveniently replaced by other elementary functions that are fairly easily calculated.

With the help of approximation, we can find the approximate value of some function

at given points. The problem of approximation is as follows.

On the interval a, b the points xi,

i=0, 1,…, N; a ? x

i ? b, and the value

of the unknown function at these points fi,

i = 0, 1, …., N. It is necessary to find the function F (x), accepting at the

points xi the same value of fi.

Points are called interpolation nodes, and conditions F(xi) = fi. – Terms of interpolation. In this case,

F(x) is searched only for segment a, b.

This task will allow us to approximate the

values ??of the parameters of volume or frequency, which are constructed by the

graphs of dependence. To solve this problem we use the algorithm of a piecewise

linear interpolation. It is as follows.

On each interval xi–1,

xi the function is linear

7.

The values ??of the coefficients are from the

implementation of interpolation conditions at the ends of the segment:

.

We obtain the system of equations:

where we find

. Consequently, the function F (x) can be written

as:

, i.e.

or F(x) = ki * (x – xi-1) + fi-1,

ki

= (fi – fi-1) / (xi – xi-1), xi-1

? x ? xi, i=1,2,…,N-1

When using linear interpolation, you first

need to define the interval in which the value of x enters, and then substitute

it into the formula.

The resulting function will be continuous,

but the derivative will be discontinuous in each interpolation node. An illustration

of a piecewise linear interpolation is shown in Figure 3.7.

Fig. 3.7 Piecewise-linear interpolation