EllipticFunction.hpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /**
  2. * \file EllipticFunction.hpp
  3. * \brief Header for GeographicLib::EllipticFunction class
  4. *
  5. * Copyright (c) Charles Karney (2008-2021) <charles@karney.com> and licensed
  6. * under the MIT/X11 License. For more information, see
  7. * https://geographiclib.sourceforge.io/
  8. **********************************************************************/
  9. #if !defined(GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP)
  10. #define GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP 1
  11. #include <GeographicLib/Constants.hpp>
  12. namespace GeographicLib {
  13. /**
  14. * \brief Elliptic integrals and functions
  15. *
  16. * This provides the elliptic functions and integrals needed for Ellipsoid,
  17. * GeodesicExact, and TransverseMercatorExact. Two categories of function
  18. * are provided:
  19. * - \e static functions to compute symmetric elliptic integrals
  20. * (https://dlmf.nist.gov/19.16.i)
  21. * - \e member functions to compute Legrendre's elliptic
  22. * integrals (https://dlmf.nist.gov/19.2.ii) and the
  23. * Jacobi elliptic functions (https://dlmf.nist.gov/22.2).
  24. * .
  25. * In the latter case, an object is constructed giving the modulus \e k (and
  26. * optionally the parameter &alpha;<sup>2</sup>). The modulus is always
  27. * passed as its square <i>k</i><sup>2</sup> which allows \e k to be pure
  28. * imaginary (<i>k</i><sup>2</sup> &lt; 0). (Confusingly, Abramowitz and
  29. * Stegun call \e m = <i>k</i><sup>2</sup> the "parameter" and \e n =
  30. * &alpha;<sup>2</sup> the "characteristic".)
  31. *
  32. * In geodesic applications, it is convenient to separate the incomplete
  33. * integrals into secular and periodic components, e.g.,
  34. * \f[
  35. * E(\phi, k) = (2 E(k) / \pi) [ \phi + \delta E(\phi, k) ]
  36. * \f]
  37. * where &delta;\e E(&phi;, \e k) is an odd periodic function with period
  38. * &pi;.
  39. *
  40. * The computation of the elliptic integrals uses the algorithms given in
  41. * - B. C. Carlson,
  42. * <a href="https://doi.org/10.1007/BF02198293"> Computation of real or
  43. * complex elliptic integrals</a>, Numerical Algorithms 10, 13--26 (1995)
  44. * .
  45. * with the additional optimizations given in https://dlmf.nist.gov/19.36.i.
  46. * The computation of the Jacobi elliptic functions uses the algorithm given
  47. * in
  48. * - R. Bulirsch,
  49. * <a href="https://doi.org/10.1007/BF01397975"> Numerical Calculation of
  50. * Elliptic Integrals and Elliptic Functions</a>, Numericshe Mathematik 7,
  51. * 78--90 (1965).
  52. * .
  53. * The notation follows https://dlmf.nist.gov/19 and https://dlmf.nist.gov/22
  54. *
  55. * Example of use:
  56. * \include example-EllipticFunction.cpp
  57. **********************************************************************/
  58. class GEOGRAPHICLIB_EXPORT EllipticFunction {
  59. private:
  60. typedef Math::real real;
  61. enum { num_ = 13 }; // Max depth required for sncndn; probably 5 is enough.
  62. real _k2, _kp2, _alpha2, _alphap2, _eps;
  63. real _Kc, _Ec, _Dc, _Pic, _Gc, _Hc;
  64. public:
  65. /** \name Constructor
  66. **********************************************************************/
  67. ///@{
  68. /**
  69. * Constructor specifying the modulus and parameter.
  70. *
  71. * @param[in] k2 the square of the modulus <i>k</i><sup>2</sup>.
  72. * <i>k</i><sup>2</sup> must lie in (&minus;&infin;, 1].
  73. * @param[in] alpha2 the parameter &alpha;<sup>2</sup>.
  74. * &alpha;<sup>2</sup> must lie in (&minus;&infin;, 1].
  75. * @exception GeographicErr if \e k2 or \e alpha2 is out of its legal
  76. * range.
  77. *
  78. * If only elliptic integrals of the first and second kinds are needed,
  79. * then set &alpha;<sup>2</sup> = 0 (the default value); in this case, we
  80. * have &Pi;(&phi;, 0, \e k) = \e F(&phi;, \e k), \e G(&phi;, 0, \e k) = \e
  81. * E(&phi;, \e k), and \e H(&phi;, 0, \e k) = \e F(&phi;, \e k) - \e
  82. * D(&phi;, \e k).
  83. **********************************************************************/
  84. EllipticFunction(real k2 = 0, real alpha2 = 0)
  85. { Reset(k2, alpha2); }
  86. /**
  87. * Constructor specifying the modulus and parameter and their complements.
  88. *
  89. * @param[in] k2 the square of the modulus <i>k</i><sup>2</sup>.
  90. * <i>k</i><sup>2</sup> must lie in (&minus;&infin;, 1].
  91. * @param[in] alpha2 the parameter &alpha;<sup>2</sup>.
  92. * &alpha;<sup>2</sup> must lie in (&minus;&infin;, 1].
  93. * @param[in] kp2 the complementary modulus squared <i>k'</i><sup>2</sup> =
  94. * 1 &minus; <i>k</i><sup>2</sup>. This must lie in [0, &infin;).
  95. * @param[in] alphap2 the complementary parameter &alpha;'<sup>2</sup> = 1
  96. * &minus; &alpha;<sup>2</sup>. This must lie in [0, &infin;).
  97. * @exception GeographicErr if \e k2, \e alpha2, \e kp2, or \e alphap2 is
  98. * out of its legal range.
  99. *
  100. * The arguments must satisfy \e k2 + \e kp2 = 1 and \e alpha2 + \e alphap2
  101. * = 1. (No checking is done that these conditions are met.) This
  102. * constructor is provided to enable accuracy to be maintained, e.g., when
  103. * \e k is very close to unity.
  104. **********************************************************************/
  105. EllipticFunction(real k2, real alpha2, real kp2, real alphap2)
  106. { Reset(k2, alpha2, kp2, alphap2); }
  107. /**
  108. * Reset the modulus and parameter.
  109. *
  110. * @param[in] k2 the new value of square of the modulus
  111. * <i>k</i><sup>2</sup> which must lie in (&minus;&infin;, ].
  112. * done.)
  113. * @param[in] alpha2 the new value of parameter &alpha;<sup>2</sup>.
  114. * &alpha;<sup>2</sup> must lie in (&minus;&infin;, 1].
  115. * @exception GeographicErr if \e k2 or \e alpha2 is out of its legal
  116. * range.
  117. **********************************************************************/
  118. void Reset(real k2 = 0, real alpha2 = 0)
  119. { Reset(k2, alpha2, 1 - k2, 1 - alpha2); }
  120. /**
  121. * Reset the modulus and parameter supplying also their complements.
  122. *
  123. * @param[in] k2 the square of the modulus <i>k</i><sup>2</sup>.
  124. * <i>k</i><sup>2</sup> must lie in (&minus;&infin;, 1].
  125. * @param[in] alpha2 the parameter &alpha;<sup>2</sup>.
  126. * &alpha;<sup>2</sup> must lie in (&minus;&infin;, 1].
  127. * @param[in] kp2 the complementary modulus squared <i>k'</i><sup>2</sup> =
  128. * 1 &minus; <i>k</i><sup>2</sup>. This must lie in [0, &infin;).
  129. * @param[in] alphap2 the complementary parameter &alpha;'<sup>2</sup> = 1
  130. * &minus; &alpha;<sup>2</sup>. This must lie in [0, &infin;).
  131. * @exception GeographicErr if \e k2, \e alpha2, \e kp2, or \e alphap2 is
  132. * out of its legal range.
  133. *
  134. * The arguments must satisfy \e k2 + \e kp2 = 1 and \e alpha2 + \e alphap2
  135. * = 1. (No checking is done that these conditions are met.) This
  136. * constructor is provided to enable accuracy to be maintained, e.g., when
  137. * is very small.
  138. **********************************************************************/
  139. void Reset(real k2, real alpha2, real kp2, real alphap2);
  140. ///@}
  141. /** \name Inspector functions.
  142. **********************************************************************/
  143. ///@{
  144. /**
  145. * @return the square of the modulus <i>k</i><sup>2</sup>.
  146. **********************************************************************/
  147. Math::real k2() const { return _k2; }
  148. /**
  149. * @return the square of the complementary modulus <i>k'</i><sup>2</sup> =
  150. * 1 &minus; <i>k</i><sup>2</sup>.
  151. **********************************************************************/
  152. Math::real kp2() const { return _kp2; }
  153. /**
  154. * @return the parameter &alpha;<sup>2</sup>.
  155. **********************************************************************/
  156. Math::real alpha2() const { return _alpha2; }
  157. /**
  158. * @return the complementary parameter &alpha;'<sup>2</sup> = 1 &minus;
  159. * &alpha;<sup>2</sup>.
  160. **********************************************************************/
  161. Math::real alphap2() const { return _alphap2; }
  162. ///@}
  163. /** \name Complete elliptic integrals.
  164. **********************************************************************/
  165. ///@{
  166. /**
  167. * The complete integral of the first kind.
  168. *
  169. * @return \e K(\e k).
  170. *
  171. * \e K(\e k) is defined in https://dlmf.nist.gov/19.2.E4
  172. * \f[
  173. * K(k) = \int_0^{\pi/2} \frac1{\sqrt{1-k^2\sin^2\phi}}\,d\phi.
  174. * \f]
  175. **********************************************************************/
  176. Math::real K() const { return _Kc; }
  177. /**
  178. * The complete integral of the second kind.
  179. *
  180. * @return \e E(\e k).
  181. *
  182. * \e E(\e k) is defined in https://dlmf.nist.gov/19.2.E5
  183. * \f[
  184. * E(k) = \int_0^{\pi/2} \sqrt{1-k^2\sin^2\phi}\,d\phi.
  185. * \f]
  186. **********************************************************************/
  187. Math::real E() const { return _Ec; }
  188. /**
  189. * Jahnke's complete integral.
  190. *
  191. * @return \e D(\e k).
  192. *
  193. * \e D(\e k) is defined in https://dlmf.nist.gov/19.2.E6
  194. * \f[
  195. * D(k) =
  196. * \int_0^{\pi/2} \frac{\sin^2\phi}{\sqrt{1-k^2\sin^2\phi}}\,d\phi.
  197. * \f]
  198. **********************************************************************/
  199. Math::real D() const { return _Dc; }
  200. /**
  201. * The difference between the complete integrals of the first and second
  202. * kinds.
  203. *
  204. * @return \e K(\e k) &minus; \e E(\e k).
  205. **********************************************************************/
  206. Math::real KE() const { return _k2 * _Dc; }
  207. /**
  208. * The complete integral of the third kind.
  209. *
  210. * @return &Pi;(&alpha;<sup>2</sup>, \e k).
  211. *
  212. * &Pi;(&alpha;<sup>2</sup>, \e k) is defined in
  213. * https://dlmf.nist.gov/19.2.E7
  214. * \f[
  215. * \Pi(\alpha^2, k) = \int_0^{\pi/2}
  216. * \frac1{\sqrt{1-k^2\sin^2\phi}(1 - \alpha^2\sin^2\phi)}\,d\phi.
  217. * \f]
  218. **********************************************************************/
  219. Math::real Pi() const { return _Pic; }
  220. /**
  221. * Legendre's complete geodesic longitude integral.
  222. *
  223. * @return \e G(&alpha;<sup>2</sup>, \e k).
  224. *
  225. * \e G(&alpha;<sup>2</sup>, \e k) is given by
  226. * \f[
  227. * G(\alpha^2, k) = \int_0^{\pi/2}
  228. * \frac{\sqrt{1-k^2\sin^2\phi}}{1 - \alpha^2\sin^2\phi}\,d\phi.
  229. * \f]
  230. **********************************************************************/
  231. Math::real G() const { return _Gc; }
  232. /**
  233. * Cayley's complete geodesic longitude difference integral.
  234. *
  235. * @return \e H(&alpha;<sup>2</sup>, \e k).
  236. *
  237. * \e H(&alpha;<sup>2</sup>, \e k) is given by
  238. * \f[
  239. * H(\alpha^2, k) = \int_0^{\pi/2}
  240. * \frac{\cos^2\phi}{(1-\alpha^2\sin^2\phi)\sqrt{1-k^2\sin^2\phi}}
  241. * \,d\phi.
  242. * \f]
  243. **********************************************************************/
  244. Math::real H() const { return _Hc; }
  245. ///@}
  246. /** \name Incomplete elliptic integrals.
  247. **********************************************************************/
  248. ///@{
  249. /**
  250. * The incomplete integral of the first kind.
  251. *
  252. * @param[in] phi
  253. * @return \e F(&phi;, \e k).
  254. *
  255. * \e F(&phi;, \e k) is defined in https://dlmf.nist.gov/19.2.E4
  256. * \f[
  257. * F(\phi, k) = \int_0^\phi \frac1{\sqrt{1-k^2\sin^2\theta}}\,d\theta.
  258. * \f]
  259. **********************************************************************/
  260. Math::real F(real phi) const;
  261. /**
  262. * The incomplete integral of the second kind.
  263. *
  264. * @param[in] phi
  265. * @return \e E(&phi;, \e k).
  266. *
  267. * \e E(&phi;, \e k) is defined in https://dlmf.nist.gov/19.2.E5
  268. * \f[
  269. * E(\phi, k) = \int_0^\phi \sqrt{1-k^2\sin^2\theta}\,d\theta.
  270. * \f]
  271. **********************************************************************/
  272. Math::real E(real phi) const;
  273. /**
  274. * The incomplete integral of the second kind with the argument given in
  275. * degrees.
  276. *
  277. * @param[in] ang in <i>degrees</i>.
  278. * @return \e E(&pi; <i>ang</i>/180, \e k).
  279. **********************************************************************/
  280. Math::real Ed(real ang) const;
  281. /**
  282. * The inverse of the incomplete integral of the second kind.
  283. *
  284. * @param[in] x
  285. * @return &phi; = <i>E</i><sup>&minus;1</sup>(\e x, \e k); i.e., the
  286. * solution of such that \e E(&phi;, \e k) = \e x.
  287. **********************************************************************/
  288. Math::real Einv(real x) const;
  289. /**
  290. * The incomplete integral of the third kind.
  291. *
  292. * @param[in] phi
  293. * @return &Pi;(&phi;, &alpha;<sup>2</sup>, \e k).
  294. *
  295. * &Pi;(&phi;, &alpha;<sup>2</sup>, \e k) is defined in
  296. * https://dlmf.nist.gov/19.2.E7
  297. * \f[
  298. * \Pi(\phi, \alpha^2, k) = \int_0^\phi
  299. * \frac1{\sqrt{1-k^2\sin^2\theta}(1 - \alpha^2\sin^2\theta)}\,d\theta.
  300. * \f]
  301. **********************************************************************/
  302. Math::real Pi(real phi) const;
  303. /**
  304. * Jahnke's incomplete elliptic integral.
  305. *
  306. * @param[in] phi
  307. * @return \e D(&phi;, \e k).
  308. *
  309. * \e D(&phi;, \e k) is defined in https://dlmf.nist.gov/19.2.E4
  310. * \f[
  311. * D(\phi, k) = \int_0^\phi
  312. * \frac{\sin^2\theta}{\sqrt{1-k^2\sin^2\theta}}\,d\theta.
  313. * \f]
  314. **********************************************************************/
  315. Math::real D(real phi) const;
  316. /**
  317. * Legendre's geodesic longitude integral.
  318. *
  319. * @param[in] phi
  320. * @return \e G(&phi;, &alpha;<sup>2</sup>, \e k).
  321. *
  322. * \e G(&phi;, &alpha;<sup>2</sup>, \e k) is defined by
  323. * \f[
  324. * \begin{align}
  325. * G(\phi, \alpha^2, k) &=
  326. * \frac{k^2}{\alpha^2} F(\phi, k) +
  327. * \biggl(1 - \frac{k^2}{\alpha^2}\biggr) \Pi(\phi, \alpha^2, k) \\
  328. * &= \int_0^\phi
  329. * \frac{\sqrt{1-k^2\sin^2\theta}}{1 - \alpha^2\sin^2\theta}\,d\theta.
  330. * \end{align}
  331. * \f]
  332. *
  333. * Legendre expresses the longitude of a point on the geodesic in terms of
  334. * this combination of elliptic integrals in Exercices de Calcul
  335. * Int&eacute;gral, Vol. 1 (1811), p. 181,
  336. * https://books.google.com/books?id=riIOAAAAQAAJ&pg=PA181.
  337. *
  338. * See \ref geodellip for the expression for the longitude in terms of this
  339. * function.
  340. **********************************************************************/
  341. Math::real G(real phi) const;
  342. /**
  343. * Cayley's geodesic longitude difference integral.
  344. *
  345. * @param[in] phi
  346. * @return \e H(&phi;, &alpha;<sup>2</sup>, \e k).
  347. *
  348. * \e H(&phi;, &alpha;<sup>2</sup>, \e k) is defined by
  349. * \f[
  350. * \begin{align}
  351. * H(\phi, \alpha^2, k) &=
  352. * \frac1{\alpha^2} F(\phi, k) +
  353. * \biggl(1 - \frac1{\alpha^2}\biggr) \Pi(\phi, \alpha^2, k) \\
  354. * &= \int_0^\phi
  355. * \frac{\cos^2\theta}
  356. * {(1-\alpha^2\sin^2\theta)\sqrt{1-k^2\sin^2\theta}}
  357. * \,d\theta.
  358. * \end{align}
  359. * \f]
  360. *
  361. * Cayley expresses the longitude difference of a point on the geodesic in
  362. * terms of this combination of elliptic integrals in Phil. Mag. <b>40</b>
  363. * (1870), p. 333, https://books.google.com/books?id=Zk0wAAAAIAAJ&pg=PA333.
  364. *
  365. * See \ref geodellip for the expression for the longitude in terms of this
  366. * function.
  367. **********************************************************************/
  368. Math::real H(real phi) const;
  369. ///@}
  370. /** \name Incomplete integrals in terms of Jacobi elliptic functions.
  371. **********************************************************************/
  372. ///@{
  373. /**
  374. * The incomplete integral of the first kind in terms of Jacobi elliptic
  375. * functions.
  376. *
  377. * @param[in] sn = sin&phi;.
  378. * @param[in] cn = cos&phi;.
  379. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  380. * sin<sup>2</sup>&phi;).
  381. * @return \e F(&phi;, \e k) as though &phi; &isin; (&minus;&pi;, &pi;].
  382. **********************************************************************/
  383. Math::real F(real sn, real cn, real dn) const;
  384. /**
  385. * The incomplete integral of the second kind in terms of Jacobi elliptic
  386. * functions.
  387. *
  388. * @param[in] sn = sin&phi;.
  389. * @param[in] cn = cos&phi;.
  390. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  391. * sin<sup>2</sup>&phi;).
  392. * @return \e E(&phi;, \e k) as though &phi; &isin; (&minus;&pi;, &pi;].
  393. **********************************************************************/
  394. Math::real E(real sn, real cn, real dn) const;
  395. /**
  396. * The incomplete integral of the third kind in terms of Jacobi elliptic
  397. * functions.
  398. *
  399. * @param[in] sn = sin&phi;.
  400. * @param[in] cn = cos&phi;.
  401. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  402. * sin<sup>2</sup>&phi;).
  403. * @return &Pi;(&phi;, &alpha;<sup>2</sup>, \e k) as though &phi; &isin;
  404. * (&minus;&pi;, &pi;].
  405. **********************************************************************/
  406. Math::real Pi(real sn, real cn, real dn) const;
  407. /**
  408. * Jahnke's incomplete elliptic integral in terms of Jacobi elliptic
  409. * functions.
  410. *
  411. * @param[in] sn = sin&phi;.
  412. * @param[in] cn = cos&phi;.
  413. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  414. * sin<sup>2</sup>&phi;).
  415. * @return \e D(&phi;, \e k) as though &phi; &isin; (&minus;&pi;, &pi;].
  416. **********************************************************************/
  417. Math::real D(real sn, real cn, real dn) const;
  418. /**
  419. * Legendre's geodesic longitude integral in terms of Jacobi elliptic
  420. * functions.
  421. *
  422. * @param[in] sn = sin&phi;.
  423. * @param[in] cn = cos&phi;.
  424. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  425. * sin<sup>2</sup>&phi;).
  426. * @return \e G(&phi;, &alpha;<sup>2</sup>, \e k) as though &phi; &isin;
  427. * (&minus;&pi;, &pi;].
  428. **********************************************************************/
  429. Math::real G(real sn, real cn, real dn) const;
  430. /**
  431. * Cayley's geodesic longitude difference integral in terms of Jacobi
  432. * elliptic functions.
  433. *
  434. * @param[in] sn = sin&phi;.
  435. * @param[in] cn = cos&phi;.
  436. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  437. * sin<sup>2</sup>&phi;).
  438. * @return \e H(&phi;, &alpha;<sup>2</sup>, \e k) as though &phi; &isin;
  439. * (&minus;&pi;, &pi;].
  440. **********************************************************************/
  441. Math::real H(real sn, real cn, real dn) const;
  442. ///@}
  443. /** \name Periodic versions of incomplete elliptic integrals.
  444. **********************************************************************/
  445. ///@{
  446. /**
  447. * The periodic incomplete integral of the first kind.
  448. *
  449. * @param[in] sn = sin&phi;.
  450. * @param[in] cn = cos&phi;.
  451. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  452. * sin<sup>2</sup>&phi;).
  453. * @return the periodic function &pi; \e F(&phi;, \e k) / (2 \e K(\e k)) -
  454. * &phi;.
  455. **********************************************************************/
  456. Math::real deltaF(real sn, real cn, real dn) const;
  457. /**
  458. * The periodic incomplete integral of the second kind.
  459. *
  460. * @param[in] sn = sin&phi;.
  461. * @param[in] cn = cos&phi;.
  462. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  463. * sin<sup>2</sup>&phi;).
  464. * @return the periodic function &pi; \e E(&phi;, \e k) / (2 \e E(\e k)) -
  465. * &phi;.
  466. **********************************************************************/
  467. Math::real deltaE(real sn, real cn, real dn) const;
  468. /**
  469. * The periodic inverse of the incomplete integral of the second kind.
  470. *
  471. * @param[in] stau = sin&tau;.
  472. * @param[in] ctau = sin&tau;.
  473. * @return the periodic function <i>E</i><sup>&minus;1</sup>(&tau; (2 \e
  474. * E(\e k)/&pi;), \e k) - &tau;.
  475. **********************************************************************/
  476. Math::real deltaEinv(real stau, real ctau) const;
  477. /**
  478. * The periodic incomplete integral of the third kind.
  479. *
  480. * @param[in] sn = sin&phi;.
  481. * @param[in] cn = cos&phi;.
  482. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  483. * sin<sup>2</sup>&phi;).
  484. * @return the periodic function &pi; &Pi;(&phi;, &alpha;<sup>2</sup>,
  485. * \e k) / (2 &Pi;(&alpha;<sup>2</sup>, \e k)) - &phi;.
  486. **********************************************************************/
  487. Math::real deltaPi(real sn, real cn, real dn) const;
  488. /**
  489. * The periodic Jahnke's incomplete elliptic integral.
  490. *
  491. * @param[in] sn = sin&phi;.
  492. * @param[in] cn = cos&phi;.
  493. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  494. * sin<sup>2</sup>&phi;).
  495. * @return the periodic function &pi; \e D(&phi;, \e k) / (2 \e D(\e k)) -
  496. * &phi;.
  497. **********************************************************************/
  498. Math::real deltaD(real sn, real cn, real dn) const;
  499. /**
  500. * Legendre's periodic geodesic longitude integral.
  501. *
  502. * @param[in] sn = sin&phi;.
  503. * @param[in] cn = cos&phi;.
  504. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  505. * sin<sup>2</sup>&phi;).
  506. * @return the periodic function &pi; \e G(&phi;, \e k) / (2 \e G(\e k)) -
  507. * &phi;.
  508. **********************************************************************/
  509. Math::real deltaG(real sn, real cn, real dn) const;
  510. /**
  511. * Cayley's periodic geodesic longitude difference integral.
  512. *
  513. * @param[in] sn = sin&phi;.
  514. * @param[in] cn = cos&phi;.
  515. * @param[in] dn = sqrt(1 &minus; <i>k</i><sup>2</sup>
  516. * sin<sup>2</sup>&phi;).
  517. * @return the periodic function &pi; \e H(&phi;, \e k) / (2 \e H(\e k)) -
  518. * &phi;.
  519. **********************************************************************/
  520. Math::real deltaH(real sn, real cn, real dn) const;
  521. ///@}
  522. /** \name Elliptic functions.
  523. **********************************************************************/
  524. ///@{
  525. /**
  526. * The Jacobi elliptic functions.
  527. *
  528. * @param[in] x the argument.
  529. * @param[out] sn sn(\e x, \e k).
  530. * @param[out] cn cn(\e x, \e k).
  531. * @param[out] dn dn(\e x, \e k).
  532. **********************************************************************/
  533. void sncndn(real x, real& sn, real& cn, real& dn) const;
  534. /**
  535. * The &Delta; amplitude function.
  536. *
  537. * @param[in] sn sin&phi;.
  538. * @param[in] cn cos&phi;.
  539. * @return &Delta; = sqrt(1 &minus; <i>k</i><sup>2</sup>
  540. * sin<sup>2</sup>&phi;).
  541. **********************************************************************/
  542. Math::real Delta(real sn, real cn) const {
  543. using std::sqrt;
  544. return sqrt(_k2 < 0 ? 1 - _k2 * sn*sn : _kp2 + _k2 * cn*cn);
  545. }
  546. ///@}
  547. /** \name Symmetric elliptic integrals.
  548. **********************************************************************/
  549. ///@{
  550. /**
  551. * Symmetric integral of the first kind <i>R</i><sub><i>F</i></sub>.
  552. *
  553. * @param[in] x
  554. * @param[in] y
  555. * @param[in] z
  556. * @return <i>R</i><sub><i>F</i></sub>(\e x, \e y, \e z).
  557. *
  558. * <i>R</i><sub><i>F</i></sub> is defined in https://dlmf.nist.gov/19.16.E1
  559. * \f[ R_F(x, y, z) = \frac12
  560. * \int_0^\infty\frac1{\sqrt{(t + x) (t + y) (t + z)}}\, dt \f]
  561. * If one of the arguments is zero, it is more efficient to call the
  562. * two-argument version of this function with the non-zero arguments.
  563. **********************************************************************/
  564. static real RF(real x, real y, real z);
  565. /**
  566. * Complete symmetric integral of the first kind,
  567. * <i>R</i><sub><i>F</i></sub> with one argument zero.
  568. *
  569. * @param[in] x
  570. * @param[in] y
  571. * @return <i>R</i><sub><i>F</i></sub>(\e x, \e y, 0).
  572. **********************************************************************/
  573. static real RF(real x, real y);
  574. /**
  575. * Degenerate symmetric integral of the first kind
  576. * <i>R</i><sub><i>C</i></sub>.
  577. *
  578. * @param[in] x
  579. * @param[in] y
  580. * @return <i>R</i><sub><i>C</i></sub>(\e x, \e y) =
  581. * <i>R</i><sub><i>F</i></sub>(\e x, \e y, \e y).
  582. *
  583. * <i>R</i><sub><i>C</i></sub> is defined in https://dlmf.nist.gov/19.2.E17
  584. * \f[ R_C(x, y) = \frac12
  585. * \int_0^\infty\frac1{\sqrt{t + x}(t + y)}\,dt \f]
  586. **********************************************************************/
  587. static real RC(real x, real y);
  588. /**
  589. * Symmetric integral of the second kind <i>R</i><sub><i>G</i></sub>.
  590. *
  591. * @param[in] x
  592. * @param[in] y
  593. * @param[in] z
  594. * @return <i>R</i><sub><i>G</i></sub>(\e x, \e y, \e z).
  595. *
  596. * <i>R</i><sub><i>G</i></sub> is defined in Carlson, eq 1.5
  597. * \f[ R_G(x, y, z) = \frac14
  598. * \int_0^\infty[(t + x) (t + y) (t + z)]^{-1/2}
  599. * \biggl(
  600. * \frac x{t + x} + \frac y{t + y} + \frac z{t + z}
  601. * \biggr)t\,dt \f]
  602. * See also https://dlmf.nist.gov/19.16.E3.
  603. * If one of the arguments is zero, it is more efficient to call the
  604. * two-argument version of this function with the non-zero arguments.
  605. **********************************************************************/
  606. static real RG(real x, real y, real z);
  607. /**
  608. * Complete symmetric integral of the second kind,
  609. * <i>R</i><sub><i>G</i></sub> with one argument zero.
  610. *
  611. * @param[in] x
  612. * @param[in] y
  613. * @return <i>R</i><sub><i>G</i></sub>(\e x, \e y, 0).
  614. **********************************************************************/
  615. static real RG(real x, real y);
  616. /**
  617. * Symmetric integral of the third kind <i>R</i><sub><i>J</i></sub>.
  618. *
  619. * @param[in] x
  620. * @param[in] y
  621. * @param[in] z
  622. * @param[in] p
  623. * @return <i>R</i><sub><i>J</i></sub>(\e x, \e y, \e z, \e p).
  624. *
  625. * <i>R</i><sub><i>J</i></sub> is defined in https://dlmf.nist.gov/19.16.E2
  626. * \f[ R_J(x, y, z, p) = \frac32
  627. * \int_0^\infty
  628. * [(t + x) (t + y) (t + z)]^{-1/2} (t + p)^{-1}\, dt \f]
  629. **********************************************************************/
  630. static real RJ(real x, real y, real z, real p);
  631. /**
  632. * Degenerate symmetric integral of the third kind
  633. * <i>R</i><sub><i>D</i></sub>.
  634. *
  635. * @param[in] x
  636. * @param[in] y
  637. * @param[in] z
  638. * @return <i>R</i><sub><i>D</i></sub>(\e x, \e y, \e z) =
  639. * <i>R</i><sub><i>J</i></sub>(\e x, \e y, \e z, \e z).
  640. *
  641. * <i>R</i><sub><i>D</i></sub> is defined in https://dlmf.nist.gov/19.16.E5
  642. * \f[ R_D(x, y, z) = \frac32
  643. * \int_0^\infty[(t + x) (t + y)]^{-1/2} (t + z)^{-3/2}\, dt \f]
  644. **********************************************************************/
  645. static real RD(real x, real y, real z);
  646. ///@}
  647. };
  648. } // namespace GeographicLib
  649. #endif // GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP