4

A few years ago I derived the following formula which I just came across in my notes:

$$\min(x,y)=\log\left(\frac{e^x+e^y}{1+e^{|x-y|}}\right)=y+\log\left(\frac{1+e^{x-y}}{1+e^{|x-y|}}\right).$$

Has anyone seen this before, and if so is there a reference? There is also a version for $\max$,

$$\max(x,y)=\log \left(\frac{e^x+e^y}{1+e^{-\left| x-y\right| }}\right).$$

At the time (rightly or wrongly!) I thought maybe it might shed light on "$\min$" and "$\max$" analogies for complex numbers, but apart from producing a new complex number (different to $x$ and $y$) it didn't yield much. Still I'd not seen this before so thought it might be of interest... Works perfectly for the reals.

UPDATE

Apparently this is related to the Softmax function.

pshmath0
  • 10,565
  • Here is a "simpler" one: http://math.stackexchange.com/questions/46939/modus-operandi-formulae-for-maximum-and-minimum-of-two-numbers-with-a-b-and (also based on $|x-y|$. – Martin R May 18 '15 at 20:27
  • 1
    It does look similar to the "softmax" function: http://www.johndcook.com/blog/2010/01/20/how-to-compute-the-soft-maximum/ – Andre May 18 '15 at 20:27
  • @Andre I wasn't aware of the softmax function. Seems then that softmax can be transformed into the usual max by adding $-\log(1+e^{|x-y|})$ to it. Interesting. – pshmath0 May 18 '15 at 20:31

1 Answers1

2

Whether it's related to softmax or not, we have $$ \log\left(\frac{1+e^{2t}}{1+e^{|2t|}}\right)= \log\left(\frac{e^t\cosh t}{e^{|t|}\cosh|t|}\right)= t-|t| $$ For $2t=x-y$, we get that your second expression for the minimum is $$ y+\frac{x-y}{2}-\frac{|x-y|}{2}=\frac{1}{2}(x+y-|x-y|) $$ which is a well known expression for $\min\{x,y\}$ and much less heavy from a computational point of view.

egreg
  • 238,574