1 Introduction

In the paper “Accurate computation of gravitational field of a tesseroid” (Fukushima 2018), an accurate method with conditional split, double exponential quadrature rule, and numerical differentiation has been presented for calculating the gravitational potential, gravitational acceleration vector, and gravity gradient tensor of a tesseroid, whereas the expressions for the \(\varGamma _{\varPhi \varLambda }\) and \(\varGamma _{\varLambda H}\) components of the gravity gradient tensor in Fukushima (2018) contain formal errors and need to be corrected. Meanwhile, some typos of the negative sign need to be corrected. The two FORTRAN codes xtess.txt and xqtess.txt provided by Fukushima (2018) to calculate the gravitational acceleration vector and gravity gradient tensor of a tesseroid need to be revised in double and quadruple precision.

This study presents the corrections for some formulas and two FORTRAN codes in Fukushima (2018). Furthermore, a numerical experiment is performed to reveal the consequences of the modified formulas and FORTRAN codes.

This study is organized as follows. Sections 2 and 3 present the corrections to some formulas and FORTRAN codes in Fukushima (2018), respectively. The corrected formulas and FORTRAN codes are numerically investigated against analytical solutions for a spherical shell in Sect. 4. Section 5 offers the revised FORTRAN codes xtess.f90 and xqtess.f90. Conclusions and consequences for Fukushima (2018) are summarized in Sect. 6.

2 Corrections to some formulas in Fukushima (2018)

Regarding the expressions of the diagonal component \((\partial ^{2} V/ \partial H^{2})_{\varPhi , \varLambda }\) of the second-order partial derivatives in Fukushima (2018), the \(+\frac{(\varDelta _{2} H)^{2}}{12}\left( \frac{\partial ^{4} V}{\partial H^{4}}\right) \) term in Eq. (25) should be replaced by \(-\frac{(\varDelta _{2} H)^{2}}{12}\left( \frac{\partial ^{4} V}{\partial H^{4}}\right) \), where the sign is wrong, and it is a typo. Equation (25) should be changed to:

$$\begin{aligned}{} & {} \left( \frac{\partial ^{2} V}{\partial H^{2}}\right) _{\varPhi , \varLambda }\nonumber \\{} & {} \quad =\frac{\begin{matrix}V(\varPhi , \varLambda , H+\varDelta _{2} H) -2 V(\varPhi , \varLambda , H)\\ +V(\varPhi , \varLambda , H-\varDelta _{2} H)\end{matrix}}{(\varDelta _{2} H)^{2}} \nonumber \\{} & {} \qquad -\frac{(\varDelta _{2} H)^{2}}{12}\left( \frac{\partial ^{4} V}{\partial H^{4}}\right) -\frac{(\varDelta _{2} H)^{4}}{360}\left( \frac{\partial ^{6} V}{\partial H^{6}}\right) -\cdots \end{aligned}$$
(1)

Similarly, for the expressions of the non-diagonal component \([\partial ^{2} V/ (\partial \varPhi \partial \varLambda )]_{H}\) of the second-order partial derivatives in Eq. (26) of Fukushima (2018), the \(+\frac{(\varDelta _{2} \varPhi ) (\varDelta _{2} \varLambda ) }{36}\left( \frac{\partial ^{4} V}{\partial \varPhi ^{2} \partial \varLambda ^{2}}\right) \) term is wrong. It should be replaced by the \(-\frac{(\varDelta _{2} \varPhi )^2(\varDelta _{2} \varLambda )^2}{36} \left( \frac{\partial ^{6} V}{\partial \varPhi ^{3} \partial \varLambda ^{3}}\right) \), and it is a typo. Meanwhile, two terms \(-\frac{(\varDelta _{2} \varPhi )^2}{6} \left( \frac{\partial ^{4} V}{\partial \varPhi ^{3} \partial \varLambda }\right) \) and \(-\frac{(\varDelta _{2} \varLambda )^2}{6}\left( \frac{\partial ^{4} V}{\partial \varPhi \partial \varLambda ^{3}}\right) \) are missing. Equation (26) should be changed to:

$$\begin{aligned} \begin{aligned}&\left( \frac{\partial ^{2} V}{\partial \varPhi \partial \varLambda }\right) _{H} =\big [V(\varPhi +\varDelta _{2} \varPhi , \varLambda +\varDelta _{2} \varLambda , H)\\&\quad -V(\varPhi +\varDelta _{2} \varPhi , \varLambda -\varDelta _{2} \varLambda , H) \\&\quad -V(\varPhi -\varDelta _{2} \varPhi , \varLambda +\varDelta _{2} \varLambda , H) \\&\quad +V(\varPhi -\varDelta _{2} \varPhi , \varLambda -\varDelta _{2} \varLambda , H)\big ] /\big [4(\varDelta _{2} \varPhi )(\varDelta _{2} \varLambda )\big ] \\&\quad -\frac{(\varDelta _{2} \varPhi )^2}{6}\left( \frac{\partial ^{4} V}{\partial \varPhi ^{3} \partial \varLambda }\right) -\frac{(\varDelta _{2} \varLambda )^2}{6}\left( \frac{\partial ^{4} V}{\partial \varPhi \partial \varLambda ^{3}}\right) \\&\quad -\frac{(\varDelta _{2} \varPhi )^2(\varDelta _{2} \varLambda )^2}{36} \left( \frac{\partial ^{6} V}{\partial \varPhi ^{3} \partial \varLambda ^{3}}\right) -\cdots \end{aligned} \end{aligned}$$
(2)

Regarding the expressions for the \(\varGamma _{\varPhi \varLambda }\) component of the gravity gradient tensor in Eq. (31) of Fukushima (2018), the \(+\frac{g_{\varPhi }\tan \varPhi }{R^2 \cos \varPhi }\) term is wrong and should be corrected to the \(+\frac{\tan \varPhi }{R} g_{\varLambda }\) term. Equation (31) should be changed to:

$$\begin{aligned} \varGamma _{\varPhi \varLambda }=\varGamma _{\varLambda \varPhi }=\frac{1}{R^2 \cos \varPhi }\bigg (\frac{\partial ^{2} V}{\partial \varPhi \partial \varLambda }\bigg )_{H} + \frac{\tan \varPhi }{R} g_{\varLambda } \end{aligned}$$
(3)

Similarly, for the formula of the \(\varGamma _{\varLambda H}\) component of the gravity gradient tensor in Fukushima (2018), the \(-\frac{g_{H}}{R^2 \cos \varPhi }\) term in Eq. (33) is wrong and should be changed to the \(- \frac{g_{\varLambda }}{R}\) term. Then, Eq. (33) should be changed to:

$$\begin{aligned} \varGamma _{\varLambda H}=\varGamma _{H \varLambda }=\frac{1}{R \cos \varPhi } \bigg (\frac{\partial ^{2} V}{\partial \varLambda \partial H}\bigg )_{\varPhi } - \frac{g_{\varLambda }}{R} \end{aligned}$$
(4)

where the expressions in Eqs. (31) and (33) belong to the incorrect derivation. The correct derivation of the formulas in Eqs. (3) and (4) is provided in “Appendix 1”.

In the formula of the radial–radial component of the gravity gradient tensor \(\varGamma _{HH}\) of the spherical shell when the computation point is located inside the spherical shell (\(H_B<H<H_T\)) in Fukushima (2018), the \((4 \pi G \rho / 3)(1+2 R_{B}^{3} / R^{3})\) term in Eq. (48) should be replaced by \(-(4 \pi G \rho / 3)(1+2 R_{B}^{3} / R^{3})\), i.e. the negative sign ‘−’ should be added, and it is a typo. Then, Eq. (48) should be changed to (Lin et al. 2020, Eq. (15c)):

$$\begin{aligned}{} & {} \varGamma _{H H, \textrm{analytical}}\nonumber \\{} & {} \quad ={\left\{ \begin{array}{ll} 0&{} \left( H<H_{B}\right) \\ -(4 \pi G \rho / 3)\left( 1+2 R_{B}^{3} / R^{3}\right) &{} \left( H_{B}<H<H_{T}\right) \\ 2 G M / R^{3} &{} \left( H_{T}<H\right) \end{array}\right. } \end{aligned}$$
(5)

Regarding the expression for the relative error of the second-order central difference formula in Eq. (77), the \(-\bigg (\frac{f^{(4)}(t)}{12 f^{\prime \prime }(t)}\bigg )(\varDelta t)^{2}\) term should be changed to \(\bigg (\frac{f^{(4)}(t)}{12 f^{\prime \prime }(t)}\bigg )(\varDelta t)^{2}\), i.e. the negative sign ‘−’ should be removed, and it is a typo. Then, Eq. (77) should be changed to:

$$\begin{aligned} \delta h_{0}(t) \equiv \frac{h_{0}(t)-f^{\prime \prime }(t)}{f^{\prime \prime }(t)} \approx \bigg (\frac{f^{(4)}(t)}{12 f^{\prime \prime }(t)}\bigg )(\varDelta t)^{2} \end{aligned}$$
(6)

3 Corrections to FORTRAN codes of Fukushima (2018)

The two FORTRAN subroutines qgtess and qggtess to calculate the gravitational acceleration vector (\(g_{\varPhi }\) and \(g_{\varLambda }\)) and gravity gradient tensor (\(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), \(\varGamma _{\varLambda H}\), and \(\varGamma _{H H}\)) of the tesseroid in the code xqtess.txt in Tables 7–11 of the electronic supplementary material of Fukushima (2018) need to be revised in quadruple precision. The corrected subroutines qgtess and qggtess are presented in Tables 7–11 of this paper’s electronic supplementary material, where the revised parts are in bold fonts. The same parts in the code xtess.txt should be revised in double precision. Note that the FORTRAN function vtess is revised to qvtess in the subroutine qggtess, which is not in bold font. Based on the revised contents in Tables 7–11 of this paper’s electronic supplementary material, these revised codes will affect the evaluation of these components \(g_{\varPhi }\), \(g_{\varLambda }\), \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), \(\varGamma _{\varLambda H}\), and \(\varGamma _{H H}\), where the calculation of the \(g_{H}\) will not be affected.

4 Numerical investigations

In this section, a simple numerical experiment is performed to reveal the magnitude of the error one makes when using the original codes of Fukushima (2018). The numerical experiment is carried out in a double-precision environment considering the computational efficiency, because quadruple precision generally requires more time than double precision. For instance, the ratio of quadruple precision to double precision is about 50.463/0.089 \(\approx \) 567 per computation point with a single tesseroid on a desktop computer with an Intel i5-10400 CPU at 2.9 GHz and single-threaded operation in Sect. 5. Specifically, the values of the gravitational acceleration vector (\(g_{\varPhi }\) and \(g_{\varLambda }\)) and gravity gradient tensor (\(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), \(\varGamma _{\varLambda H}\), and \(\varGamma _{H H}\)) of a spherical shell are served as the analytical reference values for the calculated values of the discretized tesseroids forming the whole spherical shell with the original codes provided by Fukushima (2018) and revised codes.

Regarding the gravitational acceleration vector (\(g_{\varPhi }\) and \(g_{\varLambda }\)) and gravity gradient tensor (\(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\) and \(\varGamma _{\varLambda H}\)) of a spherical shell, their reference values are equal to zero. The three components of the gravity gradient tensor (\(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varLambda \varLambda }\), and \(\varGamma _{H H}\)) satisfy Laplace’s equation outside the spherical shell and Poisson’s equation inside the spherical shell as MacMillan (1930), Kellogg (1967), Blakely (1995):

$$\begin{aligned}{} & {} \varGamma _{\varPhi \varPhi , \textrm{analytical}} + \varGamma _{\varLambda \varLambda , \textrm{analytical}} + \varGamma _{H H, \textrm{analytical}} \nonumber \\{} & {} \quad = 0 \ \ (H< H_B\ \ or \ \ H_T < H )\end{aligned}$$
(7)
$$\begin{aligned}{} & {} \varGamma _{\varPhi \varPhi , \textrm{analytical}} + \varGamma _{\varLambda \varLambda , \textrm{analytical}} + \varGamma _{H H, \textrm{analytical}} \nonumber \\{} & {} \quad = -4 \pi G \rho \ \ (H_B< H < H_T ) \end{aligned}$$
(8)

When the computation point is located inside or outside the spherical shell, \(\varGamma _{\varPhi \varPhi , \textrm{analytical}}\) = \(\varGamma _{\varLambda \varLambda , \textrm{analytical}}\) (Makhloof and Ilk 2008; Wild-Pfeiffer 2008). Substituting Eq. (5) into Eqs. (7) and (8) yields:

$$\begin{aligned}{} & {} \varGamma _{\varPhi \varPhi , \textrm{analytical}}=\varGamma _{\varLambda \varLambda ,\textrm{analytical}}\nonumber \\{} & {} \quad ={\left\{ \begin{array}{ll} 0&{} (H<H_{B})\\ (4 \pi G \rho / 3)(R_{B}^{3} / R^{3}-1) &{} (H_{B}<H<H_{T})\\ - G M / R^{3} &{} (H_{T}<H) \end{array}\right. } \end{aligned}$$
(9)
Fig. 1
figure 1

a Illustration of the absolute errors and relative errors in \(\log _{10}\) scale of the \(\delta \varGamma _{\varPhi \varPhi }\) with blue circle points, \(\delta \varGamma _{\varLambda \varLambda }\) with red star points, and \(\delta \varGamma _{H H}\) with green square points with the influence of the height H from \(-100\) to \(+100\) km with an interval of 1 km in double precision, where the absolute errors are in the range of [\(-100\) km, \(-40\) km] and the relative errors are in the range of [\(-40\) km, \(+100\) km]; b the absolute errors in \(\log _{10}\) scale of the \(\delta g_{\varPhi }\) with blue circle points, \(\delta g_{\varLambda }\) with red star points, \(\delta \varGamma _{\varPhi \varLambda }\) with purple pentagon points, \(\delta \varGamma _{\varPhi H}\) with black inverted triangle points, and \(\delta \varGamma _{\varLambda H}\) with green square points. The two solid vertical lines at \(H_B=-40\) km and \(H_T=+10\) km mean the bottom and top boundaries of the spherical shell. These values are calculated using the revised codes

Fig. 2
figure 2

Using the original codes provided by Fukushima (2018), other parameters are the same as in Fig. 1

The detailed numerical settings are similar to those in Sect. 3.1 of Fukushima (2018). \(G\rho =1\) and the radius of the reference sphere is \(R_0=6380\) km. The top and bottom heights of the spherical shell are \(H_T=+10\) km and \(H_B=-40\) km. The spherical latitude and longitude of the computation point are \(\varPhi =0^{\circ }\) and \(\varLambda =180^{\circ }\). The height of the computation point varies from \(-100\) to \(+100\) km with an interval of 1 km. The error tolerance to calculate the gravitational potential is set as \(\delta =10^{-16}\) in double precision. The computation points located on the surfaces of the spherical shell, i.e. \(H=H_B\) or \(H=H_T\), are shifted slightly inside the spherical shell as \(H=(1+\epsilon _D)H_B\) or \(H=(1-\epsilon _D)H_T\), where \(\epsilon _D = 2^{-53} \approx 1.11 \times 10^{-16}\) is the double-precision machine epsilon (see Table 1 of Fukushima (2012)).

For other components \(g_{\varPhi }\), \(g_{\varLambda }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), and \(\varGamma _{\varLambda H}\), the absolute errors in \(\log _{10}\) scale are presented as:

$$\begin{aligned} \delta F = \log _{10}\big | \sum F\big | \end{aligned}$$
(10)

where F means the \(g_{\varPhi }\), \(g_{\varLambda }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), or \(\varGamma _{\varLambda H}\). When the computation point is located below (\(H<H_{B}\)) the spherical shell for the components \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varLambda \varLambda }\), and \(\varGamma _{H H}\), the absolute errors in \(\log _{10}\) scale are applied.

Regarding the components \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varLambda \varLambda }\), and \(\varGamma _{H H}\) when the computation point is located inside (\(H_{B}<H<H_{T}\)) and above (\(H_{T}<H\)) the spherical shell, their relative errors in \(\log _{10}\) scale are presented as:

$$\begin{aligned} \delta F = \log _{10}\big | \sum F / F_{\textrm{analytical}} - 1 \big | \end{aligned}$$
(11)

where \(F = \varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varLambda \varLambda }\), or \(\varGamma _{H H}\). \(\sum \) means the sum of the calculated values of the discretized tesseroids forming the whole spherical shell. \(F_{\textrm{analytical}}\) represents the analytical reference values of the spherical shell.

The absolute errors and relative errors in \(\log _{10}\) scale of the components \(g_{\varPhi }\), \(g_{\varLambda }\), \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), \(\varGamma _{\varLambda H}\), and \(\varGamma _{H H}\) are shown in Fig. 1 using the revised FORTRAN codes and in Fig. 2 using the original FORTRAN codes provided by Fukushima (2018). The factors and units of the absolute errors of the gravitational acceleration vector (\(\delta g_{\varPhi }\) and \(\delta g_{\varLambda }\)) and gravity gradient tensor (\(\delta \varGamma _{\varPhi \varPhi }\), \(\delta \varGamma _{\varPhi \varLambda }\), \(\delta \varGamma _{\varPhi H}\), \(\delta \varGamma _{\varLambda \varLambda }\), \(\delta \varGamma _{\varLambda H}\), and \(\delta \varGamma _{H H}\)) are \(\mathrm {m^{-1}}\) and \(\mathrm {m^{-2}}\), respectively. When evaluating the practical results of the gravitational acceleration vector and gravity gradient tensor using the original or revised FORTRAN codes, the term \(G \rho R_0^2\) (i.e. the units of G, \(\rho \), and \(R_0\) are \(\mathrm {m^3\ kg^{-1}\ s^{-2}}\), \(\mathrm {kg\ m^{-3}}\), and \(\textrm{m}\)) should be multiplied.

In Fig. 1a, the ranges of the absolute errors in \(\log _{10}\) scale of \(\delta \varGamma _{\varPhi \varPhi }\), \(\delta \varGamma _{\varLambda \varLambda }\), and \(\delta \varGamma _{H H}\) are about [\(-18\), \(-14\)] in the interval of [\(-100\) km, \(-40\) km) and the relative errors in \(\log _{10}\) scale are about [\(-10\), \(-6\)] in the interval of [\(-40\) km, \(+100\) km]. In any case, Fig. 1a approximately confirms the following equation:

$$\begin{aligned} |\delta F| \approx \log _{10} \left( \sqrt{\delta }\right) = \log _{10} \left( \sqrt{10^{-16}}\right) = -8 \end{aligned}$$
(12)

excepting for the values of the \(\delta \varGamma _{\varPhi \varPhi }\), \(\delta \varGamma _{\varLambda \varLambda }\), and \(\delta \varGamma _{H H}\) at \(H_B=-40\) km and \(H_T=+10\) km, i.e. the bottom and top boundaries of the spherical shell. In Eq. (12), \(\delta F\) = \(\delta \varGamma _{\varPhi \varPhi }\), \(\delta \varGamma _{\varLambda \varLambda }\), or \(\delta \varGamma _{H H}\). The reason for this behavior in Eq. (12) is the error propagation when deriving higher-order gravitational field components by numerical differentiation of the gravitational potential. Specifically, the relative accuracy of the partially differentiated quantities is \(\sqrt{\delta }\) for the gravity gradient tensor (Fukushima 2018), where \(\delta \) is the error tolerance to compute the gravitational potential.

In Fig. 1b, the absolute errors in \(\log _{10}\) scale of the \(\delta g_{\varPhi }\), \(\delta g_{\varLambda }\), \(\delta \varGamma _{\varPhi \varLambda }\), \(\delta \varGamma _{\varPhi H}\), and \(\delta \varGamma _{\varLambda H}\) are mostly less than or equal to \(10^{-16}\), which are the random errors in double precision. Specifically, the ranges of the absolute errors in \(\log _{10}\) scale are about [\(-23\), \(-21\)] for the \(\delta g_{\varPhi }\), [\(-21\), \(-16\)] for the \(\delta g_{\varLambda }\), [\(-27\), \(-25\)] for the \(\delta \varGamma _{\varPhi \varLambda }\), [\(-27\), \(-25\)] for the \(\delta \varGamma _{\varPhi H}\), and [\(-22\), \(-16\)] for the \(\delta \varGamma _{\varLambda H}\).

By comparing the numerical results of Figs. 1a and 2a, it can be found that the absolute errors and relative errors in \(\log _{10}\) scale of the \(\delta \varGamma _{H H}\) are almost the same with each other. In Fig. 2a, the ranges of the absolute errors in \(\log _{10}\) scale of the \(\delta \varGamma _{\varPhi \varPhi }\) and \(\delta \varGamma _{\varLambda \varLambda }\) are about [\(-21\), \(-18\)] in the range of [\(-100\) km, \(-40\) km) and their relative errors in \(\log _{10}\) scale are about [\(-14\), \(-8\)] in the range of [\(-40\) km, \(+100\) km]. In Fig. 2b, the absolute errors in \(\log _{10}\) scale of the \(\delta \varGamma _{\varLambda H}\) are in the ranges of [\(-25\),\(-22\)] in the interval of [\(-100\) km, \(-40\) km) and [\(-14\), \(-12\)] in the interval of [\(-40\) km, \(+100\) km]. Regarding the absolute errors in \(\log _{10}\) scale of the \(\delta g_{\varPhi }\), \(\delta g_{\varLambda }\), \(\delta \varGamma _{\varPhi \varLambda }\), and \(\delta \varGamma _{\varPhi H}\), there are no numerical values shown in Fig. 2b, excepting that the absolute errors of the \(\delta \varGamma _{\varPhi H}\) are about \(-16\) at \(H_B=-40\) km and \(H_T=+10\) km.

Finally, numerical results reveal that the evaluation of the absolute errors and relative errors in \(\log _{10}\) scale of the \(\delta \varGamma _{H H}\) does not be affected by using the original codes, because one of the conditional splits (i.e. if \(\varPhi _{\textrm{S}} \le \varPhi \le \varPhi _{\textrm{N}}\) and \(\varLambda _{\textrm{W}} \le \varLambda \le \varLambda _{\textrm{E}}\) and either \(H_{\textrm{B}} - \varDelta _2 H< H < H_{\textrm{B}}\) or \(H_{\textrm{T}} - \varDelta _2 H< H < H_{\textrm{T}}\)) in the revised code of the \(\varGamma _{H H}\) is not triggered. When using the original codes for the \(\delta \varGamma _{\varPhi \varPhi }\) and \(\delta \varGamma _{\varLambda \varLambda }\), their absolute and relative errors in \(\log _{10}\) scale were incorrectly improved by about 2–4 orders of magnitude. Regarding the \(\delta \varGamma _{\varLambda H}\), the precision of its absolute errors in \(\log _{10}\) scale by using the original codes is erroneously improved by approximately 3–6 orders of magnitude in the range of [\(-100\) km, \(-40\) km) and reduced by about 4–8 orders of magnitude in the range of [\(-40\) km, \(+100\) km]. The precision of the absolute errors in \(\log _{10}\) scale of the \(\delta \varGamma _{\varPhi H}\) is reduced by about 9–11 orders of magnitude by using the original codes. Notably, the absolute errors in \(\log _{10}\) scale of the \(\delta g_{\varPhi }\), \(\delta g_{\varLambda }\), \(\delta \varGamma _{\varPhi \varLambda }\) and the majority of \(\delta \varGamma _{\varPhi H}\) are not presented in Fig. 2b because of no numerical values. This is due to the fact that these values equal negative infinity. In other words, the calculated values of the \(\delta g_{\varPhi }\), \(\delta g_{\varLambda }\), \(\delta \varGamma _{\varPhi \varLambda }\) and the most of \(\delta \varGamma _{\varPhi H}\) when using the original codes in Fukushima (2018) are equal to zero and their absolute errors in \(\log _{10}\) scale are \(\log _{10}0 = - \infty \).

5 Computer programs of the xtess.f90 and xqtess.f90

To make better use of the revised FORTRAN codes, the xtess.f90 and xqtess.f90 are presented at the GitHub website https://github.com/xiaoledeng/xtess-xqtess. The total CPU time of the xtess.f90 and xqtess.f90 to calculate all 10 components of the V, \(g_{\varPhi }\), \(g_{\varLambda }\), \(g_{H}\), \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), \(\varGamma _{\varLambda H}\), and \(\varGamma _{H H}\) is 3.568/40 s \(\approx \) 0.089 s per computation point when \(\delta = 10^{-16}\) in double precision and 50.463 s per computation point when \(\delta = 10^{-33}\) in quadrature precision with a single tesseroid mass body. These values are obtained on a desktop computer with an Intel i5-10400 CPU at 2.9 GHz using the single-threaded operation.

When applying the gravitational potential, gravitational acceleration vector, and gravity gradient tensor using these FORTRAN codes in the practical applications, the term \(G \rho R_0^2\) should be multiplied with the output numerical values to obtain the units \({\textrm{m}}^{2}\,{\textrm{s}}^{-2}\) for the gravitational potential, \(\hbox {m s}^{-2}\) for the gravitational acceleration vector, and \({\textrm{s}}^{-2}\) for the gravity gradient tensor, where the units of G, \(\rho \), and \(R_0\) are \(\hbox {m}^3\,\hbox {kg}^{-1}\,\hbox {s}^{-2}\), \(\hbox {kg m}^{-3}\), and \(\textrm{m}\), respectively.

6 Conclusions and consequences for Fukushima (2018)

Theoretically, the revised parts in the original codes xtess.txt and xqtess.txt have impacts on the calculation of these components of the gravitational acceleration vector (i.e. \(g_{\varPhi }\) and \(g_{\varLambda }\)) and gravity gradient tensor (i.e. \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), \(\varGamma _{\varLambda H}\), and \(\varGamma _{H H}\)). Regarding the \(\varGamma _{H H}\), the influence on the calculation results only occurs when one of the conditional splits (i.e. if \(\varPhi _{\textrm{S}} \le \varPhi \le \varPhi _{\textrm{N}}\) and \(\varLambda _{\textrm{W}} \le \varLambda \le \varLambda _{\textrm{E}}\) and either \(H_{\textrm{B}} - \varDelta _2 H< H < H_{\textrm{B}}\) or \(H_{\textrm{T}} - \varDelta _2 H< H < H_{\textrm{T}}\)) is performed. The evaluation of the gravitational potential V and the radial component of the gravitational acceleration vector \(g_H\) in the original codes xtess.txt and xqtess.txt will not be affected.

Numerical results reveal that the absolute errors obtained by using the corrected codes are at a lower precision level by 2–4 orders of magnitude for the \(\delta \varGamma _{\varPhi \varPhi }\) and \(\delta \varGamma _{\varLambda \varLambda }\) components of the gravity gradient tensor. Regarding the \(\delta \varGamma _{\varLambda H}\) component of the gravity gradient tensor, the precision level of the absolute errors by using the corrected codes is reduced by 3–6 orders of magnitude when the computation point is located below the spherical shell and improved by 4–8 orders of magnitude when the computation point is located in and above the spherical shell. When the computation point is located on the bottom and top boundaries of the spherical shell, the precision level of the absolute errors for the \(\delta \varGamma _{\varPhi H}\) component of the gravity gradient tensor by using the corrected codes is improved by 9–11 orders of magnitude. If using the original codes for the \(g_{\varPhi }\) and \(g_{\varLambda }\) components of the gravitational acceleration vector and the \(\delta \varGamma _{\varPhi \varLambda }\) and most of the \(\delta \varGamma _{\varPhi H}\) components of the gravity gradient tensor, their calculated values of the tesseroids are equal to zero. When using the revised codes for these components, their absolute errors in \(\log _{10}\) scale are in ranges of about [\(-23\), \(-21\)] for the \(\delta g_{\varPhi }\), [\(-21\), \(-16\)] for the \(\delta g_{\varLambda }\), [\(-27\), \(-25\)] for the \(\delta \varGamma _{\varPhi \varLambda }\), and [\(-27\), \(-25\)] for the \(\delta \varGamma _{\varPhi H}\).

The previous study that quoted the original FORTRAN codes provided by Fukushima (2018) to calculate the gravitational field of a tesseroid should be carefully considered based on the above potential impacts. For example, Lin et al. (2020) calculated the gravitational potential V, radial component \(V_{z}\) of the gravitational acceleration vector, and radial–radial component \(V_{zz}\) of the gravity gradient tensor in Sect. 3.7 based on the use of the original FORTRAN codes in Fukushima (2018). Fortunately, these three components V, \(V_{z}\), and \(V_{zz}\) are not affected, although the FORTRAN code of the \(V_{zz}\) needs to be modified, whereas in Sect. 4.2 gravitational acceleration vector of tesseroid, Sect. 4.3 gravity gradient tensor of tesseroid, Sect. 4.4 polar tesseroid, and Sect. 4.5 polar cap slab of the electronic supplement material of Fukushima (2018), the evaluation of the gravity field quantities (e.g. the total gravitational acceleration \(g=\sqrt{g_{\varPhi }^{2}+g_{\varLambda }^{2}+g_{H}^{2}}\), magnitude of the vector representing the deflection of the vertical referred to the normal vector of the reference sphere \(\theta =\tan ^{-1}\left( \frac{\sqrt{g_{\varPhi }^{2}+g_{\varLambda }^{2}}}{g_{H}}\right) \), azimuthal angle of the vector representing the deflection of the vertical \(A=\tan ^{-1} (g_{\varPhi }/g_{\varLambda })\), \(\varDelta A =\tan ^{-1}\left( \frac{\left( \varPhi _{\textrm{C}}-\varPhi \right) g_{\varLambda }-\left( \varLambda _{\textrm{C}}-\varLambda \right) g_{\varPhi }}{\left( \varPhi _{\textrm{C}}-\varPhi \right) g_{\varPhi }+\left( \varLambda _{\textrm{C}}-\varLambda \right) g_{\varLambda }}\right) \), and these components \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), and \(\varGamma _{\varLambda H}\) of the gravity gradient tensor) may be wrong and needs to be carefully investigated especially when these components of the gravitational acceleration vector (i.e. \(g_{\varPhi }\) and \(g_{\varLambda }\)) and gravity gradient tensor (i.e. \(\varGamma _{\varPhi \varPhi }\), \(\varGamma _{\varPhi \varLambda }\), \(\varGamma _{\varPhi H}\), \(\varGamma _{\varLambda \varLambda }\), and \(\varGamma _{\varLambda H}\)) are included.

Regarding the impacts of replacing the revised codes in this study with the original codes in Fukushima (2018) when considering practical applications for modeling the gravitational signals of mass distributions of the Earth or other planetary bodies, further empirical research is required to explore these in the future.