Namespaces
Variants

std:: beta, std:: betaf, std:: betal

From cppreference.net
double beta ( double x, double y ) ;

float betaf ( float x, float y ) ;

long double betal ( long double x, long double y ) ;
(1)
Promoted    beta ( Arithmetic x, Arithmetic y ) ;
(2)
1) x y ベータ関数 を計算します。
2) (1)でカバーされない算術型の引数のすべての組み合わせに対する、オーバーロードのセットまたは関数テンプレート。いずれかの引数が 整数型 の場合、それは double にキャストされる。いずれかの引数が long double の場合、戻り値の型 Promoted long double であり、それ以外の場合、戻り値の型は常に double である。

すべての特殊関数と同様に、 beta は、 __STDCPP_MATH_SPEC_FUNCS__ が実装によって少なくとも201003L以上の値として定義されており、かつユーザーが標準ライブラリのヘッダーをインクルードする前に __STDCPP_WANT_MATH_SPEC_FUNCS__ を定義している場合にのみ、 <cmath> で利用可能であることが保証されています。

目次

パラメータ

x, y - 浮動小数点型または整数型の値

戻り値

If no errors occur, value of the beta function of x and y , that is 1
0
t x-1
(1 - t) (y-1)
d t
, or, equivalently,
Γ(x)Γ(y)
Γ(x + y)
is returned.

エラーハンドリング

エラーは math_errhandling で指定される通りに報告される場合があります。

  • いずれかの引数がNaNの場合、NaNが返され、定義域エラーは報告されません。
  • この関数は x y の両方がゼロより大きい場合にのみ定義する必要があり、それ以外の場合は定義域エラーを報告することが許可されています。

注記

TR 29124をサポートせず、TR 19768をサポートする実装では、この関数はヘッダー tr1/cmath および名前空間 std::tr1 で提供されます。

この関数の実装は boost.math でも利用可能です。

beta ( x, y ) beta ( y, x ) と等しい。

When x and y are positive integers, beta(x, y) equals
(x - 1)!(y - 1)!
(x + y - 1)!
. Binomial coefficients can be expressed in terms of the beta function:

n
k


=
1
(n + 1)Β(n - k + 1, k + 1)
.

(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';
    }
}

出力:

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

関連項目

(C++11) (C++11) (C++11)
ガンマ関数
(関数)

外部リンク

Weisstein, Eric W. "ベータ関数." MathWorld(Wolfram Webリソース)より。