# Plot Line that gets exponentially larger around a point

I'm building a program that calculates the cost of an item based on it's size (let's say a bamboo pole). As the customer requests a longer pole, it gets hard to find a bamboo, plus requires more resources to grow, therefore, I would want to charge more per inch for the piece of bamboo based on it's length approaching a particular length. Then after that point the cost per inch would really escalate.

I believe that log would be the function that I need to use, but I just can't figure out how to make my formula. I've tried log(-x), log(x-1), log(y-x), I can't figure out how to get the log to shoot up to infinity, nor target a specific point.

Referencing the example above, I would want the cost/inch of the bamboo to stay reasonable up to 72", but after that, the cost/inch should rapidly increase, until it gets to 100", where it would become ridiculously expensive. Before 72", it should rise in cost/inch, but at a slow rate (it costs a little bit more per inch to grow a 72" stick than a 6" stick). I'm looking for a uniform growth, not a split formula. No f(x) where x<72, g(x) where x>72.

I'm not necessarily looking for the formula to solve the above question. I am looking for the HOW to research and solve the above question.

Many Thanks, Matt

-
I do not understand the common allergy to "split" formulas. – André Nicolas May 19 '11 at 17:28
I would advise against trying to find a single equation that models all of your business cases. My main reason is that you are obfuscating the reasons why you are charging different rates for different lengths. I recommend that you hard code each business case as a piecewise function. The benefit is that each reason for why you are charging a specific rate is captured and it makes it easier to modify your code in the future. Don't make life more complicated than it needs to be, keep it simple. – GEL May 19 '11 at 17:45
Once many years ago I was asked by a friend to help fit a formula to the growth curve of children. He had tried many ingenious "single formulas," none of which worked well. I suggested a "split" formula, for "before puberty" and "after puberty." Very quickly he got nice fits. – André Nicolas May 19 '11 at 18:01
definitely see your point @user6312 & @lewellen. My allergy pertains to the fact that it's quite hard to fit a formula's slope at the endpoint to another formula's slope at the beginning. All the while trying to force each curve into a specific range for the entirety of the segment. – polyhedron May 19 '11 at 18:31
Slopes do not need to match. If you want slope match, look up splines. (Income Tax people certainly don't bother with matching slopes. Why should you?) – André Nicolas May 19 '11 at 18:34

You are looking for functions that go to infinity, preferably in finite time (vertical asymptote) or something similar. you then construct a scale to get to your infinity point at the number of inches you want (say 100). so, for tan(x) as an example, pi/2 is infinity, so map 0-100 to pi/4-pi/2, and you have something that works (you might want to add a constant to formula to help you on on the low end).

A possibility: f(x) = Tan(x/200*pi/2+pi/4)+5

f(10) = 6.2

f(72) = 9.5

f(90) = 17.7

f(95) = 35.45

f(98) = 68.7

Feel free to massage the constants, or pick a different function to get the behavior that you want.

-
This definitely gets me going in the right direction! Perfect. I am going to take the advice of lewellen and user6312 above though and go ahead and split the equation into a linear before the break point of 72 and then use a formula similar to this after 72. – polyhedron May 19 '11 at 18:37

Try looking into statistics distributions. By messing with the degrees of freedom you can get something that could do what you want. If you take the inverse of the probability of something happening, then you can get your arbitrarily large number. Bonus: you can probably set 75" as the average parameter for the distro and not have to worry about it.

-