Multiple Lagrange Interpolation

159 Views Asked by At

I have a data table looking similar to the one below.

There I have for given x- and y-values respective z-values ($z(x,y)$).

  • How can I interpolate the matrix that I find a function that describes $f(x)=z=f(x,y)$?
  • Do I need a Multiple Lagrange Interpolation (as described in this document) for this non-linear function?
  • What kind of (free) software can I use to achieve this?
y x1 x2 x3 x4 x5 x6 x7
y1 z (x1,y1) z (x2,y1) z (x3,y1) z (x4,y1) z (x5,y1) z (x6,y1) z (x7,y1)
y2 z (x1,y2) z (x2,y2) z (x3,y2) z (x4,y2) z (x5,y2) z (x6,y2) z (x7,y2)
y3 z (x1,y3) z (x2,y3) z (x3,y3) z (x4,y3) z (x5,y3) z (x6,y3) z (x7,y3)
y4 z (x1,y4) z (x2,y4) z (x3,y4) z (x4,y4) z (x5,y4) z (x6,y4) z (x7,y4)
y5 z (x1,y5) z (x2,y5) z (x3,y5) z (x4,y5) z (x5,y5) z (x6,y5) z (x7,y5)
y6 z (x1,y6) z (x2,y6) z (x3,y6) z (x4,y6) z (x5,y6) z (x6,y6) z (x7,y6)
y7 z (x1,y7) z (x2,y7) z (x3,y7) z (x4,y7) z (x5,y7) z (x6,y7) z (x7,y7)
y8 z (x1,y8) z (x2,y8) z (x3,y8) z (x4,y8) z (x5,y8) z (x6,y8) z (x7,y8)
y9 z (x1,y9) z (x2,y9) z (x3,y9) z (x4,y9) z (x5,y9) z (x6,y9) z (x7,y9)

Given Numbers:

f(x,y)=z 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100
32 4 -16 -32 -48 -63 -76 -90 -103 -116 -124 -128 -132 -136 -139 -136 -128 -118 -100 -75 -40 2
50 16 0 -18 -32 -48 -63 -78 -90 -100 -111 -118 -123 -125 -128 -125 -121 -112 -96 -70 -37 4
75 44 26 8 -10 -27 -44 -57 -70 -84 -96 -104 -110 -116 -118 -116 -113 -100 -83 -60 -30 12
100 66 51 32 13 -7 -22 -38 -53 -68 -79 -88 -95 -100 -106 -103 -98 -90 -72 -48 -16 21
125 96 76 57 36 18 -2 -20 -36 -49 -60 -72 -80 -86 -92 -90 -86 -75 -60 -38 -11 27
150 120 96 77 56 36 17 -4 -18 -33 -44 -55 -64 -70 -74 -74 -71 -63 -46 -26 5 39
175 144 124 102 79 57 36 19 1 -17 -28 -40 -50 -56 -63 -64 -60 -50 -33 -18 16 44
200 164 146 123 100 80 60 40 23 5 -9 -21 -32 -41 -48 -50 -47 -40 -28 -7 20 58
225 180 160 138 116 95 77 58 38 20 5 -10 -20 -28 -35 -38 -36 -29 -16 6 30 64
250 180 160 138 116 95 77 58 41 29 18 4 -10 -17 -24 -28 -24 -16 -5 18 44 73
300 180 160 138 116 95 77 58 41 29 18 4 1 1 8 0 2 9 20 36 60 92
1

There are 1 best solutions below

4
On

Too long for a comment. You say that you want an interpolating function, so there may be better ways of doing this depending on your application, but I'll show how to construct a polynomial going through all the points.

In one variable if you want to construct a polynomial $P$ through three points $P(x_1)=y_1$, $P(x_2)=y_2$, $P(x_3)=y_3$ you know you need $P$ to have degree 2 in general. So $P(x)=ax^2+bx+c$. You can then just substitute and find

$$ax_1^2+bx_1+c=y_1$$

$$ax_2^2+bx_2+c=y_2$$

$$ax_3^2+bx_3+c=y_3$$

$$\begin{bmatrix} x_1^2 & x_1 & 1 \\ x_2^2 & x_2 & 1 \\ x_3^2 & x_3 & 1 \end{bmatrix} \begin{bmatrix} a \\ b \\ c \end{bmatrix} = \begin{bmatrix} y_1 \\ y_2 \\ y_3 \end{bmatrix} $$

So then you just solve the linear system in $a,b,c$ and you're done. In more variables you can do the same thing. Say, if you want a polynomial through four points $P(x_1,y_1)=z_1$, $P(x_1,y_2)=z_2$, $P(x_2,y_1)=z_3$, $P(x_2,y_2)=z_4$ you can try a polynomial of degree 1 in $x$ and $y$ but then $P(x)=a+bx+cy$ you have a system of 4 equations in 3 unknowns so it doesn't have a solution in general. Then you can add more terms as you see fit, for example you can add a $x^2$ term.

In the example in the question you can do

$$P(x,y)=\sum_{j=0}^{11}\sum_{k=0,k+j\leq 11}^{11} a_{jk}x^jy^k$$

So you have a system of 63 equations in 66 unknowns and you can solve that with something like numpy.