std:: beta, std:: betaf, std:: betal
|
double
beta
(
double
x,
double
y
)
;
float
betaf
(
float
x,
float
y
)
;
|
(1) | |
|
Promoted beta
(
Arithmetic x, Arithmetic y
)
;
|
(2) | |
Promoted
también es
long
double
, de lo contrario el tipo de retorno es siempre
double
.
Como todas las funciones especiales,
beta
solo está garantizada de estar disponible en
<cmath>
si
__STDCPP_MATH_SPEC_FUNCS__
está definido por la implementación con un valor de al menos 201003L y si el usuario define
__STDCPP_WANT_MATH_SPEC_FUNCS__
antes de incluir cualquier cabecera de la biblioteca estándar.
Contenidos |
Parámetros
| x, y | - | valores de un tipo de punto flotante o integral |
Valor de retorno
If no errors occur, value of the beta function of x and y , that is ∫ 10 t x-1
(1 - t) (y-1)
d t , or, equivalently,
| Γ(x)Γ(y) |
| Γ(x + y) |
Manejo de errores
Los errores pueden ser reportados como se especifica en math_errhandling .
- Si cualquier argumento es NaN, se devuelve NaN y no se reporta un error de dominio.
- La función solo está definida donde tanto x como y son mayores que cero, y se permite reportar un error de dominio en caso contrario.
Notas
Las implementaciones que no admiten TR 29124 pero sí admiten TR 19768, proporcionan esta función en el encabezado
tr1/cmath
y el espacio de nombres
std::tr1
.
Una implementación de esta función también está disponible en boost.math .
beta ( x, y ) es igual a beta ( y, x ) .
When x and y are positive integers, beta(x, y) equals| (x - 1)!(y - 1)! |
| (x + y - 1)! |
⎜
⎝ n
k ⎞
⎟
⎠ =
| 1 |
| (n + 1)Β(n - k + 1, k + 1) |
Ejemplo
(funciona como se muestra con gcc 6.0)
#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'; } }
Salida:
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
Véase también
|
(C++11)
(C++11)
(C++11)
|
función gamma
(función) |
Enlaces externos
Weisstein, Eric W. "Función Beta." De MathWorld--Un recurso web de Wolfram.