我需要在Java中開發一個程序來解決一些積分問題。積分是這樣的:如何解決Java中的Integral?
我看了一些功能來做到這一點,的java.math但我沒有發現任何東西。
有沒有人有想法得到這個解決方案? (也許一些額外的庫或類似的東西)
非常感謝!
我需要在Java中開發一個程序來解決一些積分問題。積分是這樣的:如何解決Java中的Integral?
我看了一些功能來做到這一點,的java.math但我沒有發現任何東西。
有沒有人有想法得到這個解決方案? (也許一些額外的庫或類似的東西)
非常感謝!
維基百科有關數值積分的文章有關於methods for one-dimensional integrals的章節。
實施「梯形」或「矩形」規則應該沒有問題。
也這個文檔有助於你,公式的使用和容錯公式http://www.mpia-hd.mpg.de/~mordasini/UKNUM/integration.pdf – mehmet 2014-11-01 07:42:05
看看JScience
的Apache Commons Math庫包含在Numerical Analysis部分,四個不同的數值積分:
嗨,我下載apache math .jar,然後添加到我的項目庫中。但是,例如,當我嘗試使用一個函數,例如erfc,當我調用erf erf = new Erf(); (這是在特殊包裝數學內)Android工作室拋出一個錯誤,說「Erf()有一個私人訪問org.apaches.coommon.math.special.erf」。爲什麼這個? – Txispas 2014-05-21 17:53:14
@Txispas:如果您有新的問題,請使用[Ask Question](問問題)(https://stackoverflow.com/questions/ask)按鈕。除我以外沒有人會看到這個評論,我不知道答案:) – 2014-05-21 17:59:07
/* Petit programme qui calcul numériquement une intégrale selon l'algorithme de Simpson.
Avant de l'executer, il faut entrer:
- l'expression de la fonction f: ligne 12;
- les bornes inférieure a et supérieure b de l'intégrale: lignes 39 et 40;
- le nombre de mesures n (n est entier!!!): ligne 41.
------------------------------------------------------------------------------------------------------ */
class Fonction{ //Classe fonction: definit fonction et Simpson
double f (double x) { //DEFINIR la fonction à intégrer.
return Math.Cos(x);
}
double IntSimpson(double a, double b,int n){ //Methode de Simpson pour calcul intégrale
int i,z; //a= borne inférieure et b, borne supérieure d'intégration
double h,s; //n = nombre de pas
n=n+n;
s = f(a)*f(b);
h = (b-a)/n;
z = 4;
for(i = 1; i<n; i++){
s = s + z * f(a+i*h);
z = 6 - z;
}
return (s * h)/3;
}
}
class integration{ //Class resultat: calcul l'integrale et affiche le resultat.
public static void main(String args[]){
Fonction fonction; //Appel class fonction
fonction = new Fonction();
double a = ???? ; //RENTRER les valeurs souhaitées de a, b et n !!!
double b = ???? ;
int n = ???? ;
double resultat = fonction.IntSimpson(a,b,n); //Applique méthode simpson à fonction
System.out.println("Integrale vaut: " + resultat); //Affiche les résultats
}
}
您是否尋求數字(近似數字)或符號(準確表示結果的公式)解決方案? – meriton 2010-08-01 11:36:16
對於符號集成,您可能需要考慮http://integrals.wolfram.com/index.jsp – 2010-08-01 11:38:23
@meriton此線程有一些數值近似的解決方案。但我如何獲得符號解決方案? – 2018-01-02 00:27:30