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 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.

返回一个浮点值,它是 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 值。

语法

长双 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