# Looking for a function given these inputs and ouputs

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?

Thanks

-
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
add comment

## 2 Answers

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

-
add comment

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.

-
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
add comment