std::laguerre, std::laguerref, std::laguerrel
来自cppreference.com
< cpp | experimental | special functions
double laguerre( unsigned int n, double x ); double laguerre( unsigned int n, float x ); |
(1) | |
double laguerre( unsigned int n, IntegralType x ); |
(2) | |
与所有特殊函数一样,仅当实现将 __STDCPP_MATH_SPEC_FUNCS__
定义为至少 201003L 的值,且用户在包含任何标准库头文件前定义了 __STDCPP_WANT_MATH_SPEC_FUNCS__
时,laguerre
才保证在 <cmath>
中可用。
参数
n | - | 多项式的度数,无符号整数类型的值 |
x | - | 实参,浮点或整数类型的值 |
返回值
如果未发生错误,则返回 x 的无连带拉盖尔多项式的值,即ex |
n! |
dn |
dxn |
e-x)。
错误处理
根据 math_errhandling 的规定进行错误报告。
- 如果实参为 NaN,则返回 NaN 但不报告定义域错误。
- 如果 x 为负数,则发生定义域错误。
- 如果 n 大于或等于 128,则其行为由实现定义。
注解
不支持 TR 29124 但支持 TR 19768 的实现,在头文件 tr1/cmath
和命名空间 std::tr1
中提供此函数。
此函数的实现也在 boost.math 中可用。
拉盖尔多项式是方程 xy,,
+ (1 - x)y,
+ ny = 0 的多项式解。
前几个为:
- laguerre(0, x) = 1。
- laguerre(1, x) = -x + 1。
- laguerre(2, x) =
[x21 2
- 4x + 2]。 - laguerre(3, x) =
[-x31 6
- 9x2
- 18x + 6]。
示例
(以 gcc 6.0 运行)
运行此代码
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1 #include <cmath> #include <iostream> double L1(double x) { return -x + 1; } double L2(double x) { return 0.5 * (x * x - 4 * x + 2); } int main() { // spot-checks std::cout << std::laguerre(1, 0.5) << '=' << L1(0.5) << '\n' << std::laguerre(2, 0.5) << '=' << L2(0.5) << '\n'; }
输出:
0.5=0.5 0.125=0.125
参阅
关联拉盖尔多项式 (函数) |
外部链接
Weisstein, Eric W. "Laguerre Polynomial." From MathWorld--A Wolfram Web Resource.