名稱空間
變體
操作

std::hermite, std::hermitef, std::hermitel

來自 cppreference.com
< cpp‎ | 數值‎ | 特殊函式
 
 
 
 
定義於標頭檔案 <cmath>
(1)
double      hermite ( unsigned int n, double x );

float       hermite ( unsigned int n, float x );

long double hermite ( unsigned int n, long double x );
(C++17 起)
(直至 C++23)
/* floating-point-type */ hermite( unsigned int n,
                                   /* 浮點型別 */ x );
(C++23 起)
float       hermitef( unsigned int n, float x );
(2) (C++17 起)
long double hermitel( unsigned int n, long double x );
(3) (C++17 起)
定義於標頭檔案 <cmath>
template< class Integer >
double      hermite ( unsigned int n, Integer x );
(A) (C++17 起)
1-3) 計算次數為 n、變數為 x 的(物理學家定義的)Hermite 多項式的值。 庫為所有 cv 非限定浮點型別提供了 std::hermite 的過載,作為引數 x 的型別。(C++23 起)
A) 為所有整數型別提供了額外的過載,它們被視為 double

目錄

[編輯] 引數

n - 多項式的次數
x - 變數,浮點或整數值

[編輯] 返回值

如果未發生錯誤,則返回 xn 階 Hermite 多項式的值,即 (-1)n
ex2
dn
dxn
e-x2

[編輯] 錯誤處理

錯誤可能按 math_errhandling 中指定的方式報告。

  • 如果引數是 NaN,則返回 NaN 且不報告域錯誤。
  • 如果 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 中找到

Hermite 多項式是方程 u,,
-2xu,
= -2nu
的多項式解。

前幾個 Hermite 多項式為:

函式 多項式
    hermite(0, x)     1
hermite(1, x) 2x
hermite(2, x) 4x2
- 2
hermite(3, x) 8x3
- 12x
hermite(4, x)     16x4
- 48x2
+ 12
    

不需要完全按照 (A) 提供額外的過載。它們只需足以確保對於整數型別引數 numstd::hermite(int_num, num) 的效果與 std::hermite(int_num, static_cast<double>(num)) 相同。

[編輯] 示例

#include <cmath>
#include <iostream>
 
double H3(double x)
{
    return 8 * std::pow(x, 3) - 12 * x;
}
 
double H4(double x)
{
    return 16 * std::pow(x, 4) - 48 * x * x + 12;
}
 
int main()
{
    // spot-checks
    std::cout << std::hermite(3, 10) << '=' << H3(10) << '\n'
              << std::hermite(4, 10) << '=' << H4(10) << '\n';
}

輸出

7880=7880
155212=155212

[編輯] 參閱

(C++17)(C++17)(C++17)
拉蓋爾多項式
(函式) [編輯]
(C++17)(C++17)(C++17)
勒讓德多項式
(函式) [編輯]

[編輯] 外部連結

Weisstein, Eric W. "Hermite Polynomial." 來自 MathWorld — Wolfram Web Resource。