C++ STL 中的 beta()、betaf() 和 betal() 函式


beta()、betaf() 和 betal() 函式是 C++ 標準模板庫中的內建函式。這些函式用於計算兩個正實數的 beta 函式。

**beta() 函式**、betaf() 和 betal() 函式是 C++ 標準模板庫中的內建函式。這些函式用於計算兩個正實數的 beta 函式。

$B(x,y)=\int_{0}^{1}t^{(x-1)}(1-t)^{(y-1)}dt$

beta()

beta() 函式用於處理 double 型別的值,即它接受 double 型別的引數並返回 double 值。

語法

double beta(double x, double y)

引數

x is a double value that gives the value of x in the beta function.
y is a double value that gives the value of y in the beta function.

返回一個 double 值,即 beta 函式的結果。

示例

#include <bits/stdc++.h>
using namespace std;
int main(){
   double x = 4.93;
   double y = 5.01;
   double result = beta(x, y);
   cout<<"B("<<x<<" , "<<y<<") = "<<result<<"\n";
   return 0;
}

輸出

B(4.93 , 5.01) = 0.00166054

betaf()

betaf() 函式用於處理 float 型別的值,即它接受 float 型別的引數並返回 float 值。

語法

float beta(float x, float y

引數

x is a float value that gives the value of x in the beta function.
y is a float value that gives the value of y in the beta function.

**返回**一個 float 值,即 beta 函式的結果。

示例

#include <bits/stdc++.h>
using namespace std;
int main(){
   float x = 0.31;
   float y = 3.99;
   float result = betaf(x, y);
   cout<<"B("<<x<<" , "<<y<<") = "<<result<<"\n";
   return 0;
}

輸出

B(0.31 , 3.99) = 1.93395

betal()

betal() 函式用於處理 long double 型別的值,即它接受 long double 型別的引數並返回 long double 值。

語法

long double beta(long double x, long double y)

引數

x is a long double value that gives the value of x in the beta function.
y is a long double value that gives the value of y in the beta function.

**返回**一個 long double 值,即 beta 函式的結果。

示例

#include <bits/stdc++.h>
using namespace std;
int main(){
   long double x = 3453.35451;
   long double y = 9862.89651;
   long double result = betaf(x, y);
   cout<<"B("<<x<<" , "<<y<<") = "<<result<<"\n";
   return 0;
}

輸出

B(3453.35 , 9862.9) = 4.39947e-3312

更新於:2020年7月17日

214 次瀏覽

開啟您的職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.