namespace std {
float comp_ellint_1f(float k);
double comp_ellint_1(double k);
long double comp_ellint_1l(long double k);
}
概要
第一種完全楕円積分 (complete elliptic integral of the first kind) を計算する。
戻り値
引数 k
の第一種完全楕円積分
$$
K(k) = F(k, \pi/2) = \int_0^{\pi/2} \frac{\mathrm d\theta}{\sqrt{1 - k^2 \sin^2 \theta}}
\quad \text{for } |k| \le 1
$$
を返す。
$ F(k, \phi) $ は第一種不完全楕円積分 (ellint_1
)。
例
#include <cmath>
#include <iostream>
int main() {
std::cout << "comp_ellint_1(0) = " << std::comp_ellint_1(0) << "\n"; // π / 2
std::cout << "comp_ellint_1(0.5) = " << std::comp_ellint_1(0.5) << "\n"; // 1.68575
std::cout << "comp_ellint_1(1) = " << std::comp_ellint_1(1) << "\n"; // ∞
}
出力例
comp_ellint_1(0) = 1.5708
comp_ellint_1(0.5) = 1.68575
comp_ellint_1(1) = nan
バージョン
言語
- C++17
処理系
- Clang: ??
- GCC: 7.1.0
- ICC: ??
- Visual C++: ??
備考
GCC (libstdc++)
GCC 7.1.0–8.0.0 では定義域エラーが発生したときに std::numeric_limits::quiet_NaN
を返す。
関連項目
- 第一種不完全楕円積分
ellint_1
参照
- N3060 JTC1.22.29124 Programming Language C++ — Special Math Functions
- WG21 P0226R1 Mathematical Special Functions for C++17, v5
- ISO/IEC 29124:2010 Information technology -- Programming languages, their environments and system software interfaces -- Extensions to the C++ Library to support mathematical special functions
実装例
級数
$$ K(k) = \frac{\pi}{2} \sum_{n=0}^\infty \left[ \frac{(2n-1)!!}{(2n)!!} \right]^2 k^{2n} $$