名前空間
変種
操作

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

提供: cppreference.com
 
 
 
 
ヘッダ <cmath> で定義
double      assoc_legendre( unsigned int n, unsigned int m, double x );

float       assoc_legendre( unsigned int n, unsigned int m, float x );
long 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) (C++17以上)
double      assoc_legendre( unsigned int n, unsigned int m, 整数型 x );
(2) (C++17以上)
1) 次数 n、位数 m、引数 xルジャンドル陪多項式を計算します。
2) 任意の整数型の引数を取るオーバーロード集合または関数テンプレート。 引数を double にキャストした後は (1) と同等です。

目次

[編集] 引数

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

[編集] 戻り値

エラーが発生しなければ、 x のルジャンドル陪多項式 Pm
n
、すなわち (1-x2
)m/2
dm
dxm
P
n
(x)
の値が返されます (ただし P
n
(x)
はルジャンドル多項式 std::legendre(n, x) です)。

コンドン–ショートレーの位相項 (-1)m
はこの定義から省かれていることに注意してください。

[編集] エラー処理

エラーは math_errhandling で規定されている通りに報告されます。

  • 引数が NaN の場合は、 NaN が返されます。 定義域エラーは報告されません。
  • |x| > 1 の場合は、定義域エラーが発生するかもしれません。
  • n が128以上の場合、動作は処理系定義です。

[編集] ノート

C++17 をサポートしないけれども ISO 29124:2010 をサポートする処理系は、 __STDCPP_MATH_SPEC_FUNCS__ が処理系によって少なくとも 201003L の値に定義されており、ユーザがいかなる標準ライブラリのヘッダもインクルードする前に __STDCPP_WANT_MATH_SPEC_FUNCS__ を定義する場合、この関数を提供します。

ISO 29124:2010 をサポートしなけれども TR 19768:2007 (TR1) をサポートする処理系は、ヘッダ <tr1/cmath> および名前空間 std::tr1 で、この関数を提供します。

この関数の実装は boost.mathboost::math::legendre_p としても利用可能です。 ただし 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
    )

[編集]

#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

[編集] 関連項目

(C++17)(C++17)(C++17)
ルジャンドル多項式
(関数) [edit]

[編集] 外部リンク

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