0

I'm trying to implement a mathematical method for calculation of injustice. The formula depends on two variables $a>=1$ and $b>=1$ and returns a fraction $a/b$.

$a/b=1$ indicates justice. If $a/b<1$ the injustice is to your advantage. If $a/b>1$ the injustice is to your disadvantage.

Now I would like to set aside advantage/disadvantage and only calculate the size of the injustice. I'm having trouble figuring out an easy way to get the same result for $a/b$ as $b/a$.

Anyone have any idea of how I can do this?

Dough
  • 3
  • 1
  • 2
    Not entirely sure what you are trying to do, but $F\left(\frac ab\right)=|\log \frac ab|=|\log a - \log b|$ might be what you are after. Easy to see that $F\left(\frac ab\right)=F\left(\frac ba\right)$ and $F\left(\frac ab\right)=1\implies a=b$. – lulu Jan 15 '19 at 17:31
  • Log seems to be a perfect solution. Thank you @lulu! – Dough Jan 15 '19 at 17:34
  • No problem. Note: There's a typo in my comment. I meant to write that $F\left(\frac ab\right)=0 \implies a=b$ – lulu Jan 15 '19 at 17:38

2 Answers2

2

As noted in the comments:

The function $$F\left(\frac ab\right)=|\log \frac ab|=|\log a - \log b|$$

gets the job done.

It is easy to see that $$F\left(\frac ab\right)=F\left(\frac ba\right)$$ and that $$F\left(\frac ab\right)=0\iff a= b$$ which appear to be the two desired properties.

lulu
  • 70,402
0

Perhaps simpler than logarithms would be to define the injustice to be the larger of $a/b$ and $b/a$.

Andreas Blass
  • 71,833