6
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ Commented Mar 2, 2015 at 21:09
  • 1
    $\begingroup$ Thanks, I actually ended up finding the answer I wanted here, math.stackexchange.com/questions/172439/… . Oddly, I only found it using Google instead of the internal search function. $\endgroup$
    – purple
    Commented Mar 2, 2015 at 21:17
  • 4
    $\begingroup$ Does this answer your question? Approximate $|x|$ with a smooth function $\endgroup$
    – adabru
    Commented Mar 25, 2021 at 10:08

3 Answers 3

12
$\begingroup$

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

$\endgroup$
1
  • 4
    $\begingroup$ 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. $\endgroup$ Commented Mar 2, 2015 at 21:21
3
$\begingroup$

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$.

$\endgroup$
2
  • 1
    $\begingroup$ 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)$. $\endgroup$ Commented Mar 2, 2015 at 22:38
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Mar 2, 2015 at 22:45
2
$\begingroup$

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

$\endgroup$

Not the answer you're looking for? Browse other questions tagged .