java Java中是否有可以进行集成的方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1886145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:23:14  来源:igfitidea点击:

Is there a method in Java that can do integration?

javaintegrationphysics

提问by Ben Fossen

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?

我正在用 java 编写一个程序来模拟卡诺引擎,我想计算完成的工作,我需要使用集成。我一直在谷歌上环顾四周,但没有找到我想要的东西,有什么建议吗?

回答by Joonas Pulakka

Apache Commons Mathcontains ready implementations for integration and much more.

Apache Commons Math包含用于集成等的现成实现。

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

如果您想自己动手,Java Number Cruncher是一本好书。

回答by James Black

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

看看由 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

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.

您可以使用各种方程式,具体取决于您的需要。

回答by Donnie DeBoer

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.

大多数均匀宽度的正交规则(例如中点规则)都非常简单,不应该花费太多的工作来编码,但可能需要太多的样本才能获得可接受的准确性。假设被积函数足够平滑,可变宽度采样规则(例如 Gauss-Hermite)要复杂得多,但在相同精度水平下需要的样本要少得多。您必须阅读各种规则并找出最适合您需求的规则。

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

我推荐这本书 Numerical Recipes,它广泛地涵盖了数值积分方法(以及科学计算中的几乎所有其他主题)。

回答by Davide

You have to use an external library, like this oneor 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 :-)

您必须使用外部库,例如this onethis other one。您不能仅使用本机方法来做到这一点(好吧,除非您像其他答案所建议的那样自己实现集成算法,我认为这不是您想要的 - 否则您不会在这里问:-)