0

My question is very similar to this question. The difference is that my function is taking in two arguments, not just one.

I need a function similar to f(a, b) = log(a / b) except it should output values with a range between [0,1] or [-1,1]. Currently, the result of log(a / b) ranges from -infinity to +infinity. Note that a and b will always be positive integers. Also, it is perfectly acceptable to say "a must be bigger than b" if that is convenient.

For my purposes, log(a/b) is great because log(a/b) + log(b/a) = 0. I just need to restrict the range.

If the range of the function is [0,1], then I'd like it so that f(a,b) - f(b,a) = 0.

If the range of the function is [-1,1], then I'd like it so that f(a,b) + f(b,a) = 0.

  • For anyone wondering, I like log(a / b) for my purposes because it has this important property: log(a/b) + log(b/a) = 0. It is okay if your answer does not have this property, though (but it is preferred). – Jacobjanak May 03 '22 at 19:04
  • 1
    $\frac{a}{a+b}?$ Basically, $x\mapsto\frac{e^x}{1+e^x}$ sends $\mathbb R\to (0,1).$ But when $x=\log(a/b),$ you get $\frac{a}{a+b}.$ – Thomas Andrews May 03 '22 at 19:09
  • 1
    It can’t have $f(a,b)+f(b,a)=0$ if the range of $f$ is in$[0,1]$ and is not constant. But $f(a,b)=\frac{a}{a+b}$ has $f(a,b)+f(b,a)=1.$ – Thomas Andrews May 03 '22 at 19:12
  • 1
    If you allow a range of $[-1,1]$ you can choose $f(a,b)=\frac{a-b}{a+b},$ which gives $f(a,b)+f(b,a)=0.$ This still assumes $a,b>0.$ – Thomas Andrews May 03 '22 at 19:15
  • Your first comment should be part of the question. People shouldn’t have to read the comments to know what you want. – Thomas Andrews May 03 '22 at 19:17
  • 1
    As a slight modification, $\frac {a^2+1}{a^2+b^2+2}$ is defined for all $a,b$., satisfies $f(a,b)+f(b,a)=1$, and lies between $0$ and $1$ for all $(a,b)$ (reaching both $0$ and $1$ as limiting values). – lulu May 03 '22 at 19:18
  • @ThomasAndrews Thank you so much, Thomas! I was silly for thinking I could achieve f(a,b)+f(b,a) = 0 given the range I was looking for. But thankfully it's perfectly okay for my purposes to use range [-1,1]. So I will try using (a-b)/(a+b)! – Jacobjanak May 03 '22 at 19:22
  • 1
    @lulu Might as well go the whole hog and say $$\frac{g(a)}{g(a)+g(b)}$$ for any positive function $g.$ – Thomas Andrews May 03 '22 at 19:23
  • @ThomasAndrews Sure. – lulu May 03 '22 at 19:25
  • @ThomasAndrews I updated my original question. If you want, you can now post (a-b)/(a+b) and I will mark that as the accepted answer. – Jacobjanak May 03 '22 at 19:35

0 Answers0