Is there a method in Java that can do integration?

点点圈 提交于 2020-08-05 07:29:08

问题


I am writing a program in java that models a carnot engine and I want to calculate the work done and I need to use integration. I have been looking around on google and haven't found quite what I am looking for, have any suggestions?


回答1:


You have to use an external library, like this one or this other one. You cannot do that with just native methods (well, unless you implement the integration algorithm yourself like the others answers suggest, which I think it's not what you want - otherwise you weren't asking here :-)




回答2:


Apache Commons Math contains ready implementations for integration and much more.

Java Number Cruncher is a good book if you want to do it yourself.




回答3:


Look at Object-Oriented Implemenation of Numerical Methods, by Didier H Besset.

http://www.amazon.com/Object-Oriented-Implementation-Numerical-Methods-Introduction/dp/1558606793/ref=sr_1_1?ie=UTF8&s=books&qid=1260512473&sr=8-1

There are various equations you can use, depending on what you need, precisely.




回答4:


Look into numerical integration. The general approach is to sample your integrand at various points within the integration interval, then approximate the integral with a weighted sum of the samples - think Riemann sum. There are many different quadrature rules, with different sampling distributions and weighting functions that are best suited to different types of integrands.

Most of the uniform-width quadrature rules (eg. midpoint rule) are very simple and shouldn't take much work to code, but may require far too many samples for acceptable accuracy. Variable-width sampling rules such as Gauss-Hermite are quite a bit more complex, but require far fewer samples for the same level of accuracy, assuming the integrand is sufficiently smooth. You'll have to read about the various rules and figure out what best fits your needs.

I recommend the book Numerical Recipes, which covers numerical integration methods (and just about every other topic in scientific computing) extensively.



来源:https://stackoverflow.com/questions/1886145/is-there-a-method-in-java-that-can-do-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!