Boris Hamanov
Boris Hamanov

Reputation: 3205

Progressive non-linear algorithm for increasing discount

A system has to support 100 users and the price for support is 3

A system has to support 10 000 users and the price for support is 1

I have to devise an algorithm to give me the price in between so it will gradually rise with the number of users.

I tried to multiply the number of users by 0.0002 to get the discount value and I got

300 users * 0.0002 = 0.06 discount, so price for support = 2.94 total income = 300 * 2.94 = 882

5000 users * 0.0002 = 1 discount, so price for support = 2 total income = 5000 * 2 = 10 000

8000 users * 0.0002 = 1.6 discount, so price for support = 1.4 total income = 8000 * 1.4 = 11 200

10 000 users * 0.0002 = 2 discount, so price for support = 1 total income = 8000 * 1.4 = 10 000

So you see after a given point I am actually having more users but receiving less payment.

I am not a mathematician and I now this is not really a programming question, but I don't know where else to ask this. I will appreciate if someone can help me with any information. Thanks!

Upvotes: 3

Views: 553

Answers (2)

Thai
Thai

Reputation: 11364

Scaling the price per user linearly didn't work as you showed, but you can try scaling the total income linearly instead.

  • total income for 100 users = 300
  • total income for 10000 users = 10000
  • total income for n users = (n-100) / (10000-100) * (10000-300) + 300

You know that the total income for n users is the price for support per user times the number of users, that means, now you have to find the function f(n) such that f(n) * n = (n-100) / (10000-100) * (10000-300) + 300.

And if you have to show that as the total income always increase, the price for support always decrease, just show that f'(n) ≤ 0 when 100 ≤ n ≤ 10000.

Upvotes: 0

Polynomial
Polynomial

Reputation: 28346

price = n * (5 - log10(n)) will work for 100 < n < 10000.

Just make sure you're using base-10 log and not natural (base-e) log. If your language doesn't have base-10 log normally, you can calculate it like this:
function log10(x) { return log(x)/log(10); }.

For 100 users, that's 100 * (5 - log10(100)), which gives 100 * (5 - 2), which is 300.

For 1000 users, that's 1000 * (5 - log10(1000)), which gives 1000 * (5 - 3), which is 2000.

For 10000 users, that's 10000 * (5 - log10(10000)), which gives 10000 * (5 - 4), which is 10000.

Let's pick some more random figures.
2500 users: 2500 * (5 - log10(2500)) gives us 2500 * (5 - 3.39794), which is 4005.
6500 users: 6500 * (5 - log10(6500)) gives us 6500 * (5 - 3.81291), which is 7716.
8000 users: 8000 * (5 - log10(8000)) gives us 8000 * (5 - 3.90309), which is 8775.

Should work out about right for what you're modelling.

Upvotes: 5

Related Questions