# Describing a third variable with two other variables, using combination of elementary functions.

I have an array of three variables as follows:

$$\begin{array}{ccccccc} X & Y & Z \\ 0 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 2 & 1 \\ 1 & 0 & 0 \\ 1 & 1 & 1 \\ 1 & 2 & 1 \\ 2 & 0 & 1 \\ 2 & 1 & 1 \\ 2 & 2 & 1 \\ \end{array}$$

I am looking for a function $f:(X,Y) \rightarrow Z$, using only combination of elementary functions, I also want $f$ to be differentiable.

At first look, it looks all discrete, but I can imagine it's possible to fit a continous surface through these discrete points.

Daniel did a superb job in his answer, I would like to put the Mathematica code here to demonstrate how he solved the problem:

m2 = {{1, 1, 1, 1}, {16, 8, 4, 2}, {81, 27, 9, 3}, {256, 64, 16, 4}}
m2.{b1, b2, b3, b4} == {0, 1, 1, 1}
Solve[{b1 + b2 + b3 + b4, 16 b1 + 8 b2 + 4 b3 + 2 b4,
81 b1 + 27 b2 + 9 b3 + 3 b4, 256 b1 + 64 b2 + 16 b3 + 4 b4} == {0,
1, 1, 1}, {b1, b2, b3, b4}]

• so basically if the $x+y\lt2, z=0 \text{and if} x+y\ge2, z=1$ – Eleven-Eleven Sep 2 '13 at 13:34
• That's a good one, but not exactly what I want. I have modified the question, please have a look. – qed Sep 2 '13 at 13:40
• you still only have a set of discrete points. According to your array the function is defined on the set $S=\{0,1,2\}$. We don't know the behavior of the function at say $(1/2,1/2)$. – Eleven-Eleven Sep 2 '13 at 13:43
• It doesn't matter how it behaves there, just fit the surface and restrict it to {0, 1, 2}, am I right? – qed Sep 2 '13 at 13:47
• SO you want to fit the 9 points to a surface in $\mathbb{R}^3$. I've been working on it...not so easy – Eleven-Eleven Sep 2 '13 at 14:03

## 1 Answer

$$f(X,Y)=\left\lceil\dfrac{\left\lfloor\dfrac{X+Y}{2}\right\rfloor}{2}\right\rceil$$

For the differentiable case, try the polynomial

$$f(\alpha)=\frac18\alpha^4-\frac{13}{12}\alpha^3+\frac{23}8\alpha^2-\frac{23}{12}\alpha$$

Then $\alpha = X + Y$

3D plot

• This is ingenious! But please have a look at the modified question. Thanks! – qed Sep 2 '13 at 13:48
• Oh, piece-wise defined function is exactly what I want to avoid. – qed Sep 2 '13 at 14:33
• @qed: Ah, how about now? – Daniel R Sep 2 '13 at 15:04
• Er, when $\alpha = 1$, $f(\alpha) = 1/2$, which is incorrect. But I got the idea, this is very clever! – qed Sep 2 '13 at 15:26
• @qed: Yeah, that was a typo (I wrote $\frac{27}8$ instead of $\frac{23}8$). Now it should work. – Daniel R Sep 2 '13 at 15:28