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