Find $f(a,b)$ given $f(a,1)$, $f(a,2)$, ...

177 Views Asked by At

I have a bivariate function $f(a,b)$ that takes 2 positive integers as input and gives another as output. I do not know the "inner-workings" of the function — I can only see the value it returns when I give it any 2 variables. I would like to represent this function with an equation.

My naive attempt at this:

  1. I call the function repeatedly with a different value for $a$ each time while $b$ is fixed at 1. This gives me a sequence of output integers.
  2. I ask Wolfram|Alpha to interpolate a function from this sequence and it gives me a univariate polynomial function: $g(a) = \text{some polynomial}$. I seem to always get an exact function that gives the correct output for any value of $a$. This tells me that $f(a,1) = \text{some polynomial}$.
  3. Next, I repeat steps 1 and 2, incrementing $b$ by 1 each time to get several more such functions: $f(a,2) = \text{polynomial 2}$, $f(a,3) = \text{polynomial 3}$, etc.

This gives me a system of univariate functions which represent the output of my bivariate function for any $a$ and $b$. How can I use these to get a single simplified function for $f(a,b)$?

Example

Let's say I know the following:

  1. $f(a,1) = 1$
  2. $f(a,2) = 2a + 1$
  3. $f(a,3) = 3a^2 + 3a + 1$
  4. $f(a,4) = 4a^3 + 6a^2 + 4a + 1$

For this simple example, the values of each of these functions shows up as a sequence in the OEIS which helps to discover that $f(a,b) = (a + 1)^b - a^b$.

However, not all sets of functions are this simple where each function is in the OEIS. Is there a standard way to find $f(a,b)$ given $f(a,1)$, $f(a,2)$, etc.?

2

There are 2 best solutions below

1
On

If we consider the sequence of functions $f_m (a) = f(a,m) \in \Bbb N$ for all $a \in \Bbb N$, $m = 0,1,2,...$, we cannot generally say if this sequence converges to some $f$. It may diverge at some $a$, converge pointwise elsewhere. There's not even a guarantee that for $a_1, a_2 \in \Bbb N$ where the sequence of functions does converge that $\lim_{m \to \infty} f_m (a_1) = \lim_{m \to \infty} f_m (a_2)$. We could have pointwise convergence to different functions.

But your assumption is that such an $f(a,b)$ does exist, always for all $a,b \in \Bbb N$. Even further you are making a much stronger assumption that $f_1(a) = f_2(a) = ... = f(a,b)$ (per your comments about "unpiecewising" the function, finding exactly one such $f$ that holds for all $a,b$). In general as a question about sequences of functions this is not true.

2
On

Without sampling every integer for $a$ and $b$ in the domain of $f(a,b)$, you cannot be certain that you have the correct polynomial. That said, you can construct a polynomial to exactly fit an arbitrary number of your sampled function values. This can be done with Lagrange polynomials.

For $n^2$ sample points $(a_i,b_j)$ with function values $f_{ij}$, the polynomial is given by

$$f(a,b)=\sum_i^n\sum_j^nf_{ij}\prod_{r\neq i}^{n}\frac{a-a_r}{a_i-a_r}\prod_{s\neq j}^{n}\frac{b-b_s}{b_j-b_s}$$

You can see that gives the correct value for any of your sample points by substitution into the equation. For example, if I solve $f(a_4,b_5)$, only the $i = 4, j = 5$ term is nontrivial because all others will either have a $a_4 - a_4$ or $b_5 - b_5$ term in the numerator of the product. The products evaluate to 1 and you are left with $f_{4~5}$ as desired.

By plugging in a value for $b$, you are left with a polynomial in $a$.

I extended the definition of the Lagrange polynomial to the two dimensional case: https://en.wikipedia.org/wiki/Lagrange_polynomial