1

I have this problem. Googling 2 hours with no answers found, but propably searching wrong words - im really not not a math guy but need this for a plugin I write:

A price for a product is 150 OR below and the fee is 50% = 75

A Price for a product is 3000 OR Above and the fee is 10% ( and staying there ) = 300

The fee in % between 151 - 2999 should decrease in a smooth curve (50% to 10%)

How do I get the % for example 1400 ?

Thanks for any help / Jonas

  • 1
    depends on what kind of smooth curve. Is it a linear curve? –  Apr 27 '14 at 11:11
  • As above "should decrease in a smooth curve (50% to 10%)", thanks for looking into my problem btw! Edit; my goal is to plain it out how closer to 3000 you get, if possible. – Jonas Lundman Apr 27 '14 at 12:11
  • yeah, but there are litterally infinitely many different smooth curves, each of which will give a different answer. I can, for example, fit a third-degree polynomial to a curve which goes from 0.5 to 0.1, or I can also fit a straight line. –  Apr 27 '14 at 13:02
  • Hi! Ok, I to far away of the words here but lets say we start easy with a linear, I suppose the amount 1425 (half of 3000) would endup with 13% something? I would like the % to be little higher here, so I endup with minimum amount 200 of fee over 1300... Means half is a little lower. – Jonas Lundman Apr 27 '14 at 13:20
  • This is the table (bad) I gonna replace:150 = 75 ( ~ 50% ) 200 – 250 = 100 ( 50 – 40% ) 300 – 550 = 130 ( 43 – 23% ) 600 – 850 = 230 ( 38 – 27% ) 900 – 1250 = 250 ( 27 – 20% ) 1300 – 3000 = 300 ( 23 – 10% ) 3000 or more 10% (from 300) – Jonas Lundman Apr 27 '14 at 13:31

1 Answers1

1

Ok, if the smooth curve between 150 and 3000 is a straight line, we could start by finding the actual line $f(x) = ax+b$.

We have the two conditions $f(150) = 0.5$ and $f(3000)=0.1$, so we get the system of equations $$ 150a+b = 0.5\\ 3000a + b = 0.1 $$ which has solutions $a=-0.000140351$ and $b=0.521053$, so the curve is described by $$ f(x) = -0.000140351x + 0.521053 $$

Now to find the fee for any price between 150 and 3000 you just plug it in as $x$. For $1400$ we get $-0.000140351*1400+0.521053=0.3245616$.

Edit: It kinda sounds like the normal curve would fit your preferences pretty well. Just playing around with the numbers , using the function $$ f(x) = 0.1+0.4e^{-(x-150)^2/1000000} $$

for values between $150$ and $3000$, you get this curve:

enter image description here

Changing the number where I chose $1000 000$, you could get a flatter or steeper graph by increasing/decreasing the number.

  • Wow, so greatful for this help! Well, I can see that a straight line produces to high % fee at mid costs. Like 36% at 1400, but prefer more like round 20% and rise faster 1300 - 150. Or, devide into 2 formulas and split at 1300 ( 150-1300, 1300-3000). But I don know how to "human" read the math and get "a" on my php script or calculator to experiment the thresholds. The last line was ok to use. – Jonas Lundman Apr 27 '14 at 14:05
  • If I wanna change 3000a + b = 0.1 to 1600a + b = 0.1, how do I calculate that ( to get = −0.000140351 resp the b summary) ? – Jonas Lundman Apr 27 '14 at 14:25
  • well, that's a simple linear system. You can use wolfram, for example –  Apr 27 '14 at 15:46
  • Tanks for your time and this great turtorial and solution. I can now adjust my choices to end up with suitable calculations for my plugin! – Jonas Lundman Apr 27 '14 at 15:52
  • check the edit. I was kinda bored so I played around with an exponential function. –  Apr 27 '14 at 16:38
  • Seems very useful, but I have no idea how to "pull in my numbers" on a line in a php protocol: var a = -0.000140351; var b = 0.521053; var am = 120; var p = a * am + b; print am = round(p * am) == round($p * 100) in percent. – Jonas Lundman Apr 27 '14 at 17:14
  • well, unfortunately I have zero experience with PHP so hard for me to say. But from what I can see, PHP has the usual way of defining functions just like in java or similar languages, and that it also supports things like $e$ with exp($float), etc –  Apr 27 '14 at 17:28
  • Oh, I mean how to read "−(x−150)2/1000000" and where to put it in the code I paste at Wolfram. I manage to get the values for a and b, then do the calc in diffrent langs like php or javascript or just on plain paper.... – Jonas Lundman Apr 27 '14 at 17:39
  • But just to clarify; the formula I gave in the edit has nothing to do with $a$ and $b$ and the linear formula from my original answer. The new formula is approximately fitted to the interval fees you gave. It will allways be $0.5$ at $150$ and $0.1$ at $3000$ but you can alter the steepness of it in the middle by setting for example $1200000$ instead of $1000000$. Here is the wolfram plot. –  Apr 27 '14 at 17:50