Namespaces
Variants

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

From cppreference.net
ヘッダー <cmath> で定義
(1)
float assoc_legendre ( unsigned int n, unsigned int m, float x ) ;

double assoc_legendre ( unsigned int n, unsigned int m, double x ) ;

long double assoc_legendre ( unsigned int n, unsigned int m, long double x ) ;
(C++17以降)
(C++23以前)
/* floating-point-type */ assoc_legendre ( unsigned int n, unsigned int m,
/* floating-point-type */ x ) ;
(C++23以降)
float assoc_legendref ( unsigned int n, unsigned int m, float x ) ;
(2) (C++17以降)
long double assoc_legendrel ( unsigned int n, unsigned int m, long double x ) ;
(3) (C++17以降)
ヘッダー <cmath> で定義
template < class Integer >
double assoc_legendre ( unsigned int n, unsigned int m, Integer x ) ;
(A) (C++17以降)
1-3) 次数 n 、位数 m 、引数 x 陪ルジャンドル多項式 を計算する。 このライブラリは、パラメータ x の型として、すべてのcv修飾されていない浮動小数点型に対する std::assoc_legendre のオーバーロードを提供する。 (C++23以降)
A) すべての整数型に対して追加のオーバーロードが提供されており、これらは double として扱われます。

目次

パラメータ

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

戻り値

If no errors occur, value of the associated Legendre polynomial P m
n
of x , that is (1-x 2
) m/2
d m
dx m
P n (x)
, is returned (where P n (x) is the unassociated Legendre polynomial, std:: legendre ( n, x ) ).

この定義からは Condon-Shortley位相項 (-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.mathでも利用可能 であり、 boost::math::legendre_p として提供されています。ただし、boost.mathの定義にはCondon-Shortley位相項が含まれています。

最初のいくつかのルジャンドル陪多項式は以下の通りです:

関数 多項式
assoc_legendre ( 0 , 0 , x ) 1
assoc_legendre ( 1 , 0 , x ) x
assoc_legendre ( 1 , 1 , x ) (1 - x 2
) 1/2
assoc_legendre ( 2 , 0 , x )
1
2
(3x 2
- 1)
assoc_legendre ( 2 , 1 , x ) 3x(1 - x 2
) 1/2
assoc_legendre ( 2 , 2 , x ) 3(1 - x 2
)

追加のオーバーロードは (A) と完全に同一である必要はありません。整数型の引数 num に対して、 std :: assoc_legendre ( int_num1, int_num2, num ) std :: assoc_legendre ( int_num1, int_num2, static_cast < double > ( num ) ) と同じ効果を持つことを保証するのに十分なものであればよいのです。

#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()
{
    // スポットチェック
    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)
ルジャンドル多項式
(関数)

外部リンク

Weisstein, Eric W. "Associated Legendre Polynomial." From MathWorld — A Wolfram Web Resource.
Weisstein, Eric W. "Associated Legendre Polynomial." MathWorld — Wolfram Web リソースより。