Integration of a 'stairstep' function

  • Context: Graduate 
  • Thread starter Thread starter USNavyFish
  • Start date Start date
  • Tags Tags
    Function Integration
Click For Summary

Discussion Overview

The discussion revolves around the integration of a 'stairstep' function in the context of an economic simulation. Participants explore the challenges of accurately calculating the total cost of purchasing units from a market where the value of a commodity is a function of its quantity, particularly focusing on the discrepancies between numerical summation and integration methods.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes a value function that increases as quantity decreases and expresses the need to compute total costs efficiently.
  • The participant notes that integrating the value function leads to small errors compared to numerical summation, particularly for large quantities.
  • Another participant suggests that the integral of a stepwise function is equivalent to the summation, implying it may not resolve the error issue.
  • A different participant proposes treating the value function as a series of delta functions to explore potential solutions.
  • One participant introduces the Euler MacLaurin Summation as a method to approximate sums with integrals, suggesting it may help achieve the desired accuracy.
  • A later reply confirms successful application of the Euler MacLaurin Summation, noting that the results matched the numerical sum closely, indicating a resolution to the original problem.

Areas of Agreement / Disagreement

Participants express differing views on the effectiveness of integration versus summation for this problem. While one participant finds a solution using the Euler MacLaurin Summation, others remain skeptical about the integration of a stepwise function resolving the error.

Contextual Notes

The discussion highlights the limitations of using integration for non-integer values and the potential for approximation methods to yield satisfactory results within specified error margins.

USNavyFish
Messages
4
Reaction score
0
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:
Physics news on Phys.org
Still no takers? I was hoping this problem would spark interest in some minds.
 
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.
 
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..
 
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.
 
Geomancer said:
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.
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:

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K