Need an asymptotic function that's going to have a specific shape

1.1k Views Asked by At

I'm looking for a function y = f(x) that grows quickly at first, and slowly later, asymptotically approaching 100.

I need it to hit certain specific points...

What I need is:

f(0) = 0
f(10) = 70
f(20) = 100
f( > 20) = 100 - I can cap this manually by capping the input, if necessary
f( < 0) = I don't care, it'll never happen in my use case

I know this probably should take the shape of:

y = 100 - e ^ (-ax + b)

Or something like that, but I have no idea how to find out the right coefficients to get it to have the shape I need.

Thank you!
Daniel

3

There are 3 best solutions below

1
On BEST ANSWER

Let's construct an interpolating polynomial with the conditions:

  • $ f(0) = 0 $
  • $ f(10) = 70 $
  • $ f(20) = 100 $

Since you want to set $f(x) = 100$ for $x > 100$ this condition will make it differentiable in $20$:

  • $ f'(20) = 0 $

Also let $0$ be the point with the maximum growing rate. (This is just a guess and depends and what you really mean with "grows quickly at first". If you drop this condition then a polynomial of degree 3 will work. Comparison with bubbas answer: $f''(0) = -\frac{1}{10} \neq 0 $ is not even visible to the eye. )

  • $ f''(0) = 0 $

Any polynomial that satisfies all this must at least have degree 4. So a sufficient approach is:

$ f(x) = a x^4 + b x^3 + c x^2 + d x + e $

$ f'(x) = 4a x^3 + 3b x^2 + 2cx + d $

$ f''(x) = 12a x^2 + 6b x + 2c $

With our conditions that leads to this system of linear equations:

$ \begin{pmatrix} 0 & 0 & 0 & 0 & 1 \\ 10000 & 1000 & 100 & 10 & 1 \\ 160000 & 8000 & 400 & 20 & 1 \\ 32000 & 1200 & 40 & 1 & 0 \\ 0 & 0 & 2 & 0 & 0 \\ \end{pmatrix} \begin{pmatrix} a \\ b \\ c \\ d \\ e \end{pmatrix} = \begin{pmatrix} 0 \\ 70 \\ 100 \\ 0 \\ 0 \end{pmatrix} $

The solution is:

$ f(x) = 0.0000625 x^4 - 0.008125 x^3 + 7.75x $


Lastly, to address the approach suggested in the question: $ f(x) = 100 - e ^{-ax + b} $ will not work, because it will never actually reach 100.

0
On

You can do linear regression on:

 log(100-y) = - ax + b

If only y wouldn't take the value 100.
The logarithm is then not defined.

So maybe try another constant than 100 in
your approximation. Or do a least square
gradient search to a more general function
with 3 parameters.

Bye

0
On

How about $$ f(x) = -\frac{1}{200}x^3 - \frac{1}{20}x^2 + 8x $$ Its graph looks like this:

enter image description here