7

Are there any good approximations of the absolute value function which are $C^2$ or at least $C^1$? I've thought about working with exponentials and then adding in more terms to keep the function from growing too fast away from zero, but I was hoping to find something a bit neater.

purple
  • 73
  • Welcome to MSE! "Good" often resides in the eye of the beholder. (For example, there are obvious real-analytic uniform approximations.) Do you have some specific purpose in mind, and if so, could you please add it to your question? – Andrew D. Hwang Mar 02 '15 at 21:09
  • 1
    Thanks, I actually ended up finding the answer I wanted here, http://math.stackexchange.com/questions/172439/smooth-approximation-of-absolute-value-inequalities . Oddly, I only found it using Google instead of the internal search function. – purple Mar 02 '15 at 21:17
  • 4

3 Answers3

13

A "natural" approximation of $x \mapsto |x|$ is given by the hyperbola $$x \mapsto \sqrt{x^2+c}$$ for some $c > 0$.

  • 4
    In the same vein, but with asymptotically better convergence, one can use $\log(e^{2 x}+1)-x$. The "faster" the inner function grows, the better the convergence. – Fengyang Wang Mar 02 '15 at 21:21
4

How about $$ \newcommand{\abs}[1]{\left\lvert#1\right\rvert} f_\epsilon(x) = \begin{cases} \abs{x} & (\abs{x} \geqslant \epsilon) \\ \abs{x}\left(1 - e^{\textstyle\frac{x^2}{x^2 - \epsilon^2}}\right) & (\abs{x} < \epsilon) \end{cases} $$ [I'm reminded of Littlewoood's anecdote, "$\ldots$ where $\epsilon$ is very small"! Can one fix this in MathJax?]

If my magnifying glass can be relied upon, the exponent in that expression is: $$ \frac{x^2}{x^2 - \epsilon^2}. $$

If I'm not mistaken, $f_\epsilon$ is $C^\infty$ on $\mathbb{R} \setminus\{0\}$, and $C^1$ at $0$; $f_\epsilon''(0) = 0$; and $0 \leqslant f_\epsilon(x) \leqslant \epsilon$ if $\abs{x} \leqslant \epsilon$.

  • 1
    You could use $e^{\textstyle \frac{x^2}{x^2 - \epsilon^2}}$ or even $e^{\displaystyle \frac{x^2}{x^2 - \epsilon^2}}$; but I suspect the cleanest notation is simply $\exp\left(\frac{x^2}{x^2 - \epsilon^2}\right)$. – Ilmari Karonen Mar 02 '15 at 22:38
  • 1
    The Littlewood typesetting anecdote actually concerned a minuscule $\sigma$ rather than a minuscule $\epsilon$ (a mistake others on the Net have also made, so it could too easily go uncorrected): see e.g. here, or here. – Calum Gilhooley Mar 02 '15 at 22:45
4

enter image description hereJust simply $$x. \tanh(\alpha x)$$ Example plot