1

Assume I have two functions, $f_1$ and $f_2$, that both depend on $x$ and $y$, so that $f_1(x,y)$ and $f_2(x,y)$.

I don't know the exact functions, but know values of each function at some points (actually, any points I want).

So, for example, let's say that:

at $x=+1$ and $y=-1$, $$f_1=+9,$$ $$f_2=+7,$$

at $x=-1$ and $y=+1$, $$f_1=-2,$$ $$f_2=-6,$$

at $x=+1$ and $y=+1,$ $$f_1=+11,$$ $$f_2=+9.$$

at $x=-1$ and $y=-1,$ $$f_1=-7,$$ $$f_2=-8.$$

I need to find the values for $x$ and $y$ where both functions equal $0$.

If each function only depended on one variable a linear interpolation would suffice. But as both functions depend on $2$ variables I'm getting a bit confused.

I've been searching on bilinear and trilinear interpolation, but I can't really pinpoint what I actually need to use.

Thank you all.

user4167
  • 1,453
Marcelo
  • 133
  • Sections 9.6 and 9.7 of Numerical Recipes have a discussion of why this problem is hard and some things to try. – Ross Millikan Mar 13 '13 at 00:43
  • If the points are spaced closely enough, take the four nearest "rectangle" corners, interpolate linearly in the $x$ direction on the opposite sides, and interpolate in the $y$ direction between the resulting values. Doing it in the $y ; x$ order gives the same value, so it is at least consistent (the resulting surface is quadratic in $x$ and $y$). If this is too coarse, perhaps use four points in each direction (two on each side of the point) and do similarly, but the resulting third degree polynomials could well bulge above/below the "real" surface. – vonbrand Mar 13 '13 at 00:45

2 Answers2

2

How about this way? Suppose the function can be approximated by a polynomial of degree 1, that is, $$f_1(x, y) = c_{00} + c_{10}x + c_{01}y$$ for some constants $c_{00}$, $c_{10}$, and $c_{01}$. From the first three conditions, we have $$ \begin{bmatrix} 1 & 1 & -1 \\ 1 & -1 & 1 \\ 1 & 1 & 1 \end{bmatrix} \begin{bmatrix} c_{00} \\ c_{10} \\ c_{01} \end{bmatrix} = \begin{bmatrix} f_1(1, -1) \\ f_1(-1, 1) \\ f_1(1, 1) \end{bmatrix} = \begin{bmatrix} 9 \\ -2 \\ 11 \end{bmatrix} $$ and its solution is $c_{00} = 7/2$, $c_{10} = 13/2$, and $c_{01} = 1$. Hence $$ f_1(x, y) \approx \frac{7}{2} + \frac{13}{2}x + y. $$ Do it again for $f_2$ and we get $$ f_2(x, y) \approx \frac{1}{2} + \frac{15}{2}x + y. $$ Lastly, solving $$\begin{cases} f_1(x, y) = 0 \\ f_2(x, y) = 0 \end{cases}$$ gives you $x = 3$ and $y = -23$.

If you would like to get more accurate approximation, try to do this by polynomial with higher degree.

Orat
  • 4,065
0

Just another try. Since it seems, the coordinates are of a plane,I interpret them as complex values. Then from the four given arguments and the four resulting values I do an ordinary polynomial interpolation procedure. This gives the complex polynomial: $$ \operatorname{ cofu } (z)= (-25/16 - 37/16 I) z^3 + 3/8 I z^2 + (33/8 + 23/8 I) z + (11/4 + 1/2 I) $$ This gives then, for instance, $$ \operatorname{cofu}(1-1 I) = 9 + 7I $$ One can plot this using mathematica, getting a rough impression - don't find the best command-parameters,though...

Then one can use a complex root-finder, as for instance in Pari/GP (or again in Wolfram-mathematica). We get using Pari/GP: $$ \operatorname{polroots}(\operatorname{cofu}(z)) = \\ [1.57353592868 - 0.292970871914 I, \\ -0.931132188421 - 0.0424173327510 I, \\ -0.531069738252 + 0.410613881696 I] $$