Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
2  
Could you better explain your problem? –  Sigur Aug 20 '12 at 12:47
2  
Your use of "=" has so many people rolling in their graves now I think you have triggered the mathematician zombie apocalypse. Do you mean something like capping a sequence $f(1),f(2),f(3)\dots$? –  rschwieb Aug 20 '12 at 12:49
14  
From here: $$\frac{x+20-|x-20|}{2}$$ –  J. M. Aug 20 '12 at 12:49
4  
@GustavoBandeira You shouldn't put "=" between quantities that aren't equal. If you do, you have a false statement. Writing "22=20" is as absurd as writing "0=1". –  rschwieb Aug 20 '12 at 13:07
3  
@GustavoBandeira Yeah, that's a much better version :) People will understand you more quickly. –  rschwieb Aug 20 '12 at 17:17

3 Answers 3

up vote 9 down vote accepted

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

share|improve this answer

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.