# Formula to increase/decrease a relative number based on a fixed number

Being a fairly good math student in high school, this is humbling. But my knowledge about graphs and formulas has greatly diminished since then.

I'm trying to write a formula that calculates a percentage, depending on the total amount. My base is $15\%$ of $100$. Basically the percentage needs to go up as the total goes down, and vice versa. So some examples:

10000 =>  5% (500)
1000 =>  7% (70)
300 => 10% (30)
100 => 15% (15)
80 => 20% (16)
40 => 30% (12)
20 => 40% (8)
5 => 60% (3)


There would also be a limit I think, in that $0\%$ must not be possible. The upper boundary is infinite in theory, but in practice more likely to be around $100000$.

Without the deviation, the formula would be simple:

$y = 100/x*15$

But as far as the deviation goes, I could use some help. The numbers are just an example, I'll probably tinker with the variables a bit to get the exact formula.

-
Is there an upper and lower bound on the totals? Do you want a linearly relationship or a non-linear relationship between totals and percenatges? –  response May 21 '13 at 14:36
I think the relationship is non-linear, maybe exponential. I'm not sure. The lower bound would be 1, the upper bound in theory infinite, but in practice about 100000. Thinking about it, the percentage would be 100 at a total of 1. –  Peter Kruithof May 21 '13 at 14:44

You seem to be looking for a function $f\colon[1,\infty)\to(0,1]$ such that $f(1)=100\%$, $f(100)=15\%$ and $\lim_{x\to\infty}f(x) = 0\%$.

A nice family of functions to try would be $f(x) = \frac{a}{bx+c}$. Your conditions then fix $f(1) = \frac{a}{b+c}=100\%$ and $f(100)=\frac{a}{100b+c}=15\%$. Some numbers that would work are $b=17$, $c=280$ and $a=297\cdot 100\%$.

Hence the formula would be $y = \frac{297}{17x+280}\cdot 100\%$.

Since you remark that this formula decreases too fast for large $x$ you might alternatively try $f(x) = \frac{a}{b\sqrt[n]{x}+c}$ for some $n\in\{1,2,\ldots\}$.

Now your conditions on $x=1$ and $x=100$ fix $f(1) = \frac{a}{b+c}=100\%$ and $f(100) = \frac{a}{\sqrt[n]{100}b+c}=15\%$. Some numbers satisfying these requirements are $a=(3\sqrt[n]{100}-3)\cdot100\%$, $b=17$ and $c=3\sqrt[n]{100}-20$.

Hence we now have $$y = \frac{3\sqrt[n]{100}-3}{17\sqrt[n]{x}+3\sqrt[n]{100}-20}\cdot 100\%.$$ For $n=1$ this nicely reduces to the original formula, but for $n=2$ say, we get $$y = \frac{27}{17\sqrt{x}+10}\cdot 100\%.$$

-
Wow great, thanks! It's not quite there yet, but getting close. I ran a script trying every combination of constants with $a$ and $c$ between $1$ and $700$, and $b$ between $1$ and $30$. All of them seem to diverge too much from my tests, so my tests are probably not really that accurate. However your suggested constants produce good results for numbers $100$ and below. For higher numbers though the percentage drops too quickly. How can I tweak your formula to change that? –  Peter Kruithof May 22 '13 at 7:29
I updated the answer, is this any help? –  Abel May 22 '13 at 10:40
I'll try it out tomorrow, thank you so much. How do you come up with these formulas and constants? –  Peter Kruithof May 23 '13 at 14:39
Awesome, I went with $n=6$, which gave me really good results, thanks again! I'm really interested to know how you came up with this, if you have the time to explain it to me. If not, that's fine too. –  Peter Kruithof May 28 '13 at 14:41
I'll try to explain how I came up with it, but I did it mostly subconsciously. Experience I guess. You needed a decreasing function tending to $0$ for $x$ tending to $\infty$, so $f(x)=\frac{1}{x}$ came to mind. The natural generalisation would seem $af(bx+c)+d$, but since $f$ has to tend to $0$, $d$ has to be $0$. Then, you needed a function that showed the same general behaviour but tending to $\infty$ slower, so I suggested $\frac{1}{\sqrt[n]{x}}$ instead with the same generalisation to $\frac{a}{b\sqrt[n]{x}+c}$. –  Abel May 29 '13 at 10:06