std:: comp_ellint_1, std:: comp_ellint_1f, std:: comp_ellint_1l
|
定义于头文件
<cmath>
|
||
| (1) | ||
|
double
comp_ellint_1
(
double
k
)
;
float
comp_ellint_1
(
float
k
)
;
|
(C++17 起)
(C++23 前) |
|
|
/* floating-point-type */
comp_ellint_1
(
/* floating-point-type */
k
)
;
|
(C++23 起) | |
|
float
comp_ellint_1f
(
float
k
)
;
|
(2) | (C++17 起) |
|
long
double
comp_ellint_1l
(
long
double
k
)
;
|
(3) | (C++17 起) |
|
定义于头文件
<cmath>
|
||
|
template
<
class
Integer
>
double comp_ellint_1 ( Integer k ) ; |
(A) | (C++17 起) |
目录 |
参数
| k | - | 椭圆模量或离心率(浮点数或整数值) |
返回值
若无错误发生,则返回第一类完全椭圆积分 k 的值,即 std:: ellint_1 ( k, π / 2 ) 。
错误处理
错误报告方式可按照 math_errhandling 中的规定执行。
- 如果参数为 NaN,则返回 NaN 且不报告定义域错误。
- 如果 |k|>1 ,可能出现定义域错误。
注释
不支持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 中找到 。
额外的重载不需要完全按照 (A) 的形式提供。只需确保对于整数类型的实参 num , std :: comp_ellint_1 ( num ) 与 std :: comp_ellint_1 ( static_cast < double > ( num ) ) 具有相同效果即可。
示例
长度为
l
的单摆周期,在重力加速度为
g
、初始角度为 θ 时等于
4⋅
√
l/g
⋅K(sin(θ/2))
,其中
K
为
std::comp_ellint_1
。
#include <cmath> #include <iostream> #include <numbers> int main() { constexpr double π{std::numbers::pi}; std::cout << "K(0) ≈ " << std::comp_ellint_1(0) << '\n' << "π/2 ≈ " << π / 2 << '\n' << "K(0.5) ≈ " << std::comp_ellint_1(0.5) << '\n' << "F(0.5, π/2) ≈ " << std::ellint_1(0.5, π / 2) << '\n' << "The period of a pendulum length 1m at 10° initial angle ≈ " << 4 * std::sqrt(1 / 9.80665) * std::comp_ellint_1(std::sin(π / 18 / 2)) << "s,\n" "whereas the linear approximation gives ≈ " << 2 * π * std::sqrt(1 / 9.80665) << '\n'; }
输出:
K(0) ≈ 1.5708 π/2 ≈ 1.5708 K(0.5) ≈ 1.68575 F(0.5, π/2) ≈ 1.68575 The period of a pendulum length 1 m at 10° initial angle ≈ 2.01024s, whereas the linear approximation gives ≈ 2.00641
参见
|
(C++17)
(C++17)
(C++17)
|
第一类(不完全)椭圆积分
(函数) |
外部链接
| 魏斯坦, 埃里克·W. "第一类完全椭圆积分." 摘自 MathWorld —— 一个 Wolfram 网络资源。 |