Interpolation online calculator 2 values. Determination of an intermediate value by linear interpolation

Interpolation. Introduction. General statement of the problem

When solving various practical problems, the results of research are drawn up in the form of tables showing the dependence of one or more measured quantities on one defining parameter (argument). Such tables are usually presented in the form of two or more rows (columns) and are used to form mathematical models.

Functions given in tables in mathematical models are usually written in tables of the form:

Y1(X)

Y(X0)

Y(X1)

Y(Xn)

Ym(X)

Y(X0)

Y(X1)

Y(Xn)

The limited information provided by such tables, in some cases, requires obtaining the values ​​of the functions Y j (X) (j=1,2,…,m) at points X that do not coincide with the nodal points of table X i (i=0,1,2,… ,n). In such cases, it is necessary to determine some analytical expression φ j (X) to calculate the approximate values ​​of the investigated function Y j (X) at arbitrarily specified points X . The function φ j (X) used to determine the approximate values ​​of the function Y j (X) is called an approximating function (from the Latin approximo - approaching). The proximity of the approximating function φ j (X) to the approximated function Y j (X) is ensured by the choice of the appropriate approximation algorithm.

We will do all further considerations and conclusions for tables containing the initial data of one investigated function (ie, for tables with m=1 ).

1. Methods of interpolation

1.1 Statement of the interpolation problem

Most often, to determine the function φ(X), a statement is used, called the statement of the interpolation problem.

In this classical formulation of the interpolation problem, it is required to determine an approximate analytical function φ(X) whose values ​​at the nodal points X i match the values Y(X i ) of the original table, i.e. conditions

ϕ (X i )= Y i (i = 0,1,2,...,n )

The approximating function φ(X) constructed in this way makes it possible to obtain a sufficiently close approximation to the interpolated function Y(X) within the range of values ​​of the argument [X 0 ; X n ], defined by the table. When setting the values ​​of the X argument, not owned this interval, the interpolation task is converted to the extrapolation task . In these cases, the accuracy

values ​​obtained when calculating the values ​​of the function φ(X) depends on the distance of the value of the argument X from X 0 if X<Х 0 , или отХ n , еслиХ >Xn.

In mathematical modeling, the interpolating function can be used to calculate the approximate values ​​of the function under study at intermediate points of the subintervals [Х i ; Xi+1]. Such a procedure is called table seal.

The interpolation algorithm is determined by the method of calculating the values ​​of the function φ(X). The simplest and most obvious implementation of the interpolating function is to replace the investigated function Y(X) on the interval [X i ; Х i+1 ] by a line segment connecting the points Y i , Y i+1 . This method is called the linear interpolation method.

1.2 Linear interpolation

With linear interpolation, the value of the function at the point X, located between the nodes X i and X i+1, is determined by the formula of a straight line connecting two adjacent points of the table

Y(X) = Y(Xi )+

Y(Xi + 1 ) − Y(Xi )

(X − Xi ) (i= 0,1,2, ...,n),

Xi+ 1−Xi

On fig. 1 shows an example of a table obtained as a result of measurements of a certain value Y(X) . Rows of the source table are highlighted. To the right of the table there is a scatter plot corresponding to this table. The compaction of the table is made due to the calculation by the formula

(3) values ​​of the function being approximated at the points Х corresponding to the midpoints of the subintervals (i=0, 1, 2, … , n ).

Fig.1. Compacted table of the function Y(X) and its corresponding diagram

When considering the graph in Fig. 1 it can be seen that the points obtained as a result of the compaction of the table using the linear interpolation method lie on the segments of the straight lines connecting the points of the original table. Linear accuracy

interpolation, essentially depends on the nature of the interpolated function and on the distance between the nodes of the table X i, , X i+1 .

Obviously, if the function is smooth, then, even with a relatively large distance between the nodes, the graph constructed by connecting the points with straight line segments makes it possible to fairly accurately assess the nature of the function Y(X). If the function changes quickly enough, and the distances between the nodes are large, then the linear interpolating function does not allow obtaining a sufficiently accurate approximation to the real function.

The linear interpolating function can be used for a general preliminary analysis and evaluation of the correctness of the interpolation results, which are then obtained by other more accurate methods. Such an assessment becomes especially relevant in cases where calculations are performed manually.

1.3 Interpolation by canonical polynomial

The method of interpolating a function by a canonical polynomial is based on constructing an interpolating function as a polynomial in the form [ 1 ]

ϕ (x) = Pn (x) = c0 + c1 x + c2 x2 + ... + cn xn

The coefficients with i of the polynomial (4) are free interpolation parameters, which are determined from the Lagrange conditions:

Pn (xi )= Yi , (i= 0 , 1 , ... , n)

Using (4) and (5), we write the system of equations

Cx+ cx2

C xn = Y

Cx+ cx2

Cxn

Cx2

C xn = Y

Solution vector with i (i = 0, 1, 2, …, n ) of a system of linear algebraic equations(6) exists and can be found if there are no matching nodes among i nodes. The determinant of system (6) is called the Vandermonde determinant1 and has an analytical expression [2].

1 Vandermonde's determinant called the determinant

He zero if and only if xi = xj for some. (Material from Wikipedia - the free encyclopedia)

To determine the values ​​of coefficients with i (i = 0, 1, 2, … , n)

equations (5) can be written in the vector-matrix form

A* C=Y,

where A is the matrix of coefficients determined by the table of powers of the argument vector X= (x i 0 , x i , x i 2 , … , x i n ) T (i = 0, 1, 2, … , n)

x0 2

x0 n

xn 2

xn n

C is a column vector of coefficients i (i = 0, 1, 2, …, n), and Y is a column vector of values ​​Y i (i = 0, 1, 2, …, n) of the interpolated function at the interpolation nodes.

The solution of this system of linear algebraic equations can be obtained by one of the methods described in [3]. For example, according to the formula

С = A− 1 Y,

where A -1 is the matrix inverse of matrix A. To obtain the inverse matrix A -1, you can use the function MOBR () included in the set of standard program functions Microsoft Excel.

After the values ​​of the coefficients with i are determined, using the function (4), the values ​​of the interpolated function can be calculated for any value of the arguments .

Let's write the matrix A for the table shown in Fig. 1, without taking into account the rows that condense the table.

Fig.2 Matrix of the system of equations for calculating the coefficients of the canonical polynomial

Using the MOBR() function, we obtain the matrix A -1 inverse to matrix A (Fig. 3). Then, according to formula (9), we obtain the vector of coefficients С=(c 0 , c 1 , c 2 , …, c n ) T shown in fig. 4.

To calculate the values ​​of the canonical polynomial in the cell of the column Y canonical corresponding to the values ​​0 , we introduce the converted to next kind formula corresponding to the zero line of the system (6)

=((((c 5

* x 0 + c 4 ) * x 0 + c 3 ) * x 0 + c 2 ) * x 0 + c 1 ) * x 0 + c 0

C0 +x *(c1 + x *(c2 + x*(c3 + x*(c4 + x* c5 ))))

Instead of writing " c i " in the formula entered into the cell of the Excel table, there should be an absolute reference to the corresponding cell containing this coefficient (see Fig. 4). Instead of "x 0" - a relative reference to the column column X (see Fig. 5).

Y canonical (0) of the value that matches the value in cell Y lin (0) . When dragging a formula written in a cell Y canonical (0), the values ​​of Y canonical (i) must also match, corresponding to the node points of the original

tables (see Fig. 5).

Rice. 5. Diagrams built according to the tables of linear and canonical interpolation

Comparison of graphs of functions built according to tables calculated using the formulas of linear and canonical interpolation, we see in a number of intermediate nodes a significant deviation of the values ​​obtained by the formulas of linear and canonical interpolation. It is possible to judge the accuracy of interpolation more reasonably based on obtaining additional information about the nature of the process being modeled.

This term has other meanings, see Interpolation. About the function, see: Interpolant.

Interpolation, interpolation (from lat. interpolis - « smoothed out, renewed, renewed; converted"") - in computational mathematics, a way to find intermediate values ​​of a quantity from an existing discrete set known values. The term "interpolation" was first used by John Vallis in his treatise The Arithmetic of the Infinite (1656).

IN functional analysis interpolation of linear operators is a section that considers Banach spaces as elements of a certain category.

Many of those who deal with scientific and engineering calculations often have to work with sets of values ​​obtained empirically or by random sampling. As a rule, on the basis of these sets, it is required to construct a function on which other obtained values ​​could fall with high accuracy. Such a task is called approximation. Interpolation is a type of approximation in which the curve of the constructed function passes exactly through the available data points.

There is also a problem close to interpolation, which consists in approximating some complex function by another, simpler function. If a certain function is too complex for productive calculations, you can try to calculate its value at several points, and build, that is, interpolate, a simpler function from them. Of course, using a simplified function does not allow you to get the same exact results as the original function would give. But in some classes of problems, the gain in simplicity and speed of computations can outweigh the resulting error in the results.

We should also mention a completely different kind of mathematical interpolation, known as "operator interpolation". The classic works on operator interpolation include the Riesz-Thorin theorem and the Marcinkiewicz theorem, which are the basis for many other works.

Definitions

Consider a system of non-coincident points xi (\displaystyle x_(i)) (i ∈ 0 , 1 , … , N (\displaystyle i\in (0,1,\dots ,N))) from some domain D (\displaystyle D) . Let the values ​​of the function f (\displaystyle f) be known only at these points:

Y i = f (x i) , i = 1 , … , N . (\displaystyle y_(i)=f(x_(i)),\quad i=1,\ldots ,N.)

The problem of interpolation is to find a function F (\displaystyle F) from a given class of functions such that

F (x i) = y i , i = 1 , … , N . (\displaystyle F(x_(i))=y_(i),\quad i=1,\ldots ,N.)

  • The points x i (\displaystyle x_(i)) are called interpolation nodes, and their totality is interpolation grid.
  • Pairs (x i , y i) (\displaystyle (x_(i),y_(i))) are called data points or base points.
  • Difference between "adjacent" values ​​Δ x i = x i − x i − 1 (\displaystyle \Delta x_(i)=x_(i)-x_(i-1)) - interpolation grid step. It can be both variable and constant.
  • Function F (x) (\displaystyle F(x)) - interpolating function or interpolant.

Example

1. Let's say we have a table function like the one below that, for multiple values ​​of x (\displaystyle x), determines the corresponding values ​​of f (\displaystyle f) :

X (\displaystyle x) f (x) (\displaystyle f(x))

0
1 0,8415
2 0,9093
3 0,1411
4 −0,7568
5 −0,9589
6 −0,2794

Interpolation helps us to know what value such a function can have at a point other than the specified points (for example, when x = 2,5).

To date, there are many various ways interpolation. The choice of the most suitable algorithm depends on the answers to the questions: how accurate is the chosen method, what is the cost of using it, how smooth is the interpolation function, how many data points does it require, etc.

2. Find an intermediate value (by linear interpolation).

6000 15.5
6378 ?
8000 19.2

15.5 + (6378 − 6000) 8000 − 6000 ∗ (19.2 − 15.5) 1 = 16.1993 (\displaystyle ?=15.5+(\frac ((6378-6000))(8000-6000))*(\frac ((19.2- 15.5))(1))=16.1993)

In programming languages

An example of linear interpolation for the function y = 3 x + x 2 (\displaystyle y=3x+x^(2)) . The user can enter a number between 1 and 10.

Fortran

program interpol integer i real x, y, xv, yv, yv2 dimension x(10) dimension y(10) call prisv(x, i) call func(x, y, i) write(*,*) "enter number: " read(*,*) xv if ((xv >= 1).and.(xv xv)) then yv2 = ((xv - x(i)) * (y(i+1) - y(i)) / (x(i+1) - x(i))) + y(i) end if end do end subroutine

C++

int main() ( system("COLOR 0A"); double ob, x1, x2, y1, y2, p1, p2, pi, skolko, status; system("echo Interpolate X1 - X2 "); system("echo Enter number: "); cin >> ob; system("echo For example 62, C1 = 60, L1 = 1.31, C2 = 80, L2 = 1.29"); cout > x1; cout > x2; cout > y1; cout > y2 ; p1 = y1 - x1; p2 = y2 - x2; pi = p2 / p1; skolko = ob - x1; status = x2 + (pi * skolko); cout

Interpolation methods

Nearest neighbor interpolation

The simplest interpolation method is nearest neighbor interpolation.

Interpolation by polynomials

In practice, interpolation by polynomials is most often used. This is primarily due to the fact that polynomials are easy to calculate, it is easy to analytically find their derivatives, and the set of polynomials is dense in the space of continuous functions (Weierstrass's theorem).

  • Linear interpolation
  • Newton's interpolation formula
  • Finite difference method
  • IMN-1 and IMN-2
  • Lagrange polynomial (interpolation polynomial)
  • Aitken's scheme
  • spline function
  • cubic spline

Reverse interpolation (computing x given y)

  • Lagrange polynomial
  • Inverse interpolation by Newton's formula
  • Inverse Gauss Interpolation

Multi-Variable Function Interpolation

  • Bilinear Interpolation
  • Bicubic Interpolation

Other interpolation methods

  • Rational Interpolation
  • Trigonometric interpolation

Related concepts

  • Extrapolation - methods for finding points outside a given interval (curve extension)
  • Approximation - methods for constructing approximate curves

Reverse Interpolation

on the class of functions from the space C2 whose graphs pass through the points of the array (xi, yi), i = 0, 1, . . . , m.

Solution. Among all the functions that pass through the reference points (xi, f(xi)) and belong to the mentioned space, it is the cubic spline S(x) that satisfies the boundary conditions S00(a) = S00(b) = 0 that provides the extremum (minimum) functional I(f).

Often in practice there is a problem of searching for the given value of the function of the value of the argument. This problem is solved by reverse interpolation methods. If the given function is monotonic, then the easiest way to perform backward interpolation is to replace the function with an argument and vice versa and then interpolate. If the given function is not monotonic, then this technique cannot be used. Then, without changing the roles of the function and the argument, we write down this or that interpolation formula; using the known values ​​of the argument and, assuming the function is known, we solve the resulting equation with respect to the argument.

The estimate of the remainder term when using the first method will be the same as with direct interpolation, only the derivatives of the direct function must be replaced by derivatives of the inverse function. Let us estimate the error of the second method. If we are given a function f(x) and Ln (x) is the Lagrange interpolation polynomial constructed for this function over the nodes x0, x1, x2, . . . , xn, then

f (x) − Ln (x) =(n + 1)! (x − x0) . . . (x − xn) .

Suppose we need to find a value x¯ such that f (¯x) = y¯ (y¯ is given). We will solve the equation Ln (x) = y¯ . Let's get some value x¯. Substituting into the previous equation, we get:


Mn+1

f (x¯) − Ln (x¯) = f (x¯) − y¯ = f (x¯) − f (¯x) =

Applying the Langrange formula, we get

(x¯ − x¯) f0 (η) =

where η is between x¯ and x¯. If is an interval that contains x¯ and x¯ and min

from the last expression follows:

|x¯ − x¯| 6m1(n + 1)! |$n (x¯)| .

In this case, of course, it is assumed that we have solved the equation Ln (x) = y¯ exactly.

Using interpolation for tabulation

The theory of interpolation has applications in the compilation of tables of functions. Having received such a problem, the mathematician must solve a number of questions before starting the calculations. The formula by which the calculations will be carried out must be chosen. This formula may vary from site to site. Usually, formulas for calculating function values ​​are cumbersome and therefore they are used to obtain some reference values ​​and then, by subtabulation, they thicken the table. The formula that gives the reference values ​​of the function must provide the required accuracy of the tables, taking into account the following subtabulation. If you want to compile tables with a constant step, then you first need to determine its step.

Back First Previous Next Last Go Subject index


Most often, function tables are compiled so that linear interpolation (that is, interpolation using the first two terms of the Taylor formula) is possible. In this case, the remainder term will look like

R1 (x) =f00 (ξ)h2t(t − 1).

Here ξ belongs to the interval between two adjacent tabular values ​​of the argument in which x is located, and t is between 0 and 1. The product t(t − 1) takes the largest modulo

value at t = 12. This value is equal to 14. So,

It must be remembered that next to this error - the error of the method, in the practical calculation of intermediate values, an unrecoverable error and rounding error will still occur. As we saw earlier, the fatal error in linear interpolation will be equal to the error of the tabulated values ​​of the function. The rounding error will depend on the computing means and on the calculation program.

Back First Previous Next Last Skip Index


Subject index

divided differences of the second order, 8 of the first order, 8

spline, 15

interpolation nodes, 4

Back First Previous Next Last Skip Index

/ Material_studentam_po_RGR_BZhD / How to do interpolation

Formula for interpolating tabular data

Used in the 2nd step, when the amount of NXR (Q, t) from the condition is intermediate between 100 t and 300 t.

(An exception: if Q is equal to 100 or 300 by condition, then interpolation is not needed).

y o- Your initial amount of NHR from the condition, in tons

(corresponds to the letter Q)

y 1 lesser

(from Tables 11-16, usually 100).

y 2 more nearest to your value of the amount of NCR, in tons

(from Tables 11-16, usually 300).

x 1 y 1 (x 1 located opposite y 1 ), km.

x 2 - tabular value of the depth of propagation of a cloud of contaminated air (G t), respectively y 2 (x 2 located opposite y 2 ), km.

x 0 - desired value G T corresponding y o(according to the formula).

Example.

NCR - chlorine; Q = 120 t;

Type of SVSP (degree of vertical air resistance) - inversion.

To find G T- tabular value of the spreading depth of the cloud of contaminated air.

    We look through tables 11-16 and find data that matches your condition (chlorine, inversion).

Suitable table 11.

    Choosing values y 1 , y 2, x 1 , x 2 . Important - we take the wind speed 1 m / s., we take the temperature - 20 ° C.

    Substitute the selected values ​​in the formula and find x 0 .

Important - calculation is correct if x 0 will have a value somewhere between x 1 , x 2 .

1.4. Lagrange interpolation formula

The algorithm proposed by Lagrange for constructing interpolating

functions according to tables (1) provides for the construction of the interpolation polynomial Ln(x) in the form

Obviously, the fulfillment of conditions (11) for (10) determines the fulfillment of conditions (2) of the statement of the interpolation problem.

The polynomials li(x) are written as follows

Note that not a single factor in the denominator of formula (14) is equal to zero. Having calculated the values ​​of the constants ci, you can use them to calculate the values ​​of the interpolated function at given points.

The Lagrange interpolation polynomial formula (11), taking into account formulas (13) and (14), can be written as

qi (x − x0)(x − x1) K (x − xi −1)(x − xi +1) K (x − xn)

1.4.1.Organization of manual calculations according to the Lagrange formula

The direct application of the Lagrange formula leads to a large number of calculations of the same type. For tables of small dimensions, these calculations can be performed both manually and in the software environment.

At the first stage, we consider the algorithm of calculations performed manually. In the future, the same calculations should be repeated in the environment

Microsoft Excel or OpenOffice.org Calc.

On fig. 6 shows an example of the source table of an interpolated function defined by four nodes.

Fig.6. Table containing the initial data for the four nodes of the interpolated function

In the third column of the table, we write the values ​​of the coefficients qi calculated by formulas (14). Below is a record of these formulas for n=3.


q0=Y0/(x0-x1)/(x0-x2)/(x0-x3)q1=Y1/(x1-x0)/(x1-x2)/(x1-x3)(16) q2=Y2/( x2-x0)/(x2-x1)/(x2-x3)q3=Y3/(x3-x0)/(x3-x1)/(x3-x2)

The next step in the implementation of manual calculations is the calculation of the values ​​li(x) (j=0,1,2,3), performed by formulas (13).

Let's write these formulas for the version of the table we are considering with four nodes:

l0(x)=q0(x-x1) (x-x2) (x-x3),

l1(x)=q1(x-x0) (x-x2) (x-x3),

l2(x)=q2(x-x0)(x-x1)(x-x3),(17) l3(x)=q3(x-x0)(x-x1)(x-x2) .

Let's calculate the values ​​of the polynomials li(xj) (j=0,1,2,3) and write them down in the cells of the table. The values ​​of the function Ycalc(x), according to formula (11), will be obtained as a result of summing the values ​​of li(xj) in rows.

The format of the table, which includes columns of calculated values ​​li(xj) and a column of values ​​Ycalc(x), is shown in Fig.8.

Rice. 8. Table with the results of manual calculations performed by formulas (16), (17) and (11) for all values ​​of the argument xi

Having completed the formation of the table shown in Fig. 8, by formulas (17) and (11) it is possible to calculate the value of the interpolated function for any value of the argument X. For example, for X=1 we calculate the values ​​li(1) (i=0,1,2,3):

l0(1)=0.7763; l1(1)= 3.5889; l2(1)=-1.5155;l3(1)=0.2966.

Summing up the values ​​of li(1) we get the value Yinterp(1)=3.1463.

1.4.2. Implementation of the interpolation algorithm by Lagrange formulas in the environment of the Microsoft Excel program

The implementation of the interpolation algorithm begins, as in manual calculations, by writing formulas for calculating the coefficients qi. 9 shows the columns of the table with the given values ​​of the argument, interpolated function and coefficients qi. To the right of this table are the formulas that are written in the cells of column C to calculate the values ​​of the coefficients qi.

ВС2: "=B2/((A2-A3)*(A2-A4)*(A2-A5))" Æ q0

c3: "=B3/((A3-A4)*(A3-A5)*(A3-A2))" Æ q1

c4: "=B4/((A4-A5)*(A4-A2)*(A4-A3))" Æ q2

vС5: "=B5/((A5-A2)*(A5-A3)*(A5-A4))" Æ q3

Rice. 9 Table of coefficients qi and calculation formulas

After entering the formula q0 in cell C2, it is pulled through cells from C3 to C5. After that, the formulas in these cells are corrected in accordance with (16) to the form shown in Fig. nine.


Ycalc(xi),

Implementing formulas (17), we write formulas for calculating the values ​​li(x) (i=0,1,2,3) in the cells of columns D, E, F and G. In cell D2 to calculate the value l0(x0), we write the formula:

=$C$2*($A2-$A$3)*($A2-$A$4)*($A2-$A$5),

we obtain the values ​​l0 (xi) (i=0,1,2,3).

The $A2 link format allows you to stretch the formula along columns E, F, G to form computational formulas for calculating li(x0) (i=1,2,3). Dragging a formula over a row does not change the column index of the arguments. To calculate li(x0) (i=1,2,3) after drawing the formula l0(x0) it is necessary to correct them according to formulas (17).

In column H we put the Excel formulas for summing li(x) according to the formula

(11) algorithm.

On fig. 10 shows a table implemented in the Microsoft Excel program environment. A sign of the correctness of the formulas written in the cells of the table and the performed computational operations are the resulting diagonal matrix li(xj) (i=0,1,2,3),(j=0,1,2,3), repeating the results shown in Fig. 8, and a column of values ​​matching the values ​​of the interpolated function in the nodes of the original table.

Rice. 10. Table of values ​​li(xj) (j=0,1,2,3) and Ycalc(xj)

To calculate the values ​​at some intermediate points, it is enough

In the cells of column A, starting from cell A6, enter the values ​​of the argument X for which you want to determine the values ​​of the interpolated function. Highlight

in the last (5th) line of the cell table from l0(xn) to Ycalc(xn) and stretch the formulas written in the selected cells to the line containing the last

the given value of the x argument.

On fig. 11 shows a table in which the calculation of the value of the function in three points: x=1, x=2 and x=3. An additional column with row numbers of the source data table has been introduced into the table.

Rice. 11. Calculation of the values ​​of interpolated functions using Lagrange formulas

For greater clarity of displaying the interpolation results, we will construct a table that includes a column of values ​​of the argument X ordered in ascending order, a column of initial values ​​of the function Y(X) and a column

Tell me how to use the interpolation formula and which one in solving problems in thermodynamics (heat engineering)

Ivan Shestakovich

The simplest, but often not sufficiently accurate interpolation is linear. When you already have two known points (X1 Y1) and (X2 Y2) and you need to find the Y values ​​of the day of some X which is between X1 and X2. Then the formula is simple.
Y \u003d (Y2-Y1) * (X-X1) / (X2-X1) + Y1
By the way, this formula also works for X values ​​outside the X1..X2 interval, but this is already called extropolation and, at a significant distance from this interval, it gives a very large error.
There are many other mats. interpolation methods - I advise you to read the textbook or rummage through the internet.
The method of graphical interpolation is also not ruled out - manually draw a graph through known points and find Y from the graph for the required X. ;)

novel

You have two meanings. And approximately the dependence (linear, quadratic, ..)
The graph of this function passes through your two points. You need a value somewhere in between. Well, express!
For example. In the table, at a temperature of 22 degrees, the saturated vapor pressure is 120,000 Pa, and at 26, 124,000 Pa. Then at a temperature of 23 degrees 121000 Pa.

Interpolation (coordinates)

There is a coordinate grid on the map (image).
It has some well-known reference points (n>3) with two x,y values- coordinates in pixels, and coordinates in meters.
It is necessary to find intermediate values ​​of coordinates in meters, knowing the coordinates in pixels.
Linear interpolation is not suitable - too much error outside the line.
Like this: (Xc - coordinate in meters by x, Xp - coordinate in pixels by x, Xc3 - desired value by x)
Xc3= (Xc1-Xc2)/(Xp1-Xp2)*(Xp3-Xp2)+Xc2
Yc3= (Yc1-Yc2)/(Yp1-Yp2)*(Yp3-Yp2)+Yc2

How to find the same formula for finding Xc and Yc, given not two (like here), but N known reference points?

Joka fern lowd

Judging by the written formulas, do the axes of the coordinate systems in pixels and meters coincide?
That is, Xp -> Xc is interpolated independently and Yp -> Yc is independently interpolated. If not, then you need to use two-dimensional interpolation Xp,Yp->Xc and Xp,Yp->Yc, which complicates the task somewhat.
Further, it is assumed that the coordinates Xp and Xc are related by some dependence.
If the nature of the dependence is known (or it is assumed, for example, we assume that Xc=a*Xp^2+b*Xp+c), then you can get the parameters of this dependence (for the given dependence a, b, c) using regression analysis(Least square method) . In this method, if you specify a certain dependence Xc(Xp), you can get a formula for the parameters of the dependence on the reference data. This method allows, in particular, to find a linear dependence, the best way satisfying this data set.
Disadvantage: In this method, the Xc coordinates obtained from the data of the Xp control points may differ from the given ones. As for example, the approximation straight line drawn through the experimental points does not pass exactly through these points themselves.
If an exact match is required and the nature of the dependence is unknown, interpolation methods should be used. The simplest mathematically is the Lagrange interpolation polynomial, passing exactly through the reference points. However, due to the high degree of this polynomial at large numbers reference points and Bad quality interpolation, it is better not to use it. The advantage is the relatively simple formula.
It is better to use spline interpolation. The essence of this method is that in each section between two neighboring points, the dependence under study is interpolated by a polynomial, and smoothness conditions are written at the joining points of two intervals. The advantage of this method is the quality of the interpolation. Disadvantages - almost impossible to withdraw general formula, one has to find the coefficients of the polynomial in each section algorithmically. Another disadvantage is the difficulty of generalizing to 2D interpolation.

This is a chapter from Bill Jelen's book.

Challenge: Some engineering design problems require the use of tables to calculate parameter values. Because the tables are discrete, the designer uses linear interpolation to get an intermediate parameter value. The table (Fig. 1) includes the height above the ground (control parameter) and wind speed (calculated parameter). For example, if you need to find the wind speed corresponding to a height of 47 meters, then you should apply the formula: 130 + (180 - 130) * 7 / (50 - 40) = 165 m / s.

Download note in or format, examples in format

What if there are two control parameters? Is it possible to perform calculations with a single formula? The table (Fig. 2) shows the values ​​of wind pressure for various heights and spans of structures. It is required to calculate the wind pressure at a height of 25 meters and a span of 300 meters.

Solution: We solve the problem by extending the method used for the case with one control parameter. Do the following.

Start with the table shown in fig. 2. Add source cells for height and span to J1 and J2 respectively (Figure 3).

Rice. 3. The formulas in cells J3:J17 explain how the mega formula works

For the convenience of using formulas, define names (Fig. 4).

Follow the work of the formula sequentially moving from cell J3 to cell J17.

By reverse sequential substitution, assemble the mega formula. Copy the formula text from cell J17 to J19. Replace the reference to J15 in the formula with the value in cell J15: J7+(J8-J7)*J11/J13. Etc. The result will be a formula consisting of 984 characters, which cannot be perceived in this form. You can see it in the attached excel file. Not sure if this kind of mega-formulas are useful to use.

Summary: Linear interpolation is used to obtain an intermediate value of a parameter if tabular values ​​are given only for range boundaries; a calculation method based on two control parameters is proposed.

There is a situation when you need to find intermediate results in an array of known values. In mathematics, this is called interpolation. In Excel this method can be used both for tabular data and for plotting graphs. Let's take a look at each of these methods.

The main condition under which interpolation can be applied is that the desired value must be inside the data array, and not go beyond its limit. For example, if we have a set of arguments 15, 21 and 29, then when finding a function for argument 25, we can use interpolation. And to find the corresponding value for the argument 30 - no longer. This is the main difference between this procedure and extrapolation.

Method 1: Interpolation for tabular data

First of all, consider the use of interpolation for data that is located in a table. For example, let's take an array of arguments and their corresponding function values, the ratio of which can be described linear equation. These data are placed in the table below. We need to find the corresponding function for the argument 28 . The easiest way to do this is with the operator FORECAST.


Method 2: interpolating a graph using its settings

The interpolation procedure can also be used when plotting a function. It is relevant in the event that in the table on the basis of which the graph is built, the corresponding value of the function is not indicated for one of the arguments, as in the image below.


As you can see, the graph has been corrected, and the gap has been removed using interpolation.

Method 3: Graph interpolation using a function

You can also interpolate the graph using the special ND function. It returns null values ​​in the specified cell.


You can make it even easier without running Function Wizard, but just use the keyboard to drive a value into an empty cell "#N/A" without quotes. But it already depends on how it is more convenient for which user.

As you can see, in the Excel program, you can interpolate like tabular data using the function FORECAST, as well as graphics. In the latter case, this can be done using the graph settings or using the function ND, causing an error "#N/A". The choice of which method to use depends on the problem statement, as well as on the personal preferences of the user.

What else to read