Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Integration of a 'stairstep' function

  1. May 31, 2009 #1
    Good evening!

    I'm developing a small economic simulation for kicks, and have been stumped for the last few days.

    The value of a commodity within a market is a function of the quantity of that commodity, with respect to the capacity of the market. The function I use to generate those values looks something like:

    Value(Quantity) = BaseValue * 2-(1.5*((Quantity/Capacity)^R))
    where R = (Log(3) / Log(2) ) - 1

    The specifics of are irrelevant, I'm simply providing it for context. What's important to note is that as Quantity in a market decreases, value increases.

    Now, say you're going to determine the total cost to purchase 5 units from that market. The easy way to do this is this is to sum Value(Quantity - 0) + Value(Quantity -1) + Value(Quantity -2) ... all the way to Value(Quantity - 4).

    Unfortunately, this process is very computationally expensive for large values of Q (quantity). The immediate answer is to take the integral of the value function. That integral looks like:

    Integral of Value with respect to Q = (Q)*(2 - (1.5*(Q/Capacity)^(R))/(R+1))


    Now, here's where the problem begins. For large values of Q, and also at the extremes of the function where the slope is large (i.e. Q = 0 or Q = Capacity), Integration over a specified range DIFFERS from the numerical sum over that range by a small error (generally no more than 1-2%).

    I've come to reason that the cause for this error is due to the integration of non-integer quantity values. The summation obviously deals with only integer values.. but the integration takes care of all the values in between these integers as well.

    Assuming that's what causes this error, I would assume that if the value function were instead written as a "stairstep" function, the error would drop out. Such a stairstep function would treat all Q values from (integerQ - 0.5) to (integerQ + 0.5) as having the same value as IntegerQ.

    I have not been able to figure out how to define, nor take the integral of such a stairstep function. How would you go about solving this problem analytically? Any assistance would be greatly appreciated!
     
    Last edited: May 31, 2009
  2. jcsd
  3. May 31, 2009 #2
    Still no takers? I was hoping this problem would spark interest in some minds.
     
  4. Jun 1, 2009 #3
    The integral of a stepwise function is the the summation you're talking about, so I don't think it will solve you're problem.
     
  5. Jun 1, 2009 #4
    So you're saying you don't think you can use integration to solve this? What if the value function is treated as a a series of delta functions or something similar?

    I'm determined to find a solution to this conundrum..
     
  6. Jun 1, 2009 #5
    There is a gizmo called "Euler MacLauren Summation" that allows one to rapidly approximate sums by integrals; this may get you where you want to go.
    I must note that the example formula you gave may be simple enough to allow exact results. I'll think about this.
     
  7. Jun 1, 2009 #6

    Wow! Excellent suggestion Geomancer!

    NumberedEquation5.gif

    I setup the Euler MacLaurin Summation up to the fifth order term, and the results were identical to the numerical sum, for all intents and purposes.

    Turns out that after the 1st order term, the remaining terms reduce to less than 0.000001, which is still well within my desired margin of error. Thus, problem solved.

    Thank you so much Geomancer, this was exactly what I was looking for o:)
     
    Last edited: Jun 1, 2009
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Integration of a 'stairstep' function
  1. Integral of a function (Replies: 18)

  2. Integrable function (Replies: 7)

  3. Functional Integration (Replies: 2)

  4. A Function to Integrate (Replies: 13)

  5. Integral of a function (Replies: 6)

Loading...