最終更新日時(UTC):
が更新

履歴 編集

function
<cmath>

std::ellint_2(C++17)

namespace std {
  double
    ellint_2(double k,
             double phi);              // (1) C++17
  floating-point-type
    ellint_2(floating-point-type k,
             floating-point-type phi); // (1) C++23

  Promoted
    ellint_2(Arithmetic1 k,
             Arithmetic2 phi);         // (2) C++17

  float
    ellint_2f(float k,
              float phi);              // (3) C++17

  long double
    ellint_2l(long double k,
              long double phi);        // (4) C++17
}

概要

第2種不完全楕円積分 (incomplete elliptic integral of the second kind) を計算する。

  • (1) :
    • C++17 : doubleに対するオーバーロード
    • C++23 : 浮動小数点数型に対するオーバーロード
  • (2) : 算術型に対するオーバーロード (対応する大きい方の精度の浮動小数点数型にキャストして計算される)
  • (3) : float型規定
  • (4) : long double型規定

戻り値

引数 k, phi の第2種不完全楕円積分 $$ E(k, \phi) = \int_0^\phi \mathrm d\theta ~ \sqrt{1 - k^2 \sin^2 \theta} \quad \text{for } |k| \le 1 $$ を返す。

備考

#include <cmath>
#include <iostream>

constexpr double pi = 3.141592653589793;

void p(double k) {
  for (double q : {0., 0.25, 0.5})
    std::cout << "ellint_2(" << k << ", " << q << " pi) = " << std::ellint_2(k, q * pi) << "\n";
  std::cout << "\n";
}

int main() {
  p(0);   // ellint_2(0, phi) = phi
  p(0.5);
  p(1);   // ellint_2(1, phi) = sin(phi) for phi ∈ [-π/2, π/2]
}

出力例

ellint_2(0, 0 pi) = 0
ellint_2(0, 0.25 pi) = 0.785398
ellint_2(0, 0.5 pi) = 1.5708

ellint_2(0.5, 0 pi) = 0
ellint_2(0.5, 0.25 pi) = 0.767196
ellint_2(0.5, 0.5 pi) = 1.46746

ellint_2(1, 0 pi) = 0
ellint_2(1, 0.25 pi) = 0.707107
ellint_2(1, 0.5 pi) = 1

バージョン

言語

  • C++17

処理系

関連項目

参照