名前空間
変種
操作

std::assoc_legendre, std::assoc_legendref, std::assoc_legendrel

From cppreference.com
 
 
 
 
double      assoc_legendre( unsigned int n, unsigned int m, double x );

double      assoc_legendre( unsigned int n, unsigned int m, float x );
double      assoc_legendre( unsigned int n, unsigned int m, long double x );
float       assoc_legendref( unsigned int n, unsigned int m, float x );

long double assoc_legendrel( unsigned int n, unsigned int m, long double x );
(1)
double      assoc_legendre( unsigned int n, unsigned int m, IntegralType x );
(2)
1) 次数 n、順序 m、および引数 xルジャンドル陪関数を計算します。
2) 整数型 (integral type) の引数を受け付けるオーバーロードのセット、または関数テンプレートです。引数を double にキャストした後の (1) と同等です。

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

目次

[編集] パラメータ

n - 多項式の次数。符号なし整数型の値。
m - 多項式の順序。符号なし整数型の値。
x - 引数。浮動小数点型または整数型の値。

[編集] 戻り値

エラーが発生しなかった場合、引数 x のルジャンドル陪関数 Pm
n
の値が返されます。これは、(1 - x2
)m/2
dm
dxm
Pn(x)
に等しく、ここで Pn(x) はルジャンドル多項式(std::legendre(n, x))です。

[編集] エラー処理

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

  • 引数がNaNの場合、NaNが返され、ドメインエラーは報告されません。
  • もし |x| > 1 であれば、定義域エラーが発生する可能性があります。
  • n が 128 以上の場合、動作は実装定義となります。

[編集] 注釈

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

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

最初のいくつかのルジャンドル陪関数は以下の通りです。

  • assoc_legendre(0, 0, x) = 1。
  • assoc_legendre(1, 0, x) = x
  • assoc_legendre(1, 1, x) = -(1 - x2
    )1/2
  • assoc_legendre(2, 0, x) =
    1
    2
    (3x2
    - 1)
  • assoc_legendre(2, 1, x) = -3x(1 - x2
    )1/2
  • assoc_legendre(2, 2, x) = 3(1 - x2
    )

[編集]

(gcc 6.0で示されたとおりに動作します)

#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1
#include <cmath>
#include <iostream>
 
double P20(double x)
{
    return 0.5 * (3 * x * x - 1);
}
 
double P21(double x)
{
    return -3.0 * x * std::sqrt(1 - x * x);
}
 
double P22(double x)
{
    return 3 * (1 - x * x);
}
 
int main()
{
    // spot-checks
    std::cout << std::assoc_legendre(2, 0, 0.5) << '=' << P20(0.5) << '\n'
              << std::assoc_legendre(2, 1, 0.5) << '=' << P21(0.5) << '\n'
              << std::assoc_legendre(2, 2, 0.5) << '=' << P22(0.5) << '\n';
}

出力

-0.125=-0.125
-1.29904=-1.29904
2.25=2.25

[編集] 関連項目

ルジャンドル多項式
(関数) [編集]

[編集] 外部リンク

Weisstein, Eric W. "Associated Legendre Polynomial." From MathWorld--A Wolfram Web Resource.

English 日本語 中文(简体) 中文(繁體)