Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate exact area under curve in Java

Tags:

java

math

Are there any methods which do that? I have an application where I need the area under the curve, and I am given the formula, so if I can do the integration on hand, I should be able to do it programatically? I can't find the name of the method I'm referring to, but this image demonstrates it: http://www.mathwords.com/a/a_assets/area%20under%20curve%20ex1work.gif

Edit: to everyone replying, I have already implemented rectangular, trapezoidal and Simpson's rule. However, they take like 10k+ stripes to be accurate, and should I not be able to find programatically the integrated version of a function? If not, there must be a bloody good reason for that.

like image 640
Velizar Hristov Avatar asked Nov 12 '12 08:11

Velizar Hristov


People also ask

How do you find the exact value of the area under a curve?

The area under a curve between two points is found out by doing a definite integral between the two points. To find the area under the curve y = f(x) between x = a & x = b, integrate y = f(x) between the limits of a and b. This area can be calculated using integration with given limits.

What is an area under the curve?

The area under a curve refers to the area between a curve and the -axis. This area could be entirely above the -axis, entirely below the -axis, or a combination of above and below the -axis. In calculus, the area under a curve is a visual representation of an integral.


1 Answers

Numerical integration
There are multiple methods, which can be used. For description, have a look in Numerical Recipes: The Art of Scientific Computing.
For Java there is Apace Commons library, which can be used. Integration routines are in Numerical Analysis section.

Symbolic integration
Check out jScience. Functions module "provides support for fairly simple symbolic math analysis (to solve algebraic equations, integrate, differentiate, calculate expressions, and so on)".
If type of function is given, it can be possible to integrate faster in that specific case than when using some standard library.

like image 177
bhovhannes Avatar answered Sep 20 '22 02:09

bhovhannes