TITLE: approximating a maximum function by a differentiable function
QUESTION [14 upvotes]: Is it possible to approximate the $max\{x,y\}$ by a differentiable function?
$f(x,y)=max \{x,y\} ;\ x,y>0$

REPLY [2 votes]: You can use an approximation of max norm a.k.a. infinity norm with a p-norm of relatively high $p$.
Caveat #1: make sure $p$ isn't too high though because that can cause numerical instabilities, overflow to infinity, esp. if you use 32-bit floats
Caveat #2: norm works with the absolute values so you'll need to transform your numbers with e.g. log(exp(x)+1) (a.k.a. softplus) if you have to deal with negative values as well (and then back). Softplus quickly approximates $x$ for $x>20ish$ btw so this can be faster than it seems.