beta(), betaf() and betal() functions in C++ STL

C++Server Side ProgrammingProgramming

The functions beta(), betaf() and betal() are built-in functions in the standard template library of C++. These functions are used to calculate the beta function of two positive real numbers.

The functions beta(), betaf() and betal() are built-in functions in the standard template library of C++. These functions are used to calculate the beta function of two positive real numbers.

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

beta()

The beta() function is used to deal with values of data type double i.e. it accepts the parameter of double type and returns are double value.

Syntax

double beta(double x, double y)

Parameters

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.

Returns a double value which is beta function result.

Example

#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;
}

Output

B(4.93 , 5.01) = 0.00166054

betaf()

The betaf() function is used to deal with values of data type float i.e. it accepts the parameter of float type and returns are float value.

Syntax

float beta(float x, float y

Parameters

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.

Returns a float value which is beta function result.

Example

#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;
}

Output

B(0.31 , 3.99) = 1.93395

betal()

The betal() function is used to deal with values of data type long double i.e. it accepts the parameter of long double type and returns a long double value.

Syntax

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

Parameters

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.

Returns a long double value which is beta function result.

Example

#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;
}

Output

B(3453.35 , 9862.9) = 4.39947e-3312
raja
Published on 17-Jul-2020 12:03:46
Advertisements