The beta(), betaf() and betal() are built-in functions in C++ STL that are used to compute the beta functionof two positive real values. The function takes two variables x and y as input and returns the beta function of x and y. Beta function (Also known as Euler integral of first kind) of x and y can be defined as:
double beta(double x, double y) or long double betal(long double x, long double y) or float betaf(float x, float y)
Parameters: The function accepts two mandatory parameters x and y which specifies the values of a floating-point or integral type. The parameters can be of double, double or float, float or long double, long double data-type.
Return Value: The function returns the value of beta function of x and y. The return type depends on the parameters passed. It is same as that of the parameter.
Note: The function runs in and above C++ 17(7.1).
Below program illustrates the beta(), betaf() and betal() functions:
0.00357143 0.00034965 1.65804e-005
Application of Beta function: It is used to compute Binomial Coefficients.The binomial coefficient in terms of beta function can be expressed as:
The above relation can be used to compute the binomial coeeficient. An illustration has been shown below:
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- fill() and fill_n() functions in C++ STL
- Binary Search functions in C++ STL (binary_search, lower_bound and upper_bound)
- Find and print duplicate words in std::vector<string> using STL functions
- Computing index using pointers returned by STL functions in C++
- Important functions of STL Components in C++
- Forward List in C++ | Set 1 (Introduction and Important Functions)
- strtok() and strtok_r() functions in C with examples
- strdup() and strndup() functions in C/C++
- Ceil and Floor functions in C++
- Pure Virtual Functions and Abstract Classes in C++
- Wide char and library functions in C++
- Explicitly Defaulted and Deleted Functions in C++ 11
- atol(), atoll() and atof() functions in C/C++
- std::stol() and std::stoll() functions in C++
- std::legendre, std::legendref and std::legendrel functions in C++17
- Virtual Functions and Runtime Polymorphism in C++ | Set 1 (Introduction)
- asin() and atan() functions in C/C++ with Example
- isalpha() and isdigit() functions in C with cstring examples.
- Can static functions be virtual in C++?
- Virtual functions in derived classes
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.