Back to resource page for geodesics.

Addenda for C. F. F. Karney, Algorithms for Geodesics, J. Geodesy 87(1), 43–55 (Jan. 2013);
DOI: 10.1007/s00190-012-0578-z.

  1. Implementations of the geodesic routines are now available in C, Fortran, Java, JavaScript, Python, and Octave/MATLAB (in addition to C++). For details see this link.
  2. Care needs to be taken when solving the inverse problem for a non-equatorial geodesic when both end points on the equator. In Table 5, the quadrants for \(\sigma_1\) and \(\omega_1\) must be determined taking \(\sin\sigma_1\) and \(\sin\omega_1\) to be negative; this is consistent with the ordering \(\phi_1 \le 0\).
  3. The 6th-order series given in the paper provide solutions for the geodesic problem which are accurate to round off for \(\left|f\right| \lt 0.01\). The least accurate of the series is the reverted series for \(\sigma\) in terms of \(\tau\), Eqs. (20) and (21), which is used only in solving the direct problem. The accuracy can be improved by using these equations to give an initial approximation for \(\sigma\) which is following by one step of Newton's method applied to Eq. (7), with \(dI_1(\sigma)/d\sigma = \sqrt{1 + k^2 \sin^2\sigma}\). With this change (which need only be applied for \(\left|f\right| \gt 0.01\)), the 6th-order series are accurate to round-off for \(\left|f\right| \lt 0.02\).
  4. Equation (63) give expansions for the area integral using \(e'^2\) and \(k^2\) as small parameters. Unfortunately the resulting series diverges for \(e' \gt 1\) or \(b/a \lt 1/\sqrt2\). This problem is remedied by expanding instead in terms of \(n\) and \(\epsilon\). Thus Eq. (63) becomes \[ \begin{align} C_{40} &\textstyle= \bigl(\frac{2}{3} - \frac{4}{15} n + \frac{8}{105} n^2 + \frac{4}{315} n^3 + \frac{16}{3465} n^4 + \frac{20}{9009} n^5\bigr)\\ &\textstyle\quad{}- \bigl(\frac{1}{5} - \frac{16}{35} n + \frac{32}{105} n^2 - \frac{16}{385} n^3 - \frac{64}{15015} n^4\bigr) \epsilon\\ &\textstyle\quad{}- \bigl(\frac{2}{105} + \frac{32}{315} n - \frac{1088}{3465} n^2 + \frac{1184}{5005} n^3\bigr) \epsilon^2\\ &\textstyle\quad{}+ \bigl(\frac{11}{315} - \frac{368}{3465} n - \frac{32}{6435} n^2\bigr) \epsilon^3\\ &\textstyle\quad{}+ \bigl(\frac{4}{1155} + \frac{1088}{45045} n\bigr) \epsilon^4 + \frac{97}{15015} \epsilon^5 + \ldots,\\ C_{41} &\textstyle= \bigl(\frac{1}{45} - \frac{16}{315} n + \frac{32}{945} n^2 - \frac{16}{3465} n^3 - \frac{64}{135135} n^4\bigr) \epsilon\\ &\textstyle\quad{}- \bigl(\frac{2}{105} - \frac{64}{945} n + \frac{128}{1485} n^2 - \frac{1984}{45045} n^3\bigr) \epsilon^2\\ &\textstyle\quad{}- \bigl(\frac{1}{105} - \frac{16}{2079} n - \frac{5792}{135135} n^2\bigr) \epsilon^3\\ &\textstyle\quad{}+ \bigl(\frac{4}{1155} - \frac{2944}{135135} n\bigr) \epsilon^4 + \frac{1}{9009} \epsilon^5 + \ldots,\\ C_{42} &\textstyle= \bigl(\frac{4}{525} - \frac{32}{1575} n + \frac{64}{3465} n^2 - \frac{32}{5005} n^3\bigr) \epsilon^2\\ &\textstyle\quad{}- \bigl(\frac{8}{1575} - \frac{128}{5775} n + \frac{256}{6825} n^2\bigr) \epsilon^3\\ &\textstyle\quad{}- \bigl(\frac{8}{1925} - \frac{1856}{225225} n\bigr) \epsilon^4 + \frac{8}{10725} \epsilon^5 + \ldots,\\ C_{43} &\textstyle= \bigl(\frac{8}{2205} - \frac{256}{24255} n + \frac{512}{45045} n^2\bigr) \epsilon^3\\ &\textstyle\quad{}- \bigl(\frac{16}{8085} - \frac{1024}{105105} n\bigr) \epsilon^4 - \frac{136}{63063} \epsilon^5 + \ldots,\\ C_{44} &\textstyle= \bigl(\frac{64}{31185} - \frac{512}{81081} n\bigr) \epsilon^4 - \frac{128}{135135} \epsilon^5 + \ldots,\\ C_{45} &\textstyle= \frac{128}{99099} \epsilon^5 + \ldots. \end{align} \]
  5. In some applications, it is necessary to keep track of how many times a geodesic encircles the earth, i.e., to determine the value of \(\lambda_{12}\) without reducing it to some canonical range. The geodesic classes offer this option through the Geodesic::LONG_UNROLL mask bit. In the case of the inverse problem, we are interested in the shortest geodesic and thus \(\lambda_{12}\in[-\pi,\pi]\) (the geodesic between points on opposite meridians is taken to be east- or west-going depending on whether \(\lambda_2 - \lambda_1\) is positive or negative). When solving the direct geodesic problem, \(\sigma_{12}\) is found in terms of the length of the geodesic, \(\omega\) and \(\sigma\) pass from one quadrant to the next at the same time, and they are related by \(\tan\omega = \sin\alpha_0 \tan\sigma\). The "unrolled" value of \(\lambda_{12}\) is then given by \[ \begin{align} \omega_{12} &= E\biggl[\sigma_{12} - \biggl(\tan^{-1}\frac{\sin\sigma_2}{\cos\sigma_2} - \tan^{-1}\frac{\sin\sigma_1}{\cos\sigma_1}\biggr)\\ &\quad\qquad{}+ \biggl(\tan^{-1}\frac{E\sin\omega_2}{\cos\omega_2} - \tan^{-1}\frac{E\sin\omega_1}{\cos\omega_1}\biggr)\biggr],\\ \lambda_{12} &= \omega_{12} - f\sin\alpha_0 \bigl(I_3(\sigma_2)-I_3(\sigma_1)\bigr), \end{align} \] where \(E=\pm1\) is the sign of \(\sin\alpha_0\) or \(+1\) if \(\sin\alpha_0 = 0\).
  6. The starting guesses for Newton's method given in Sec. 5 are not very good for highly eccentric ellipsoids. It's possible to modify Newton's method so that it converges even for poor initial guesses. The goal is to find the root of \[ f(\alpha_1) \equiv \lambda_{12}(\alpha_1) - \lambda_{12} = 0, \] where \(\lambda_{12}(\alpha_1)\) is the solution of the hybrid problem. There is exactly one root to this equation in the interval \(\alpha_1 \in (0,\pi)\) and its derivative \(f'(\alpha_1)\) is positive at the root. During the course of the iteration, a range \((\alpha_{1a}, \alpha_{1b})\) is maintained which brackets the root and with each evaluation of \(f(\alpha_1)\) the range is shrunk, if possible. Newton's method is restarted whenever the derivative of \(f(\alpha_1)\) is negative (because the new value of \(\alpha_1\) is then further from the solution) or if the new estimate of \(\alpha_1\) lies outside \((0,\pi)\); in this case, the new starting guess is taken to be \((\alpha_{1a} + \alpha_{1b}) / 2\).
  7. The series for \(A_2\) converges slightly faster it is multiplied by \(1+\epsilon\), instead of divided by \(1-\epsilon\). The resulting series is \[ \textstyle A_2 = (1 + \epsilon)^{-1} \bigl( 1 - \frac{3}{4}\epsilon^2 - \frac{7}{64}\epsilon^4 - \frac{11}{256}\epsilon^6 + \ldots \bigr). \]
  8. In order to obtain accurate solutions for ellipsoids of arbitrary eccentricity, it is necessary to replace the series expansions for the integrals (which are valid only if \(f\) is small) with direct evaluation in terms of elliptic integrals (which are valid for all \(f\)). The key relations used are \[ \begin{align} \frac sb &= E(\sigma, ik), \\ \lambda &= \chi - \frac{e'^2}{\sqrt{1+e'^2}}\sin\alpha_0 H(\sigma, -e'^2, ik), \\ J(\sigma) &= k^2 D(\sigma, ik), \end{align} \] where \[ \begin{align} \tan\chi &= \sqrt{\frac{1+e'^2}{1+k^2\sin^2\sigma}}\tan\omega, \\ H(\phi, \alpha^2, k) &= \frac1{\alpha^2} F(\phi, k) + \biggl(1 - \frac1{\alpha^2}\biggr) \Pi(\phi, \alpha^2, k), \end{align} \] and \(F(\phi, k)\), \(E(\phi, k)\), \(D(\phi, k)\), and \(\Pi(\phi, \alpha^2, k)\), are incomplete elliptic integrals (see https://dlmf.nist.gov/19.2.ii).
  9. The integral \(I_4(\sigma)\), Eq. (61), appearing in the expression for the area Eq. (59), does not appear to be an elliptic integral. When the formulation of geodesics in terms elliptic integrals was first provided in GeographicLib, a 30th order series for \(I_4(\sigma)\) was used, expanded in terms of \(n\) and \(\epsilon\) as in item 4 above. This provided full accuracy in double precision for \(\frac12 \le b/a \le 2\). Here we detail how to obtain accuracy over a wider range. We start by writing Eq. (61) as \[ \begin{align} I_4 &= \int_{\pi/2}^\sigma q(\sigma')\,d\sigma',\\ q(\sigma) &= - \Delta t(e'^2, k^2\sin^2\sigma) \frac{\sin\sigma}2,\\ \Delta t(x,y) &= \frac{t(x)-t(y)}{x-y},\\ t(x>0) &= x + \biggl( \sqrt{1 + x} \frac{\sinh^{-1}\sqrt x}{\sqrt x} - 1 \biggr),\\ t(x<0) &= x + \biggl( \sqrt{1 + x} \frac{\sin^{-1}\sqrt{-x}}{\sqrt{-x}} - 1 \biggr),\\ t(0) &=0.\\ \end{align} \] The notation \(\Delta t(x,y)\) is used for the divided difference of \(t(x)\) and, because \(t(x)\) involves just elementary functions, there's a systematic way to put it in a form that avoids subtracting nearly equal quantities as explained by Kahan and Fateman (1999). From the symmetries of the sine function, it's clear that we can expand \(q(\sigma)\) in a Fourier series \[ q(\sigma) = \sum_{l=0}^\infty Q_l \sin\bigl((2l+1)\sigma\bigr), \] so that we have \[ \begin{align} I_4(\sigma)&= \sum_{l=0}^\infty C_{4l} \cos\bigl((2l+1)\sigma\bigr),\\ C_{4l} &= -\frac{Q_l}{2l+1};\\ \end{align} \] this is Eq. (62) in the paper. Instead of determining \(Q_l\) using a Taylor expansion (as in the paper and in item 4), we use the discrete sine transform and compute \[ Q_l = \frac2N \sum_{j=0}^{N} p_j q(\sigma_j) \sin\bigl((2l+1)\sigma_j\bigr) \] for \(0\le l\lt N\), where \(\sigma_j = j\pi/(2N)\) and \(p_j = \frac12\) for \(j = 0\) or \(j = N\) and \(1\) otherwise. Using the fast Fourier transform (FFT), \(Q_l\) may be computed efficiently; using the FFT also minimizes round-off errors in computing the sum. In addition, this yields an excellent approximation to the true value of \(Q_l\): the number of correct digits approximately doubles as \(N\) is doubled. This is a consequence of the fact that the trapezium rule (or, equivalently, the rectangle rule) converges faster than any power of \(N\) when computing an integral over a full period of a smooth periodic function. \(N\) is adjusted to give full accuracy for \(0.01 \le b/a \le 100\).
  10. Google Books does not consistently provide access to the full text. If you encounter this situation, you can download the pdf files listed here:
Items 3–9 represent changes since the publication of the paper. Changes 3–7 have been implemented in the GeographicLib classes Geodesic and GeodesicLine in GeographicLib versions 1.27, 1.26, 1.39 (fixed in 1.43), 1.25, and 1.44, respectively. Change 8 (the evaluation of the integrals in terms of elliptic integrals) is implemented in the GeographicLib classes GeodesicExact and GeodesicLineExact which were added to GeographicLib 1.25. Change 9 (the accurate computation of geodesic areas) was added to these classes in GeographicLib 2.1. For geodetic applications, Geodesic and GeodesicLine are preferred, because they are about 2–3 times faster and the round-off errors are about 2–3 times smaller.

Some notes on geodesics on a triaxial ellipsoid are given in Geodesics on a triaxial ellipsoid. This examines the solution to this problem found by Jacobi in 1839.

Errata for C. F. F. Karney, Algorithms for Geodesics, arXiv:1109.4448v2 (2012-03-28).

These errata apply to the preprint only:

Errata for C. F. F. Karney, Geodesics on an ellipsoid of revolution arXiv:1102.1215v1 (2011-02-07).

Addenda:

Errata:

Back to resource page for geodesics.
Charles Karney <karney@alum.mit.edu> (2022-06-08)

GeographicLib home