Integration of a 'stairstep' function

In summary, the value of a commodity in a market is a function of the quantity of that commodity, with respect to the capacity of the market. Integrating the value function over a range of quantities results in an error due to the integration of non-integer values. However, by taking the summation of the values over a range of quantities, the error is reduced to an insignificant margin.
  • #1
USNavyFish
4
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
  • #2
Still no takers? I was hoping this problem would spark interest in some minds.
 
  • #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.
 
  • #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..
 
  • #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.
 
  • #6
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:

FAQ: Integration of a 'stairstep' function

What is a 'stairstep' function?

A 'stairstep' function, also known as a 'step' function, is a piecewise function that changes its value only at certain points. These points are typically joined by a series of horizontal or vertical line segments, creating a 'stairstep' appearance.

How is a 'stairstep' function integrated?

To integrate a 'stairstep' function, you must first identify the intervals over which the function changes its value. Then, you can integrate each interval separately using the appropriate integration method (e.g. substitution, integration by parts). Finally, you can add the individual integrals together to get the overall integral of the 'stairstep' function.

What are the applications of integrating a 'stairstep' function?

'Stairstep' functions are commonly used to model real-world situations, such as stepwise changes in growth or population. They can also be used to represent discontinuous processes, such as chemical reactions or electrical circuits. Integrating 'stairstep' functions can provide important information, such as the total change or accumulated effect over time.

Can a 'stairstep' function be integrated using calculus?

Yes, a 'stairstep' function can be integrated using calculus. However, because it is a piecewise function, the integration process may be more complex and require breaking the integral into multiple parts. Depending on the specific function, integration techniques such as u-substitution, integration by parts, or trigonometric substitution may be needed.

Are there any limitations to integrating a 'stairstep' function?

One limitation of integrating 'stairstep' functions is that they cannot represent continuous functions, as they have discontinuities at the step points. Additionally, if the 'stairstep' function has infinitely many step points, the integral may not converge. Furthermore, some 'stairstep' functions may be difficult or impossible to integrate using traditional calculus methods.

Similar threads

Back
Top