0
$\begingroup$

A user on the chat asked how could he make something that would cap when it gets a specific value like 20. Then the behavior would be as follows:

$f(...)=...$

$f(18)=18$

$f(19)=19$

$f(20)=20$

$f(21)=20$

$f(22)=20$

$f(...)=20$

He said he would like to perform it with a regular calculator. Is it possible to do this?

  • 0
    Of course if you chose a moderately large, but finite $n$ ($n=10$ is already quite good), my formula can be used on a standard scientific calculator. While it only gives an approximation, only for values near $x=20$ the approximation differs from the exact value less than the numeric error. However, for too small $x$ you may get an overflow.2012-08-21

3 Answers 3

9

$ x \mapsto \min ( x , 20 ) $

1

We can also get a bit (unnecessarily) fancier: $ f(x) = x + (20 - x) \int\limits_{-\infty}^{x-20} \delta(t)\ dt $ where $ \int\limits_{-\infty}^{x-20} \delta(t)\ dt = \begin{cases} 0 & x < 20 \\ 1 & x \ge 20 \end{cases} $ (See Heaviside step function.)

0

While we are at fancy expressions, what about $20-\lim_{n\to\infty}\frac1n\ln\left(1+\mathrm e^{n(20-x)}\right)$