Logarithmically decreasing output from linearly increasing input.

I am trying to create a logarithmically decreasing output from a linearly increasing input. Say that I have two graphs, one representing the input and the other representing the output, I have a linear one (the input) that starts at zero and increases linearly to $255$, while the other one (the output) will need to start at $255$ and decrease fast before evening out and ending at zero.

This is to be used for filtering joystick controller input. I am looking for a function that looks something like this: $f(x) = 255 - Kx$, where $K$ is the value that I'm struggling to find.

I have been scratching my head for a while and would appreciate some guidance.

What do you think about $f(x) = 255 - a \cdot \log(x+1)$ where $a = 255/\log(256) \approx 46$?

• Beautiful! Thank you. Commented Apr 21, 2018 at 22:32

Decreasing fast and evening out sounds more like an exponential. You might be interested in

$$f(x) = 255e^{-kx}$$

For some very small positive value of k.