2
$\begingroup$

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}]
$\endgroup$
  • 3
    $\begingroup$ so basically if the $x+y\lt2, z=0 \text{and if} x+y\ge2, z=1$ $\endgroup$ – Eleven-Eleven Sep 2 '13 at 13:34
  • $\begingroup$ That's a good one, but not exactly what I want. I have modified the question, please have a look. $\endgroup$ – qed Sep 2 '13 at 13:40
  • $\begingroup$ 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)$. $\endgroup$ – Eleven-Eleven Sep 2 '13 at 13:43
  • $\begingroup$ It doesn't matter how it behaves there, just fit the surface and restrict it to {0, 1, 2}, am I right? $\endgroup$ – qed Sep 2 '13 at 13:47
  • $\begingroup$ SO you want to fit the 9 points to a surface in $\mathbb{R}^3$. I've been working on it...not so easy $\endgroup$ – Eleven-Eleven Sep 2 '13 at 14:03
4
$\begingroup$

$$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$

enter image description here

3D plot

enter image description here

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

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.