2
$\begingroup$

There are two variables, let's say $x$ and $y$.

I want to come up with a function $f:[0,5]\times[0,5]\longrightarrow[0,5]$ that respects the following rules:

  1. If $x$ is high (close to the maximum value of 5) and $y$ is low (close to $0$), $f(x,y)$ should results in a high value (close to 5). The same would happen for the reverse ($x$ with a low value and $y$ with a high value)
  2. If $x$ is high and $y$ is high, $f(x,y)$ will also be high; it would be useful that the values resulted would be higher than those from point $(1)$.
  3. If $x$ is low and $y$ is low, $f(x,y)$ should result in low values.

I'm having troubles starting imagining what mathematical functions would be useful, as I am not even close to being advanced in the concepts of Mathematics. Any ideas would be appreciated, at least in the sense of finding any information that could get me started.

$\endgroup$
7
  • 1
    $\begingroup$ you defined your function $f :[0,5]\rightarrow [0,5]$, and then you talk about two input variable $x$ and $y$, i guess you meant $f :[0,5]\times [0,5] \rightarrow [0,5]$ ? $\endgroup$
    – lufydad
    Aug 11 at 11:47
  • 1
    $\begingroup$ that is correct, I'll add the change. $\endgroup$ Aug 11 at 11:48
  • $\begingroup$ If you have precise value for your function $f$, you could use something like multivariate interpolation. $\endgroup$
    – lufydad
    Aug 11 at 11:52
  • $\begingroup$ If you don't know the concept of interpolation you should check out first 1D interpolation like this one. $\endgroup$
    – lufydad
    Aug 11 at 11:57
  • 1
    $\begingroup$ If $f(x,y)=f(y,x)$, and $f(x,y)$ is linear with respect to $x$ (this was not part of the problem statement, it was added by me to ensure uniqueness of solution), then $f(x,y)=axy+b(x+y)+c$. Let $f(0,0)=0$, $f(5,5)=5$, then $c=0$, $5a+2b=1$. If one wants to set value $f(0,5)=d$, then $b=\frac{d}{5}$, $a=\frac{5-2d}{25}$. At $d=5$ result is formula from my previous comment, but OP can take $f(0,5)=d=4.9$ or something else what needed. $\endgroup$ Aug 12 at 7:14

2 Answers 2

4
$\begingroup$

You can take, for instance,$$f(x,y)=\frac45\max\{x,y\}+\frac15\min\{x,y\}.$$It has all the properties that you are interested in.

$\endgroup$
2
$\begingroup$

One way to model this could be to use the distance from the line: $$ x+y=0 $$ through $(0,0)$. This line has normal vector: $$ \vec n= \begin{pmatrix} 1\\ 1 \end{pmatrix} $$ and the distance of a given point $(x,y)$ to this line is proportional to $t=\vec n\cdot\langle x,y \rangle=x+y$ so in case we want something like: $$ f(5,5)=5\\ f(5,0)=4\\ f(0,0)=0 $$ we can connect this to a single dimensional function: $$ f(x,y)=g(x+y) $$ where $$ g(10)=5\\ g(5)=4\\ g(0)=0 $$ A way to achieve this could be to add the extra requirement $g'(10)=0$ so that $f$ has maximum at $(x,y)=(5,5)$ and build $g(0)=0$ in: $$ g(t)=at^3+bt^2+ct $$ Hence $$ \begin{align} g(10)&=1000a+100b+10c&&=5\\ g(5)&=125a+25b+5c&&=4\\ g'(10)&=300a+20b+c&&=0 \end{align} $$ which can be solved for $a,b,c$ to have: $$ f(x,y)=g(x+y)=0.002(x+y)^3-0.09(x+y)^2+1.2(x+y) $$

See this link to look at interactive GeoGebra-applet with 3D-plot of this function


ADDENDUM: As can be seen both from the other answer and from comments, there will be (infinitely) many ways to satisfy your requirements, but to point you towards handling the additional requirement stated in your comment below this post, you could simply add a modifier to the above solution which takes the distance to the perpendicular line: $$ x-y=0 $$ as input. This distance is (similarly) proportional to $t=x-y$, and so we need a modifier function $m(x,y)=h(x-y)=h(t)$ that satisfies: $$ h(0)=0\\ h(5)=m(5,0)\\ h(-5)=m(0,5) $$ so just choose which modification you want at $(5,0)$ and $(0,5)$ and match for instance a quadratic function as $h$: $$ h(t)=\alpha t^2+\beta t+\gamma $$ and combine: $$ \begin{align} q(x,y) &=f(x,y)+m(x,y)\\ &=g(x+y)+h(x-y)\\ &=a(x+y)^3+b(x+y)^2+c(x+y)+\alpha(x-y)^2+\beta(x-y)+\gamma \end{align} $$ but be a little careful - if $h(t)$ increases too rapidly away from $h(0)$ to one side, then $q$ may exceed a value of $5$.

Here is GeoGebra-applet with example of this technique

$\endgroup$
2
  • $\begingroup$ Very interesting and detailed answer. With the risk of going a bit outside the boundaries of the question: is there a way to introduce some kind of bias towards $x$ or $y$? In the sense that $f(x,y)$ should be greater than $f(y,x)$ or the opposite. $\endgroup$ Aug 16 at 13:06
  • 1
    $\begingroup$ @Ionut-AlexandruBaltariu: I added an extra section about this. Generally, you can always combine two one-dimensional functions $g(x+y)$ and $h(x-y)$ to create formula for change in value when you move perpendicular to the two lines $x+y=0$ and $x-y=0$. This gives you a lot of control over what you want to happen. Just be careful, because combinations may escape the max/min values, since we only controlled them in points $(0,0),(5,0),(0,5)$ and $(5,5)$. $\endgroup$
    – String
    Aug 17 at 8:41

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.