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

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

-
You may construct an interpolating polynomial function with your three values 0, 10 and 20. It may be helpful. – Dutta Aug 15 '13 at 12:12
Ok, how would I do that? (sorry, math newbie here) – Daniel Magliola Aug 15 '13 at 12:20
Do you want it to have zero slope at $x = 20$? Is it important that $f(x) \le 100$ for $0 < x < 20$? – bubba Aug 15 '13 at 12:41
Searching a solution for $y = 100 - e ^ (-ax + b)$ with $f(0)=0, f(10)=70$ (ignoring the $f(20)$ constraint) we get : $$f(x)=100\;\left(1-e^{\ln(0.3)x/10}\right)$$ (this gives $f(20)\approx 91$ with a smooth convergence of $f(x)$ to $100$ as $x\to\infty$) – Raymond Manzoni Aug 15 '13 at 13:10

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.

-
Awesome, thank you so much! Especially for giving me the explanation of how you derived those coefficients, I was able to play with a linear solver and graphing it in excel, and ended up with the same equation shape, same solution, but slightly different numbers, which worked better for my case. Thanks!!! – Daniel Magliola Aug 16 '13 at 17:26

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

-

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

-