Well, there are tons and tons of functions that never go higher than 500. One of them is $f(x) = \min (x, 500)$ (in Javascript, Math.min(x, 500)
). This function simply gives you either $x$ or 500, whichever is smaller.
We might be able to "build" a function that behaves more nicely. The function $e^x$ is never less than 0, which means that $-e^x$ is never more than 0, which means that $500 - e^x$ is never more than 500. But if you look at a graph of this function, you'll see that as $x$ gets larger, $500 - e^x$ gets smaller.
We can make things go the other way around, though. We know that as $x$ gets larger, $-x$ gets smaller, and that as $-x$ gets smaller, $500 - e^{-x}$ gets larger. So, as $x$ gets larger, $500 - e^{-x}$ gets larger. Here's a graph of this function. In Javascript, that function is 500 - Math.exp(-x)
.
The thing is, if $x = 0$, then $500 - e^{-x} = 499$, so this function doesn't do a great job of leaving small values of $x$ alone. After a bit of experimenting, I've come up with the function $f(x) = 500 (1 - e^{-x/500})$ (in Javascript, 500 * (1 - Math.exp(-x/500))
). For small values of $x$, $f(x)$ is approximately $x$, but for large values of $x$, $f(x)$ is approximately 500.