I'm looking for some sort of function $f$ that can take any integer $n>0$ and give a real number $100 \le m \lt 200$ such that if $a \lt b$ then $f(a) \lt f(b)$. How can I do that? I'm a programmer and I need this for an application of mine.
Asked
Active
Viewed 362 times
3
-
Is $m$ a real number or an integer? – Wintermute Mar 31 '13 at 12:59
-
m is real number – Rachid O Mar 31 '13 at 13:01
-
Is $n$ an integer or a real number? – Erick Wong Mar 31 '13 at 13:05
-
i mentioned that the formula can take any number from (1,2,3,...) so i think it's obvious that it's an integer – Rachid O Mar 31 '13 at 13:07
3 Answers
8
Try
$$f(x)= 150 + 50 \cdot \frac{x}{1+|x|}$$
This is a bijection from $\mathbb{R}$ to $(100,200)$.
The graph is

which gives you the idea why it is monotone and why it works.
Dominic Michaelis
- 19,935
-
1
-
your answer wasn't exactly what i was looking for but i modified it to this $$f(x)= 200 \cdot \frac{x}{1+|x|}$$ – Rachid O Mar 31 '13 at 13:17
-
1
-
@RachidO.: Note that your modified function doesn't do the trick for all reals, but only for reals $\ge1.$ – Cameron Buie Mar 31 '13 at 13:29
-
1@RachidO. Notice that for this domain that's the same as $200 - 200/(1+x)$, which makes the increasing property more obvious. Perhaps a slightly simpler function would be $200 - 100/x$. – Erick Wong Mar 31 '13 at 17:16
-
@ErickWong yes you are right and your solution is nice too and more simple :) – Rachid O Mar 31 '13 at 17:54
2
$\tan\dfrac{\pi (x-150) }{100 } $ is a monotone bijection from $(100,200)$ to $\mathbb{R}$. (You can obtain it by looking at $\tan x$ and then trying a linear function). The inverse of this is the function you want.
Ishan Banerjee
- 6,459
2
$f(n)=200-2^{-n}$ satisfies your criteria.