## Question:

There is a two-dimensional space and there is an array consisting of `x`

, `y`

and `v`

: two coordinates and a value. How to calculate new values for arbitrary coordinates based on existing values?

They say this is solved using linear extrapolation methods. Tell me where to get the formula or the source code of the program for such a primitive case as mine?

## Answer:

Consider the problem of linear approximation of a tabularly given function of two variables.

FORMULATION OF THE PROBLEM

The function u(x, y) is given by its values u _{i} at the points with coordinates (x _{i} , y _{i} ), i = 0, 1, … n-1.

It is required to determine the coefficients A, B, C of the linear approximating function

U(x, y) = Ax + By + C,

minimizing residual

δ(A, B, C) = ∑ _{i} (Ax _{i} + By _{i} + C – v _{i} ) ^{2} .

SOLUTION

The residual function depends on three variables A, B, C. The necessary conditions for the minimum of this function are zero partial derivatives with respect to each of these variables:

δ' _{A} = 0; δ' _{B} = 0; δ' _{C} = 0.

These conditions lead to the 3rd order SLAE:

2∑ _{i} (Ax _{i} + By _{i} + C – v _{i} )x _{i} = 0;

2∑ _{i} (Ax _{i} + By _{i} + C – v _{i} )y _{i} = 0;

2∑ _{i} (Ax _{i} + By _{i} + C – v _{i} ) = 0,

∑ _{i} x _{i} ^{2} A + ∑ _{i} x _{i} y _{i} B + ∑ _{i} x _{i} z _{i} C = ∑ _{i} x _{i} v _{i} ,

∑ _{i} x _{i} y _{i} A + ∑ y _{i} ^{2} B + ∑ _{i} y _{i} z _{i} C = ∑ _{i} y _{i} v _{i} ,

∑ _{i} x _{i} z _{i} A + ∑ y _{i} z _{i} B + ∑z _{i} ^{2} C = ∑ _{i} z _{i} v _{i} ,

the solution of which (for example, according to Cramer's rule) is not a problem.