Find an f(x) that fits specific critera (Polynomial Regression)

75 Views Asked by At

I need a function (I don't care how messy it is) that when:

$f(1) = 1$ <--this has $1!$ different terms

$f(2) = a-b$ <--this has $2!$ different terms

$f(3) = a^2b-a^2c-b^2a+b^2c+c^2a-c^2b$ <--this has $3!$ different terms

$f(4) = a^3b^2c-a^3b^2d-a^3c^2b+a^3c^2d+a^3d^2b-a^3d^2c-b^3a^2c+b^3a^2d+b^3c^2a-b^3c^2d-b^3d^2a+b^3d^2c+c^3a^2b-c^3a^2d-c^3b^2a+c^3b^2d+c^3d^2a-c^3d^2b-d^3a^2b+d^3a^2c+d^3b^2a-d^3b^2c-d^3c^2a+d^3c^2b$ <--this has $4!$ different terms

$f(5) = a^4b^3c^2d-a^4b^3c^2e-a^4b^3d^2c+a^4b^3d^2e+a^4b^3e^2c-a^4b^3e^2d-a^4c^3b^2d+a^4c^3b^2e+a^4c^3d^2b-a^4c^3d^2e-a^4c^3e^2b+a^4c^3e^2d+a^4d^3b^2c-a^4d^3b^2e-a^4d^3c^2b+a^4d^3c^2e+a^4d^3e^2b-a^4d^3e^2c-a^4e^3b^2c+a^4e^3b^2d+a^4e^3c^2b-a^4e^3c^2d-a^4e^3d^2b+a^4e^3d^2c+b^4a^3c^2d-$ <--this would have $5!$ different terms (If I typed all 120 of them)

This function lists all of the unique combinations of the letters and the powers used. Hopefully you can see the pattern between the what is stated above, I just can't find a way to describe it.

This function would be a necessary part for working out a formula for 2-dimensional polynomial regression.

I do realize that there are multiple answers for this and any help for this would be much appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

This equation works for all the values:

$$-\prod_{i=1}^{N-1}(-\prod_{j=1}^i(x_{i+1}-x_j))$$

Where $x =1,2,3,...,N-1,N$

and $N =$ length of sequence $x$

4
On

Seems to be $$ \eqalign{ & f\left( n \right) = \sum\limits_{\left\{ {j_1 , \cdots ,j_n } \right\} \in S\;even} {\left( {x_{\,j_{\,1} } - x_{\,j_{\,2} } } \right)x_{\,j_{\,3} } ^2 x_{\,j_{\,4} } ^3 \cdots x_{\,j_{\,n} } ^{n - 1} } = \cr & = \sum\limits_{\left\{ {j_1 , \cdots ,j_n } \right\} \in S\;even} {\left( {x_{\,j_{\,1} } - x_{\,j_{\,2} } } \right)\prod\limits_{3\, \le \,k\, \le \,n} {x_{\,j_{\,k} } ^{k - 1} } } \quad |\;2 \le n \cr} $$ where $S\, \text{even}$ denotes the set of the permutations of $\{1,2,\cdots,n\}$ which are even (even number of inversions).

That is, we denote $a,b,c, ...$ as $x_1,x_2,..$.
Then for example, in the case of $n=3$ we have $3!$ permutations, half of which are even and half odd. So the expression above becomes

Prod_permut_1