-1
$\begingroup$

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.?

$\endgroup$
  • $\begingroup$ Perhaps related?: Find the generating function for a series , given a recurrence relation $\endgroup$ – Web_Designer Jun 26 '17 at 23:31
  • $\begingroup$ As a counterexample, what prevents $f$ from being a piecewise function where $f(n,m) = 0$ for some $n,m \in \Bbb Z$ and $f(a,m) = g(a)$ for all other $a$? $\endgroup$ – Phillip Hamilton Jun 27 '17 at 0:32
  • $\begingroup$ @PhillipHamilton The last ordered list in my question is basically just another way of writing the piecewise function. My goal is to unpiecewise a piecewise function. :) $\endgroup$ – Web_Designer Jun 27 '17 at 0:46
  • 1
    $\begingroup$ That's not inherently possible. A piecewise function with a discontinuity, as an example, cannot be "unpiecewised" into a continuous form. If your goal is to get the statistically closest continuous polynomial form, that is a much different question. $\endgroup$ – Phillip Hamilton Jun 27 '17 at 0:56
  • $\begingroup$ Can it not be unpiecwised into a diophantine (only integer solutions) function? $\endgroup$ – Web_Designer Jun 27 '17 at 0:57
1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thanks Matthew. Is it possible to evaluate something like that online? What does the $r \neq i$ mean? How does that give a starting value for the variable $r$ to progress from? $\endgroup$ – Web_Designer Jun 27 '17 at 8:05
  • $\begingroup$ In the sums, $i$ and $j$ start as 1 and run to n. In the products, $r$ and $s$ start as 1 and run to n, but if $r=i$ or $s=j$ the term is skipped. This polynomial is not the only one that would give the proper values for the sample points. You could use Mathematica or something similar to write a program that would calculate the polynomial and simplify the expression. It would be interesting to see if the polynomial doesn't change after a certain amount of sample points are used. This method won't be able to converge to your exponential example for finitely many points. $\endgroup$ – Matthew Harasty Jun 27 '17 at 16:14
0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ As a follow up, I would read up on Sequences of Functions. I am taking your question somewhat literally - as an example I've completely ignored the interpolate tag because your question isn't really about that. But if your real question is about finding the best statistical fit for a surface I would rework the question. $\endgroup$ – Phillip Hamilton Jun 27 '17 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.