The Fundamental Theorem of Calculus gives us an exact formula for computing
abf(x) dx, provided we can find an antiderivative for f.
This method of evaluating definite integrals is called the analytic method. However, there are times when this is difficult or impossible. In these cases, it is usually good enough to find an approximate, or numerical solution, and there are some very straighforward ways to do this. [1]
Here you can find a processing project that contains "cIntegrate" which calculates numeric value of the integral
abf(x) dx based on "Left Riemann Sums". The cIntegrate class has following interface:
- cIntegrate(float _a, float _b) - constructor which specifies left (_a) and right (_b) border of the calculated interval.
- public float solve(intMethodIntegrate methodIntegrateImpl) - method accepts name of the object from class that contains method to be integrated. This class has to implement interface intMethodIntegratel, which allows to pass the method about to integrate as callback method.
note.: important parameter for Riemann Sums algorithm is number of subintervals the <a,b> interval is divided into. By default constructor sets variable "n = 100;" , however the variable is publicaly accessible.
note1: results of the class were compaired to results from http://www.plu.edu/~heathdj/java/calc2/Riemann.html.
Example:


