Bug of integration using Rectangular method
In the source code "src/uom/xint.c", for the rectangular method,
1. if the data is evenly spaced, the first data point is calculated by "g0 = y0*delta";
if the data is unevenly spaced, the first point keeps its original value, "g0 = y0".
The boundary condition for unevenly-spaced data seems wrong.
2. why not decrease NPTS by one, and adjust B and/or E while using rectangular method?
#1 Updated by Awen Thomas almost 9 years ago
To resolving this issue, use following steps and code
•The rectangle’s width is determined by the interval of integration.One rectangle could span the width of the interval of integration and approximate the entire integral.Alternatively, the interval of integration could be sub-divided into smaller intervals of equal lengths, and rectangles would used to approximate the integral; each smaller rectangle has the width of the smaller interval.
•The rectangle’s height is the function’s value at the midpoint of its base.
•Within a fixed interval of integration, the approximation becomes more accurate as more rectangles are used; each rectangle becomes narrower, and the height of the rectangle better captures the values of the function within that interval.
Area of Rectangle = base*height
To adapt this to a rectangle that approximates a function f(x) over an interval [a, b],
Area of rectangle = (b-a)*f[0.5*(b-a)]
#2 Updated by Chad Trabant almost 9 years ago
The first response to this ticket by Awen Thomas contained a link to an external site which had nothing to do with the issue being reported.
Best case this was an attempt at advertising, worst case is dissemination of malware.
This response likely has no merit.
#3 Updated by Brian Savage over 8 years ago
- Assignee set to Brian Savage
The method for uneven, rectangular has been in place for a long while. The result do not match those for a evenly spaced rectangular method. However, defining the first point is problematic as there is no time step to be defined.
Another options are to set the first value to 0.0.
I am leaning to leave the routine as it exists.