Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not very good at mathematics, so please bear with me.

How can you determine / define a function based on sets of values of its input and output parameters.

You have: $f(x_{1_1}, x_{1_2}, \ldots , x_{1_n}) = y_1$

$f(x_{2_1}, x_{2_2}, \ldots , x_{2_n}) = y_2$


$f(x_{n_1}, x_{n_2}, \ldots , x_{n_n}) = y_n$

You want: $$f(x_1, x_2, \ldots , x_n) = a_1(x_1)^{b_1} + a_2(x_2)^{b_2} + \cdots + a_n(x_n)^{b_n}$$

Let's assume that you have enough (how much is enough?) sets of input and output parameters.

What software could do this and how (excel, mathematica, r, ... ?). I'm looking for the simplest solution.

p.s. I need it only to define $f(x_1,x_2)=y$ function, but at the same time I'd like to learn more about all of this. Thank you for your time and answers.

share|cite|improve this question
The answer won't always necessarily be unique, so you need to make a decision on how you want to "fill in the gaps". Read this for starters: – tomcuchta Dec 28 '11 at 20:07
How sure are you about the exact form of the "you want" function? It would be a much more approachable problem if you were looking for a polynomial solution -- that is, if you allowed more than one term containing each variable, and required the exponents to be integers. – Henning Makholm Dec 28 '11 at 20:34
Well I assume (99%) that it is polynomial, I could also assume (80%) that exponents are integers. – Ben Dec 28 '11 at 21:16
How about having more terms for each variable, and/or cross terms? Do you have an upper bound for the exponents? Are you free to choose the sample points? – Henning Makholm Dec 28 '11 at 23:17
I am free to choose the sample points. Well there definitely is an upper bound for exponents, I guess it should be 3 or 4. – Ben Dec 28 '11 at 23:48
up vote 3 down vote accepted

You are solving a set of nonlinear simultaneous equations. As you have $2n$ values to evaluate (all the $a_n$'s and all the $b_n$'s) you need $2n$ pieces of data. In general there will be many solutions because of the $b_n$ exponents-do you really mean that? If all the $b_n$ are $1$ the problem is linear and much easier. For the linear problem the solutions are not hard and Excel's matrix tools will find the solution. For the nonlinear problem you will probably find too much of a mess without using a multidimensional function minimizer, found in many numerical analysis texts (and Excel's Goal Seek) but that gives a numeric answer, not an algebraic one.

share|cite|improve this answer
I have no idea what kind of a function f(x,y) could be. What I mean was that I would want to get something like this: f(x,y) = 5*x^3 *y^2 + 7*x^2*y^4 + 3xy + 5y^2 – Ben Dec 28 '11 at 20:19

Each data point $f(x_{i,1},\ldots,x_{i,n}) = y_i$ corresponds to one equation in the $2n$ variables $a_1, b_1, \ldots, a_n, b_n$. "Typically" you'd want the same number of equations as variables. Unfortunately these are nasty transcendental equations. It's hard to predict whether real solutions will exist or be unique, and finding them will almost certainly require numerical methods. Maple, Mathematica, Matlab, maybe even Excel will probably be able to solve the equations. For example, here's Maple on a randomly-chosen case with $n=3$.

eqs:= {a1*5^b1+a2*2^b2+a3*5^b3 = 6, a1*2^b1+a2*3^b2+a3*4^b3 = 4, a1*6^b1+a2*5^b2+a3*3^b3 = 1, a1*5^b1+a2*2^b2+a3*3^b3 = 2, a1*2^b1+a2*4^b2+a3*3^b3 = 3, a1*1^b1+a2*2^b2+a3*5^b3 = 4};


${a1 = -3.575581132, a2 = 6.279366686, a3 = -30.92905576, b1 = 66.19615719, b2 = -2.879205097, b3 = 11.74564989}$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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