1
$\begingroup$

I'm programming a game and am looking to create a non-linear relationship between input and output, such that as the input increases, the output increases, but the higher the input value, the corresponding output increment is less and less.

I've looked at logarithms, and that seems to be the effect I'm looking at.

o = log(i), where o is the output value and i is the input value.

But this is too extreme - the curve is too steep. If I try to modify this with

o = log(i)k, where k is some constant multiplier, creates too steep of a curve in the lower end.

I'd like to find a way to make the falloff more gradual. Unfortunately, I can't seem to find any other functions in my programming language (ActionScript 3) that will do the trick.

Where should I be looking? Are there any functions I should be trying to replicate?

Thanks in advance - I realize this is a pure maths forum, but it seemed like the best place to ask.

  • 0
    The slope of say $(1+i)^{1/2}-1$ does approach $0$ as $i$ gets large. But maybe not fast enough for you. What about $1-2^{-i}$, for $i \ge 0$? Slope approaches $0$ very fast, and we are linear near $0$. To make the effect less extreme, divide $i$ by $3$ or $4$.2011-08-04

2 Answers 2

1

I would suggest trying a function of the form f(X)=A*(1-exp(-B*x))+C.

This functional form gives you pretty good control over the appearance of the curve since it starts with f(0)=C and converges to f(inf)=A with the rate of convergence given by B.

  • 0
    @Tom Auger, Thinking about it a little bit more I think you should try f(x)=A*(1-exp(-B*x^n))+C, this should give you a finer control over the convergence of the function.2011-08-05
0

I'm by far not the smartest guy in math, admittedly, but through brute trial-and-error, this function seems to achieve what I need:

for a factor f - if greater than 1.0, you'll have a "flattening" of the curve (gamma) and if between 0.0 and 1.0, you'll get a "bumping" of the curve

for a range from 0 - max

x^f / max^f * max

Example on Wolfram Alpha here