Convert any positive number to decimal $x$ such that $0\lt x \lt 1$.

501 Views Asked by At

This is a very basic question, I understand that.

So I have these numbers: 20, 0.75, 1.25. If you sort them, it would look like this:

20
1.25
0.75

I need to convert any number that's greater than 1 to a decimal that's less than 1 and greater than 0, and still sort like above.

So I thought about dividing 1 by that number. But naturally, that's not going to work with the 0.75, so 0.75 will be greater than 20.

So what formula can I apply to any positive number so that they all are less than 1 and greater than 0, and they still sort correctly with this new value (i.e. #1: 20, #2: 1.25, #3: 0.75)

3

There are 3 best solutions below

0
On BEST ANSWER

There are many approaches. You need an increasing function that has a horizontal asymptote. One simple one is $f(x)=\frac x{1+x}$. When $x=0, f(x)=0$ and as $x$ gets large $f(x)$ goes to $1$.

0
On

What about $\frac x{x+1}$? It's an increasing function with values in $[0,1)$.

0
On

Try the following function:

$$S(x) = \frac 1{1+e^{-x}}$$

This function has the following graph:

enter image description here

Now, if all of your values are non-negative, you will want to use the following function:

$$S(x) = \frac 2{1+e^{-x}} - 1$$