std::beta,s...f,std::betal(3)
π beta besties: std::beta, std::betaf, std::betal π
okay so this is the C++ Standard Libary manual page for std::beta, std::betaf, and std::betal, aka the std::beta,s...f,std::betal(3) page. bestie, we're gonna get you comfy with the beta function. no cap. π«Ά
π NAME π
The NAME line is literally:
std::beta,std::betaf,std::betal - std::beta,std::betaf,std::betal
That's it. That's the name. iconic. π
β¨ Synopsis β¨
Here's the signature lineup, bestie:
double beta( double x, double y );
float betaf( float x, float y ); (1)
long double betal( long double x, long double y );
Promoted beta( Arithmetic x, Arithmetic y ); (2)
- Computes the beta function of
xandy. - A set of overloads or a function template for all combinations of arguments of arithmetic type not covered by (1). If any argument has integral type, it is cast to
double. If any argument islong double, then the return typePromotedis alsolong double, otherwise the return type is alwaysdouble.
As all special functions, beta is only guaranteed to be available in <cmath> if __STDCPP_MATH_SPEC_FUNCS__ is defined by the implementation to a value at least 201003L and if the user defines __STDCPP_WANT_MATH_SPEC_FUNCS__ before including any standard library headers. that's the availability vibe check, fr fr. β¨
π§Έ Parameters π§Έ
x,yβ values of a floating-point or integral type.
πΈ Return value πΈ
If no errors occur, value of the beta function of x and y, that is
β«1 0tx-1 (1 - t)(y-1) dt
or, equivalently,
Ξ(x)Ξ(y)
Ξ(x + y)
is returned. math girlies stay winning. π
π Error handling π
Errors may be reported as specified in math_errhandling.
- If any argument is
NaN,NaNis returned and domain error is not reported. - The function is only required to be defined where both
xandyare greater than zero, and is allowed to report a domain error otherwise.
π Notes π
- Implementations that do not support TR 29124 but support TR 19768, provide this function in the header
tr1/cmathand namespacestd::tr1. - An implementation of this function is also available in
boost.math. beta(x, y)equalsbeta(y, x). symmetry slay.- When
xandyare positive integers,beta(x, y)equals\(\frac{(x - 1)!(y - 1)!}{(x + y - 1)!}\), displayed like:
(x - 1)!(y - 1)!
(x + y - 1)!
- Binomial coefficients can be expressed in terms of the beta function:
\(\binom{n}{k} = \frac{1}{(n + 1)B(n - k + 1, k + 1)}\), displayed like:
β
β
βn
kβ
β
β =
1
(n + 1)Ξ(n - k + 1, k + 1)
and yes, the source has a period at the end: . periodt. π
π Example π
(works as shown with gcc 6.0)
// Run this code
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
double binom(int n, int k)
{
return 1 / ((n + 1) * std::beta(n - k + 1, k + 1));
}
int main()
{
std::cout << "Pascal's triangle:\n";
for (int n = 1; n < 10; ++n)
{
std::cout << std::string(20 - n * 2, ' ');
for (int k = 1; k < n; ++k)
std::cout << std::setw(3) << binom(n, k) << ' ';
std::cout << '\n';
}
}
π Output π
Pascal's triangle:
2
3 3
4 6 4
5 10 10 5
6 15 20 15 6
7 21 35 35 21 7
8 28 56 70 56 28 8
9 36 84 126 126 84 36 9
π See also π
tgammatgammaftgammalgamma function(C++11) (function)(C++11)(C++11)
π¦ External links π¦
Weisstein, Eric W. "Beta Function." From MathWorld--A Wolfram Web Resource.
that's the whole page, bestie. source/version/date sign-off: http://cppreference.com Β· 2024.06.10 Β· std::beta,s...f,std::betal(3). go be iconic with your beta function πβ¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms