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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the function f(x)= that produces these discrete values:

input   output
[0-1500]     13
]1500-3000]  12
]3000-6000]  11
]6000-12000] 10

Update: sorry for the lack of precision at the interval limits. Updated. Could you update your answers accordingly?


share|cite|improve this question
Do the endpoints of the input intervals (e.g. 1500, 3000, 6000) belong to the set of smaller, or larger numbers? – Eugene Shvarts Aug 27 '12 at 14:08
Do you want a continuous function? If not, you can use step function. – Sigur Aug 27 '12 at 14:20
up vote 0 down vote accepted

It can be computed as $$x \mapsto \begin{cases}13 & 0 < x < 1500 \\ 13 - \left\lceil \log_2(\frac{x}{1500}) \right\rceil & x \ge 1500 \end{cases} $$

share|cite|improve this answer

Assuming the endpoints of the interval belong to the set of smaller numbers, so that $f((1500,3000]) = \{12\}$ and $f(1500) = 13$ , I'd use $$ f(x) = \begin{cases} 13 & x \le 1500~~, \\ 13 - \left\lceil \log_2 \frac{x}{1500} \right\rceil & \text{else}. \end{cases} $$ To implement the log, you can use $ \frac{\log x - \log 1500}{\log 2} $ . To switch the endpoints to the other interval, use a floor instead of a ceiling.

share|cite|improve this answer
updated the question. – Nicolas Cadilhac Aug 27 '12 at 15:03
Thanks Eugene. Gave the good answer to Henning because he answered a few seconds prior to you. Voted up yours for the log2 reminder. – Nicolas Cadilhac Aug 27 '12 at 15:24
@NicolasCadilhac Updated the answer as requested. Hope it works out for you! – Eugene Shvarts Aug 27 '12 at 15:32

Your Answer


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.