std:: legendre, std:: legendref, std:: legendrel
|
double
legendre
(
unsigned
int
n,
double
x
)
;
double
legendre
(
unsigned
int
n,
float
x
)
;
|
(1) | |
|
double
legendre
(
unsigned
int
n, IntegralType x
)
;
|
(2) | |
すべての特殊関数と同様に、
legendre
は、
__STDCPP_MATH_SPEC_FUNCS__
が実装によって少なくとも201003L以上の値として定義されており、かつユーザーが標準ライブラリヘッダーを含める前に
__STDCPP_WANT_MATH_SPEC_FUNCS__
を定義している場合にのみ、
<cmath>
で利用可能であることが保証されています。
目次 |
パラメータ
| n | - | 多項式の次数 |
| x | - | 引数、浮動小数点型または整数型の値 |
戻り値
If no errors occur, value of the order-
n
unassociated Legendre polynomial of
x
, that is
| 1 |
|
2
n
n! |
|
d
n
|
|
dx
n
|
- 1) n
, is returned.
エラーハンドリング
エラーは、 math_errhandling で指定された通りに報告される場合があります。
- 引数がNaNの場合、NaNが返され、定義域エラーは報告されません。
- この関数は |x| > 1 において定義される必要はありません。
- n が128以上の場合、動作は実装定義となります。
注記
TR 29124をサポートしていないがTR 19768をサポートしている実装では、この関数はヘッダ
tr1/cmath
および名前空間
std::tr1
で提供されます。
この関数の実装は boost.math でも利用可能です。
最初のいくつかのルジャンドル多項式は以下の通りです:
- legendre(0, x) = 1 .
- legendre(1, x) = x .
-
legendre(2, x) =
(3x 21 2
- 1) . -
legendre(3, x) =
(5x 31 2
- 3x) . -
legendre(4, x) =
(35x 41 8
- 30x 2
+ 3) .
例
(gcc 6.0で示した通り動作します)
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 #include <cmath> #include <iostream> double P3(double x) { return 0.5 * (5 * std::pow(x, 3) - 3 * x); } double P4(double x) { return 0.125 * (35 * std::pow(x, 4) - 30 * x * x + 3); } int main() { // スポットチェック std::cout << std::legendre(3, 0.25) << '=' << P3(0.25) << '\n' << std::legendre(4, 0.25) << '=' << P4(0.25) << '\n'; }
出力:
-0.335938=-0.335938 0.157715=0.157715
関連項目
|
ラゲール多項式
(関数) |
|
|
エルミート多項式
(関数) |
外部リンク
| Weisstein, Eric W. "Legendre Polynomial." From MathWorld — A Wolfram Web Resource. |