1 Introduction

The gravity anomaly of a region represents a basic set of geophysical data for the investigation of the subsurface density both in forward modelling and inversion (Jacoby and Smilde 2009). For this reason, it is highly beneficial to dispose of analytical solutions of the gravity anomaly associated with a body characterized by complex density distributions. Due to the mathematical complexity of the problem, the gravity anomaly of an irregular body whose density contrast is spatially variable has been first computed by approximating the body as a collection of vertical rectangular parallelepipeds (prisms) in which the density is assumed to be constant. Hence, the gravity anomaly for the whole body is computed as algebraic sum of the contribution of all vertical prisms at appropriate depths and distances from the observation point.

Numerical computations were first carried out by Talwani et al. (1959) and Bott (1960). Closed-form expressions of the gravity anomaly were subsequently derived by Nagy (1966), Banerjee and DasGupta (1977), Cady (1980), Nagy et al. (2000), Tsoulis (2000), Jiancheng and Wenbin (2010), D’Urso (2012), see also Plouff (1975, 1976), Won and Bevis (1987), Montana et al. (1992) for computer codes. The case of a spheroidal shell has been addressed by Johnson and Litehiser (1972). Analytical expressions of the gravity anomaly for prisms have been derived by D’Urso (2015b); for a linearly varying density, by Rao (1985, 1986, 1990), Rao et al. (1994), and Gallardo-Delgado et al. (2003); and for a quadratic density contrast, by García-Abdeslem (1992, 2005a), when the density varies with depth according to a cubic law. Non-polynomial density contrast models have been considered by Cordell (1973), Chai and Hinze (1988), Litinsky (1989), Silva et al. (2006), and Chappell and Kusznir (2008). For more complicated forms of the density contrast, see, e.g., Cai and Wang (2005) and Mostafa (2008).

The previous contributions are characterized by simple geometric modelling, i.e., the use of prisms, and refined modelling of the density contrast. A different approach is based on the use of polyhedra, to avoid the necessity of subdividing the region of interest in several prisms, countervailed by a simple description of density contrast. Analytical formulas for the gravimetric analysis of polyhedra having constant density have been contributed by Paul (1974), Barnett (1976), Strakhov (1978), Okabe (1979), Waldvogel (1979), Golizdra (1981), Strakhov et al. (1986), Götze and Lahmeyer (1988), Pohanka (1988), Murthy et al. (1989), Kwok (1991b), Werner (1994), Holstein and Ketteridge (1996), Petrović (1996), Werner and Scheeres (1997), Li and Chouteau (1998), Tsoulis (2012), and D’Urso (2013a). Subsequent advancements have been only concerned with a linear density variation (Pohanka 1998; Hansen 1999; Holstein 2003; Hamayun et al. 2009; D’Urso 2014b); actually, handling more complex density functions in conjunction with polyhedral models considerably increases the difficulties of the treatment, especially if analytical solutions are looked for.

As a matter of fact, the interest in modelling gravity data using non-uniform density contrast is associated with the geological and economic relevance of sedimentary basins. Actually, the sediment thickness and bedrock topography are important parameters in modelling groundwater flow, petroleum exploration, geotectonic investigations, and ground motion amplification during an earthquake (Jacoby and Smilde 2009; Aydemir et al. 2014). The geologic evaluation of sedimentary basins can be quite complex so that the kind of function describing the density contrast significantly differs from case to case. For instance, if simple differential compaction is assumed to be the main diagenetic process in the evaluation of a sedimentary basin, geologically meaningful results are obtained by using an exponentially increasing density with depth. However, if more complex geological process come into play, such as non-uniform stratigraphic layering and facies changes, more general variations in density need to be taken into account.

Independently of the kind of function assumed to define the density contrast, density can be assumed to vary, separately or jointly, along the vertical and horizontal directions. For instance, variations in density can be either arbitrary in the horizontal direction and of polynomial type in the vertical one, or with an interchanged functional dependence. This last case does occur in dipping layered intrusions or sedimentary beds in which an arbitrary density function is assumed along depth and a polynomial function is considered in the horizontal direction. Furthermore, complicated density functions can be associated with 3D modelling based on prisms (Murthy and Rao 1979; Rao et al. 1990; Chakravarthi et al. 2002; Chakravarthi and Sundararajan 2007; Zhou 2009b), or with 2D geometrical shapes (Gendzwill 1970; Murthy and Rao 1979; Pan 1989; Guspí 1990; Ruotoistenmäki 1992; Martín-Atienza and García-Abdeslem 1999; Zhang et al. 2001; Zhou 2008, 2009a, 2010). Actually, this last geometrical assumption, which characterizes domains having a cylindrical shape, significantly simplifies the mathematical treatment of the problem.

The derivation of analytical expressions for the gravity anomaly has not yet been achieved, even in the presence of two-dimensional domains, for bodies characterized by a complicated density contrast, so that numerical methods have been resorted to. Specifically, starting from the first researches on the subject (Hubbert 1948), all authors have systematically transformed the original domain integrals into integrals of lower dimension in order to simplify the adoption of quadrature rules for the numerical evaluation of the gravity anomaly.

For 2D bodies, which are the object of the present paper, Zhou (2008) converted the original domain integral for gravity anomaly to a line integral (LI) by using Stokes theorem. In particular, he derived two types of LIs for computing the gravity anomaly of bodies having density contrast depending only on depth. In a subsequent paper (Zhou 2009a), the author extended his method to account for density contrast functions that depended not only on depth but also on horizontal or, jointly, on horizontal and vertical directions. The original approach by Zhou has been further improved in Zhou (2010) to evaluate the gravity anomaly at observation points different from the origin since, historically, gravity anomaly was computed only at the origin of the reference frame. Furthermore, Zhou dealt with the singularity of the gravity anomaly arising where the observation point is coincident with the vertices of the integration domain, an issue already discussed in Kwok (1991a), for prism-based modelling, and Tsoulis and Petrović (2001) for polyhedra.

The aim of this paper is to derive an analytical expression of the gravity anomaly for polygonal bodies whose density contrast is expressed as a polynomial function of arbitrary degree in both the horizontal and vertical directions. The result is obtained by reducing the original domain integral to a boundary integral by virtue of the generalized Gauss theorem first presented in D’Urso (2012, 2013a) and subsequently applied to several problems ranging from geodesy (D’Urso 2014a, b, 2015b; D’Urso and Trotta 2015c) to geomechanics (Sessa and D’Urso 2013; D’Urso and Marmo 2015a), to geophysics (D’Urso and Marmo 2013b), and to heat transfer (Rosati and Marmo 2014). The generalized Gauss theorem referred to above does allow one not only to derive an expression of the gravity anomaly that is expressed in terms of a boundary integral but also to prove that the singularity of the gravity anomaly, arising when the observation point does belong to the integration domain, is eliminable.

For a polygonal domain \(\varOmega\) of \(n\) sides, the expression of the gravity anomaly in terms of boundary integral is further specialized to the sum of \(n\) 1D integrals. Differently from previous contributions on the subject, such 1D integrals are not numerically evaluated but expressed analytically as a function of the position vectors defining the vertices of the integration domain and of scalar quantities \(I_{ki}\) defined on each side. In turn, the quantities \(I_{ki}\), pertaining to the ith edge of the boundary of \(\varOmega\), are analytically computed by evaluating an integral of real variable that can exhibit a singularity when the edge does belong to a line containing the observation point. However, it is proved that such a singularity produces a null contribution of the ith edge to the general expression of gravity anomaly; hence, one can conclude that the derived expression is singularity-free.

By exploiting a suitable change in variables, we also derive an enhanced algebraic formula that expresses the gravity anomaly at an arbitrary point \(P\) and simplifies to the ordinary one when \(P=O\). Remarkably, the enhanced expression of the gravity anomaly has been derived without any modification of the density contrast function since this is still defined in the original reference frame. The enhanced formula has been implemented in a MATLAB code, and its accuracy and robustness has been assessed by numerical comparisons with examples derived from the literature.

2 Gravity Anomaly of a 2D Body at the Origin O of the Reference Frame

It is well known that the gravitation exerted by a 3D body \(\hat{\varOmega }\) on a unit mass at \(O\) is given by

$$\begin{aligned} \mathbf{g}(O)=G\int \limits _{\hat{\varOmega }}\frac{\Delta {\rho }(\mathbf{r})\,\mathbf{r}}{(\mathbf{r}\cdot \mathbf{r})^{3/2}}\hbox {d}V \end{aligned}$$
(1)

where \(G\) is the gravitational constant, \(\mathbf{r}\) the position vector pointing from \(O\) to an arbitrary point of \(\hat{\varOmega }\) and \(\Delta {\rho }(\mathbf{r})\) the density contrast at \(\mathbf{r}\). Hence, \(\Delta {\rho }(\mathbf{r})\hbox {d}V(\mathbf{r})\) represents the infinitesimal difference between the mass at \(\mathbf{r}\) and the background. We are interested in two-dimensional problems so that we shall denote by \(\varOmega\) the section of \(\hat{\varOmega }\) in the vertical plane and consider the reference frame sketched in Fig. 1.

Fig. 1
figure 1

Polygonal domain \(\varOmega\) and geometric quantities of the ith edge

The vertical component \(\mathbf{g}_z\) of gravitation at \(O\) is given by

$$\begin{aligned} \mathbf{g}_z(O)=G\int \limits _{\hat{\varOmega }}\frac{\Delta {\rho }(\mathbf{r})\mathbf{r}\cdot \mathbf{k}}{(\mathbf{r}\cdot \mathbf{r})^{3/2}} \hbox {d}V \end{aligned}$$
(2)

where \(\mathbf{k}\) is the unit vector directed downwards. Being \(\hat{\varOmega }\) infinite in the \(y\)-direction and assuming that the density contrast \(\Delta {\rho }\) is independent of \(y\), the previous integration can be carried out between two symmetric ordinates \(\pm\) d y , with \(d_y \rightarrow \infty\). Accordingly, one obtains

$$\begin{aligned} \mathbf{g}_z(0,0) = G \int \limits _{\varOmega } \left[ \lim _{d_y\rightarrow \infty }\int \limits _{-d_y}^{d_y}\frac{\Delta {\rho }(x,z)\mathbf{r}\cdot \mathbf{k}}{(\mathbf{r}\cdot \mathbf{r})^{3/2}} \hbox {d}y\right] \hbox {d}x \hbox {d}z = \int \limits _{\varOmega }\frac{\Delta {\rho }(x,z) z}{x^2+z^2}\hbox {d}A. \end{aligned}$$
(3)

This is the general form of the 2D integral for calculating the gravity anomaly at \(O\) produced by a distribution of 2D masses having a density contrast \(\Delta {\rho }\) with respect to the background. Actually, the gravity anomaly is defined as the line integral of the components of the 2D vector gravitation along the boundary of a mass body.

The computation of the integral in (3) is complicated by the fact that, due to geological and geochemical processes, the density contrast distribution within \(\varOmega\) can be arbitrary. A quite general expression for \(\Delta {\rho }\), able to accommodate a large variety of geological formations, is given by a double polynomial in \(x\) and \(z\), (Zhang et al. 2001; Zhou 2008, 2009a, 2010)

$$\begin{aligned} \Delta {\rho }(x,z)=\theta (x,z)=\sum _{i=0}^{N_x}\sum _{j=0}^{N_z} c_{ij} x^i z^j \end{aligned}$$
(4)

where \(N_x\) and \(N_z\) represent the maximum power of the polynomial density variation along \(x\) and \(z,\) respectively.

The scalars \(c_{ij}\) represent the coefficients of the polynomial law; they can be estimated from the known data points by a least-squares approach (Jacoby and Smilde 2009). In the sequel, we shall confine the treatment to the case

$$\begin{aligned} {N_x}+{N_z} =3 \end{aligned}$$
(5)

since this will suffice to address the majority of the numerical examples previously considered in the literature and, at the same time, to present our formulation at a degree of generality sufficient to be generalized to the cases \(N_x+N_z > 3\).

To simplify the ensuing developments, it is convenient to introduce the two-dimensional vectors \({\varvec{\rho }}=(x,z)\) and \({\varvec{\kappa }}_z (0,1)\). In this way, the previous relation can be written as

$$\begin{aligned} \mathbf{g}_z({\varvec{o}}) = 2G{\int \limits _{\varOmega }\frac{\theta ({\varvec{\rho }})({\varvec{\rho }}\cdot {\varvec{\kappa }}_z)}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A } \end{aligned},$$
(6)

and our objective was to prove that the previous integral can be expressed as a line integral extended to the boundary \(\partial {\varOmega }\) of \(\varOmega\). Paralleling an analogous treatment developed in D’Urso and Marmo (2013b), we first reformulate the general expression (4) of the density contrast by writing

$$\begin{aligned} \theta ({\varvec{\rho }}) = \theta _{\varvec{o}}+ \mathbf{c}\cdot {\varvec{\rho }}+ \mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}} + {\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}} \end{aligned}$$
(7)

where \(\theta _{\varvec{o}}\) is a scalar, \(\mathbf{c}\) is a vector, \(\mathbf{C},\) and \(\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}\) are symmetric second-order tensors, \({\varvec{{\mathbb {C}}}}\) and \({\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}\) are third-order tensors; furthermore, it has been set

$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}} = {\varvec{\rho }}\otimes {\varvec{\rho }}\qquad {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}} = {\varvec{\rho }}\otimes {\varvec{\rho }}\otimes {\varvec{\rho }} \end{aligned}$$
(8)

The second-order (rank-two) tensor \({\varvec{\rho }}\otimes {\varvec{\rho }}\) has the following matrix representation

$$\begin{aligned}{}[{\varvec{\rho }}\otimes {\varvec{\rho }}]= \left[ \begin{array}{cc} x^2 &{} xz \\ xz &{} z^2 \end{array} \right] \end{aligned}$$
(9)

so that, being

$$\begin{aligned} \mathbf{C}\cdot ({\varvec{\rho }}\otimes {\varvec{\rho }})=C_{11}x^2+2C_{12}xz+C_{22}z^2 \end{aligned}$$
(10)

a quadratic distribution of density can be assigned by suitably defining the coefficients of the symmetric tensor \(\mathbf{C}\). Analogously, the third-order tensors \({\varvec{{\mathbb {C}}}}\) and \({\varvec{\rho }}\otimes {\varvec{\rho }}\otimes {\varvec{\rho }}\) are represented in matrix form as:

(11)

i.e., as vectors of rank-two tensors. Being

$$\begin{aligned} {\varvec{{\mathbb {C}}}}\cdot ({\varvec{\rho }}\otimes {\varvec{\rho }}\otimes {\varvec{\rho }})&= {\mathbb {C}}_{111}x^3+({\mathbb {C}}_{112}+{\mathbb {C}}_{121}+{\mathbb {C}}_{211})x^2z\nonumber \\&\quad +({\mathbb {C}}_{122}+{\mathbb {C}}_{212}+{\mathbb {C}}_{221})xz^2+{\mathbb {C}}_{222}z^3 \end{aligned}$$
(12)

the representation (4) of the density contrast is recovered from (7) by setting

$$\begin{aligned} \begin{array}{rclrlcl} &{}&{}\theta _{\varvec{o}}= c_{00} \qquad c_1 = c_{10} \qquad c_2 = c_{01}\\ &{}&{}C_{11} = c_{20} \qquad C_{22} = c_{02} \qquad C_{12} = c_{11}/2 \end{array} \end{aligned}$$
(13)

and

$$\begin{aligned} {\mathbb {C}}_{111}&= c_{30}\qquad {\mathbb {C}}_{222}=c_{03}\end{aligned}$$
(14)
$$\begin{aligned} {\mathbb {C}}_{112}&= {\mathbb {C}}_{121}={\mathbb {C}}_{211}=c_{21}/3 \qquad {\mathbb {C}}_{122}={\mathbb {C}}_{212}={\mathbb {C}}_{221}=c_{12}/3 \end{aligned}$$
(15)

In conclusion, we derive from (6) the following expression of the gravity anomaly

$$\begin{aligned} \mathbf{g}_z({\varvec{o}}) = 2G\left[ \theta _{\varvec{o}}d_{\varvec{\rho }}^{\varOmega }+ \mathbf{c}\cdot \mathbf{d}_{\varvec{\rho }}^{\varOmega }+ \mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }+ {\varvec{{\mathbb {C}}}}\cdot {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }\right] \end{aligned}$$
(16)

where

$$\begin{aligned} d_{\varvec{\rho }}^{\varOmega }=\int \limits _{\varOmega } \frac{{\varvec{\rho }}\cdot {\varvec{\kappa }}_z}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A \qquad \mathbf{d}_{\varvec{\rho }}^{\varOmega }=\int \limits _{\varOmega } \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z){\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A \end{aligned}$$
(17)

and

$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }=\int \limits _{\varOmega } \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z){\varvec{\rho }}\otimes {\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A \qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }=\int \limits _{\varOmega } \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z){\varvec{\rho }}\otimes {\varvec{\rho }}\otimes {\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A \end{aligned}$$
(18)

In order to transform the previous domain integrals into boundary integrals, we apply Gauss theorem in the generalized form illustrated in D’Urso (2013a, 2014a). In this way, the singularity at \({\varvec{\rho }}={\varvec{o}}\) of the four domain integrals can be correctly taken into account.

2.1 Analytical Expression of the Gravity Anomaly at O in Terms of Boundary Integral

Let us now illustrate a general approach to express the 2D integrals in (16) as 1D integrals extended to the boundary of \(\varOmega\). Generality lies in the fact that, owing to the symmetry of the integrals, application of Gauss theorem can be based upon a unique formula. Actually, we are going to prove the general formula

$$\begin{aligned} \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}[\otimes {\varvec{\rho }},m]}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A= \frac{1}{m+1}\int \limits _{\partial {\varOmega }} \frac{\iota _{\varvec{\rho }}[\otimes {\varvec{\rho }},m]({\varvec{\rho }}\cdot {\varvec{\nu }})}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}s \quad m=0,1,\ldots \end{aligned}$$
(19)

where \(\iota _{\varvec{\rho }}={\varvec{\rho }}\cdot {\varvec{\kappa }}_z\), \({\varvec{\nu }}\) is the 2D outward unit normal to \(\partial {\varOmega }\) and \([\otimes {\varvec{\rho }},m]\) denotes a rank-\(m\) tensor defined by

$$\begin{aligned}{}[\otimes {\varvec{\rho }},m]=\left\{ \begin{array}{ll} 1 &{}\quad \hbox {if} \,\,m=0 \\ {\varvec{\rho }}&{}\quad \hbox {if}\,\,m=1 \\ {\varvec{\rho }}\otimes {\varvec{\rho }}&{}\quad \hbox {if}\,\,m=2\\ \cdots &{}\quad \cdots \\ \underbrace{{\varvec{\rho }}\otimes {\varvec{\rho }}\otimes \cdots \otimes {\varvec{\rho }}}_{m\,\mathrm{times}} &{}\quad \hbox {if}\,\,m>2 \end{array} \right. \end{aligned}$$
(20)

To fix the ideas, we shall prove the identity (19) for \(m=2\)

$$\begin{aligned} \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}{\varvec{\rho }}\otimes {\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A = \frac{1}{3}\int \limits _{\partial {\varOmega }} \frac{\iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }})\nu _{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}s \end{aligned}$$
(21)

since it allows us to illustrate our approach to a degree of generality sufficient to extend the final result to all integrals in (16) and to the additional ones, not reported in (16), containing tensors of rank superior to three, i.e., tensors of the kind \([\otimes {\varvec{\rho }},m]\) where \(m>3\). In the following, we shall make use of some differential identities that are collected in Appendix 1 in order to not divert the reader from the main stream of our derivation.

Let us consider the following identity involving the divergence of a rank-three tensor.

$$\begin{aligned} { \mathrm{div}\left[ \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }})\otimes \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] }&= { \left[ ({\varvec{\rho }}\otimes {\varvec{\rho }})\otimes \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] \mathrm{grad}\,\iota _{\varvec{\rho }}+ \iota _{\varvec{\rho }}\left[ (\mathrm{grad}\,{\varvec{\rho }})\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] \otimes {\varvec{\rho }}}\nonumber \\&\quad +\,{ \iota _{\varvec{\rho }}{\varvec{\rho }}\otimes \left[ (\mathrm{grad}\,{\varvec{\rho }})\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] + \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }}) \,\mathrm{div}\,\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}}, \end{aligned}$$
(22)

which stems from the identity (119) of Appendix 1. Furthermore, application of the identity (120) provides

$$\begin{aligned} \mathrm{grad}\,\iota _{\varvec{\rho }}=\mathrm{grad}\,({\varvec{\rho }}\cdot {\varvec{\kappa }}_{z})=(\mathrm{grad}\,{\varvec{\rho }})^\mathrm{t}{\varvec{\kappa }}_z = {\varvec{\kappa }}_z \end{aligned}$$
(23)

since \({\varvec{\kappa }}_z\) is a constant vector field and \(\mathrm{grad}\,{\varvec{\rho }}=\mathbf{I}\) where \(\mathbf{I}\) is the rank-two identity tensor. Substituting the previous relation in (22), one obtains

$$\begin{aligned} { \mathrm{div}\left[ \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }})\otimes \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] }&= { \left[ ({\varvec{\rho }}\otimes {\varvec{\rho }})\otimes \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] {\varvec{\kappa }}_z } + \iota _{\varvec{\rho }}\left[ \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\otimes {\varvec{\rho }}+ {\varvec{\rho }}\otimes \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}} \right] \nonumber \\&\quad +\,{ \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }}) \,\mathrm{div}\,\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}} } \nonumber \\&= 3 \iota _{\varvec{\rho }}\frac{{\varvec{\rho }}\otimes {\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}+ \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }}) \,\mathrm{div}\,\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}} \end{aligned}$$
(24)

Finally, integrating the previous identity over \(\varOmega\) yields

$$\begin{aligned} { \int \limits _{\varOmega } \iota _{\varvec{\rho }}\frac{{\varvec{\rho }}\otimes {\varvec{\rho }}} {{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A}&= \frac{1}{3}\int \limits _\varOmega {\mathrm{div}}\left[ \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }})\otimes \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] \hbox{d}A\nonumber \\& -\, \frac{1}{3}\int \limits _\varOmega \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }}) \,{\mathrm{div}}\,\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}} \hbox {d}A \end{aligned}$$
(25)

The second integral on the right-hand side can be computed by means of the general result (Tang 2006)

$$\begin{aligned} \int \limits _F\varphi ({\varvec{\rho }}){\mathrm{div}}\,\left[ \frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\right] \hbox {d}A= \left\{ \begin{array}{ll} 0&{}\quad \hbox {if}\,\,{\varvec{o}}\not \in F \\ \alpha ({\varvec{o}})\varphi ({\varvec{o}})&{}\quad \hbox {if}\,\,{\varvec{o}}\in F\\ \end{array} \right. \end{aligned}$$
(26)

where \(\varphi\) is a scalar function and \(F\) denotes an arbitrary 2D domain. The previous expression can be extended to arbitrary tensors by applying it to each scalar component of the tensor. Furthermore, the quantity \(\alpha\) represents the angular measure, expressed in radians, of the intersection between \(F\) and a circular neighborhood of the singularity point \({\varvec{\rho }}={\varvec{o}}\), see D’Urso (2012, 2013a, 2014a) for additional details. Although its computation is not required in the ensuing developments, we specify for completeness that \(\alpha\) can be computed by means of the general algorithm detailed in D’Urso and Russo (2002).

On account of (26), one infers that the second integral on the right-hand side of (25) is the null rank-two tensor \(\mathbf{O}\) since

$$\begin{aligned} {\int \limits _\varOmega \iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }}) \,\mathrm{div}\,\frac{{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A} =\left\{ \begin{array}{ll} \mathbf{O}\quad &{}\quad \hbox {if}\,\,{\varvec{o}}\not \in \varOmega \\ {[}\iota _{\varvec{\rho }}{\varvec{\rho }}\otimes {\varvec{\rho }}]_{{\varvec{\rho }}={\varvec{o}}}\alpha ({\varvec{o}})&{}\quad \hbox {if}\,\,{\varvec{o}}\in \varOmega \end{array} \right. \end{aligned}$$
(27)

However, the expression \([\iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }})]_{{\varvec{\rho }}={\varvec{o}}}\) amounts to evaluating the quantity \(\iota _{\varvec{\rho }}({\varvec{\rho }}\otimes {\varvec{\rho }})\) at the singularity point \({\varvec{\rho }}={\varvec{o}}\), that yields trivially the null tensor \(\mathbf{O}\). Hence, according to (27), the last integral in (25) is always the null tensor, independently from the position of singularity point \({\varvec{\rho }}={\varvec{o}}\) with respect to the domain \(\varOmega\) of integration. In conclusion, upon application of Gauss theorem to the second integral in (25), we finally infer the identity (21). Remarkably, the derivation of this identity has also allowed us to prove that the singularity at \({\varvec{\rho }}={\varvec{o}}\), of the integrand function appearing on the left-hand side of (21), can be actually ignored.

Furthermore, it is not difficult to rephrase the path of reasoning detailed in formulas (22)–(27) so as to prove the more general formula (19). Hence, defining

$$\begin{aligned} d_{\varvec{\rho }}^{\partial {\varOmega }}&= \int \limits _{\partial {\varOmega }} \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z)({\varvec{\rho }}\cdot {\varvec{\nu }})}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}s \qquad \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}=\int \limits _{\partial {\varOmega }} \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z)\,{\varvec{\rho }}\,({\varvec{\rho }}\cdot {\varvec{\nu }})}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}s \end{aligned}$$
(28)
$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}&= \int \limits _{\partial {\varOmega }} \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z)\,{\varvec{\rho }}\otimes {\varvec{\rho }}\,({\varvec{\rho }}\cdot {\varvec{\nu }})}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}s \qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}=\int \limits _{\partial {\varOmega }} \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z)\,{\varvec{\rho }}\otimes {\varvec{\rho }}\otimes {\varvec{\rho }}\,({\varvec{\rho }}\cdot {\varvec{\nu }})}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}s \end{aligned}$$
(29)

one has, recalling definitions (17) and (18)

$$\begin{aligned} d_{\varvec{\rho }}^{\varOmega }=d_{\varvec{\rho }}^{\partial {\varOmega }}\qquad \mathbf{d}_{\varvec{\rho }}^{\varOmega }=\frac{\mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}}{2} \qquad \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }=\frac{\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}}{3} \qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }=\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}}{4} \end{aligned}$$
(30)

In conclusion, application of formula (19)–(16) yields

$$\begin{aligned} \mathbf{g}_z({\varvec{o}}) = 2G\left[ \theta _{\varvec{o}}d_{\varvec{\rho }}^{\partial {\varOmega }}+ \frac{\mathbf{c}\cdot \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}}{2} + \frac{\mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}}{3}+ \frac{{\varvec{{\mathbb {C}}}}\cdot {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}}{4} \right] \end{aligned}$$
(31)

a formula that will be specialized to the case of polygonal domains in the next subsection.

2.2 Algebraic Expression of the Gravity Anomaly at O

In order to derive an algebraic expression suitable to be programmed, we specialize formula (31) to the case of a polygonal domain \(\varOmega\). Actually, this is by far the most common case since geological formations are either polygonal or can be approximated to polygons by subdividing the real boundary by an arbitrary number of vertices and edges. Once again, in order to illustrate the rationale of our derivation, we shall make reference to formula (21). In particular, denoting by \(n\) the common number of vertices and edges belonging to \(\partial {\varOmega }\) (see Fig. 1), formula (21) simplifies to

$$\begin{aligned} \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}{\varvec{\rho }}\otimes {\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A = \frac{1}{3}\sum \limits _{i=1}^{n} \int \limits _{\partial _{i}{\varOmega }} \frac{[{\varvec{\rho }}(s_i)\cdot {\varvec{\kappa }}_z] [{\varvec{\rho }}(s_i)\otimes {\varvec{\rho }}(s_i)][{\varvec{\rho }}(s_i)\cdot {\varvec{\nu }}(s_i)]}{{\varvec{\rho }}(s_i)\cdot {\varvec{\rho }}(s_i)}\hbox {d}s_i \end{aligned}$$
(32)

where \(s_i\) is the curvilinear abscissa along the ith edge \(\partial _{i}{\varOmega }\) of the boundary of \(\varOmega\).

The edge \(\partial _{i}{\varOmega }\) connects the vertices \({\varvec{\rho }}_{i}\) and \({\varvec{\rho }}_{i+1}\), see, e.g., Fig. 1, and it will be assumed that, along each edge, the relevant curvilinear abscissa has its origin at the ith vertex. Being the product \({\varvec{\rho }}(s_i)\cdot {\varvec{\nu }}(s_i)\) constant along each side, formula (32) becomes

$$\begin{aligned} \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A = \frac{1}{3}\sum \limits _{i=1}^{n} {\varvec{\rho }}_{i}\cdot {\varvec{\nu }}_{i}\int \limits _{\partial _{i}{\varOmega }} \frac{[{\varvec{\rho }}(s_i)\cdot {\varvec{\kappa }}_z] [{\varvec{\rho }}(s_i)\otimes {\varvec{\rho }}(s_i)]}{{\varvec{\rho }}(s_i)\cdot {\varvec{\rho }}(s_i)}\hbox {d}s_i \end{aligned}$$
(33)

where \({\varvec{\nu }}_{i}\) is the outward unit normal to the ith edge. Assuming a counterclockwise circulation sense along \(\partial _{i}{\varOmega }\) and denoting by \(l_i=|{\varvec{\rho }}_{i+1}-{\varvec{\rho }}_{i}|\) the length of the ith edge, it turns out \({\varvec{\nu }}_{i}=({\varvec{\rho }}_{i+1}-{\varvec{\rho }}_{i})^\perp /l_i\) where \((\cdot )^\perp\) denotes a clockwise rotation of \((\cdot )\). In particular, \({\varvec{\rho }}_{i}\cdot {\varvec{\nu }}_{i}={\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp /l_i\) where \({\varvec{\rho }}_{i+1}^\perp =(z_{i+1},-x_{i+1})\) (D’Urso 2013a).

Introducing in (32) the dimensionless abscissa \(\lambda _{i}=s_i/l_i,\) we finally get

$$\begin{aligned} \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A = \frac{1}{3}\sum \limits _{i=1}^{n} {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \int \limits _{0}^{1} \frac{[{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z] [{\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})]}{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})}\hbox {d}\lambda _{i}, \end{aligned}$$
(34)

which represents the starting point to derive the basic formulas useful for programming.

Actually, defining

$$\begin{aligned} d_{\varvec{\rho }}^{\partial _{i}\varOmega }&= \int \limits _{0}^1 \frac{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z}{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})} \hbox {d}\lambda _i \qquad \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }=\int \limits _{0}^1 \frac{[{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z]{\varvec{\rho }}(\lambda _{i})}{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})} \hbox {d}\lambda _i \end{aligned}$$
(35)
$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }&= \int \limits _{0}^1 \frac{[{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z]{\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})}{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})} \hbox {d}\lambda _i \end{aligned}$$
(36)
$$\begin{aligned} {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }&= \int \limits _{0}^1 \frac{[{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z]{\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})}{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})} \hbox {d}\lambda _i, \end{aligned}$$
(37)

we can express the integrals (28) and (29) as

$$\begin{aligned} d_{\varvec{\rho }}^{\partial {\varOmega }}&= \sum \limits _{i=1}^{n} ({\varvec{\rho }}_{i}\cdot {\varvec{\nu }}_{i})l_id_{\varvec{\rho }}^{\partial _{i}\varOmega }\qquad \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}=\sum \limits _{i=1}^{n} ({\varvec{\rho }}_{i}\cdot {\varvec{\nu }}_{i})l_i\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\end{aligned}$$
(38)
$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}&= \sum \limits _{i=1}^{n}({\varvec{\rho }}_{i}\cdot {\varvec{\nu }}_{i})l_i\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}=\sum \limits _{i=1}^{n} ({\varvec{\rho }}_{i}\cdot {\varvec{\nu }}_{i})l_i{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\end{aligned}$$
(39)

Accordingly, formula (31) of the gravity anomaly simplifies as follows

$$\begin{aligned} \mathbf{g}_z({\varvec{o}}) = 2G \sum \limits _{i=1}^{n}({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp ) \left\{ \theta _{\varvec{o}}d_{\varvec{\rho }}^{\partial _{i}\varOmega }+ \frac{\mathbf{c}\cdot \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }}{2} + \frac{\mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }}{3} + \frac{{\varvec{{\mathbb {C}}}}\cdot {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }}{4} \right\} \end{aligned}$$
(40)

The previous integrals can be evaluated analytically by introducing the following parameterization of the ith edge

$$\begin{aligned} {\varvec{\rho }}(\lambda _{i})={\varvec{\rho }}_{i}+\lambda _i({\varvec{\rho }}_{i+1}-{\varvec{\rho }}_{i})={\varvec{\rho }}_{i}+\lambda _i\Delta {{\varvec{\rho }}_{i}} \end{aligned}$$
(41)

In this way, one has

$$\begin{aligned} {\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z=({\varvec{\rho }}_{i}\cdot {\varvec{\kappa }}_z)+\lambda _i(\Delta {{\varvec{\rho }}_{i}}\cdot {\varvec{\kappa }}_z)= a_i+b_i\lambda _i \end{aligned}$$
(42)

and

$$\begin{aligned} {\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})=p_i\lambda _i^2+2q_i\lambda _i+u_i \end{aligned}$$
(43)

where

$$\begin{aligned} p_i=\Delta {{\varvec{\rho }}_{i}}\cdot \Delta {{\varvec{\rho }}_{i}}\qquad q_i={\varvec{\rho }}_{i}\cdot \Delta {{\varvec{\rho }}_{i}}\qquad u_i={\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i} \end{aligned}$$
(44)

Furthermore,

$$\begin{aligned} {\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})&= {\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}+\lambda _i({\varvec{\rho }}_{i}\otimes \Delta {{\varvec{\rho }}_{i}}+\Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\rho }}_{i})+\lambda _i^2\Delta {{\varvec{\rho }}_{i}}\otimes \Delta {{\varvec{\rho }}_{i}}\nonumber \\&= \mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}} + \lambda _i \mathbf{D}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}} + \lambda _i^2\mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} \end{aligned}$$
(45)

Analogously, setting

$$\begin{aligned} {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}&= {\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\qquad {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}={\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\otimes \Delta {{\varvec{\rho }}_{i}}+{\varvec{\rho }}_{i}\otimes \Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\rho }}_{i}+ \Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\end{aligned}$$
(46)
$$\begin{aligned} {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}&= {\varvec{\rho }}_{i}\otimes \Delta {{\varvec{\rho }}_{i}}\otimes \Delta {{\varvec{\rho }}_{i}}+\Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\rho }}_{i}\otimes \Delta {{\varvec{\rho }}_{i}}\nonumber \\&\quad +\, \Delta {{\varvec{\rho }}_{i}}\otimes \Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\rho }}_{i}\end{aligned}$$
(47)
$$\begin{aligned} {\varvec{{\mathbb {D}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}&= \Delta {{\varvec{\rho }}_{i}}\otimes \Delta {{\varvec{\rho }}_{i}}\otimes \Delta {{\varvec{\rho }}_{i}},\end{aligned}$$
(48)

one has

$$\begin{aligned} {\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\rho }}(\lambda _{i})={\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}+ \lambda _i{\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}} + \lambda _i^2 {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} + \lambda _i^3{\varvec{{\mathbb {D}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} \end{aligned}$$
(49)

Thus, defining

$$\begin{aligned} f(\lambda _i) = \frac{a_i+b_i\lambda _i}{p_i\lambda _i^2+2q_i\lambda _i+u_i} \end{aligned}$$
(50)

formula (40) simplifies to

$$\begin{aligned} \mathbf{g}_z({\varvec{o}})&= 2G\sum \limits _{i=1}^{n}\left( {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \right) \left\{ \theta _{\varvec{o}}\int \limits _{0}^1 f(\lambda _i) \hbox {d}\lambda _i + \frac{\mathbf{c}}{2}\cdot \int \limits _{0}^1 f(\lambda _i)({\varvec{\rho }}_{i}+\lambda _i\Delta {{\varvec{\rho }}_{i}}) \hbox {d}\lambda _i\right. \nonumber \\&\quad \left. +\,\frac{\mathbf{C}}{3}\cdot \int \limits _{0}^1 f(\lambda _i) \left[ \mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}} + \lambda _i \mathbf{D}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}} + \lambda _i^2\mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} \right] \hbox {d}\lambda _i \right. \nonumber \\&\quad \left. +\,\frac{{\varvec{{\mathbb {C}}}}}{4}\cdot \int \limits _{0}^1 f(\lambda _i) \left[ {\varvec{{\mathbb {C}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}} + \lambda _i {\varvec{{\mathbb {C}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}} + \lambda _i^2 {\varvec{{\mathbb {C}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} + \lambda _i^3{\varvec{{\mathbb {C}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} \right] \hbox {d}\lambda _i \right\} \end{aligned}$$
(51)

Grouping together the quantities multiplying the same exponent of \(\lambda _i\) and setting

$$\begin{aligned} \theta _{{\varvec{\rho }}_{i}}^O&= \frac{\mathbf{c}\cdot {\varvec{\rho }}_{i}}{2}+\frac{\mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}}{3} + \frac{{\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}}{4}\end{aligned}$$
(52)
$$\begin{aligned} \theta _{\Delta {{\varvec{\rho }}_{i}}}^O&= \frac{\mathbf{c}\cdot \Delta {{\varvec{\rho }}_{i}}}{2}+\frac{\mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}}{3} + \frac{{\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}}{4} \end{aligned}$$
(53)
$$\begin{aligned} \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O&= \frac{\mathbf{C}\cdot \mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}}{3} + \frac{{\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}}{4} \end{aligned}$$
(54)
$$\begin{aligned} \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O&= \frac{{\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}}{4} \end{aligned}$$
(55)

formula (40) becomes

$$\begin{aligned} \mathbf{g}_z({\varvec{o}})&= 2G \sum \limits _{i=1}^{n}\left( {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \right) \left\{ I_{0i}\left[ a_i\left( \theta _{\varvec{o}}+ \theta _{{\varvec{\rho }}_{i}}^O\right) \right] + I_{1i}\left[ a_i\theta _{\Delta {{\varvec{\rho }}_{i}}}^O + b_i \theta _{{\varvec{\rho }}_{i}}^O \right] \right. \nonumber \\&\quad \left. +\, I_{2i}\left[ a_i\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O + b_i \theta _{\Delta {{\varvec{\rho }}_{i}}}^O \right] + I_{3i}\left[ a_i\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O + b_i \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O \right] \right. \nonumber \\&\quad \left. +\, I_{4i}b_i \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O \right\} \end{aligned}$$
(56)

where

$$\begin{aligned} I_{ki}=\int \limits _0^1\frac{\lambda _i^k}{p_i \lambda _i^2 + 2 q_i \lambda _i + u_i}\hbox {d}\lambda _i \end{aligned}$$
(57)

\(\theta _{\varvec{o}}\) is defined in (13), \(a_i,b_i\) in (42), \(\theta _{{\varvec{\rho }}_{i}}^O-\theta _{\Delta {{\varvec{\rho }}_{i}}}^O-\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O- \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O\) in (52)–(55).

The actual computation of the integrals \(I_{ki}\) will be detailed in Sect. 4. In particular, singularities in their expression, due to the vanishing of the denominator in (57), will be proved to be ineffective. Hence, formula (56) is singularity-free in the sense that, for edges characterized by singularities of the integrals \(I_{ki}\), the whole addend of the sum is zero.

3 Gravity Anomaly of a 2D Body at an Arbitrary Point P

Gravity anomaly calculations at an observation point which does not coincide with the origin of the reference frame have been first addressed by Zhou (2010). Specifically, the author devised two alternative formulations: the first one, named coordinate transformation, was conceived so as to make the observation point as the origin of the new coordinate system and employing the solution obtained by the author in Zhang et al. (2001) and Zhou (2009a). Clearly, this approach requires one to express the density contrast as a function of the new coordinates. In the second formulation proposed by Zhou (2010), named solution transformation, the solution at an arbitrary point is extrapolated from that obtained at the origin of the reference frame.

On the contrary, denoting by \({\varvec{\omega }}=(x_P,z_P)\) the position vector of an arbitrary point \(P\), we show that the approach illustrated in the previous section, as well as the function expressing the density contrast, can be left unchanged provided that one introduces the vector

$$\begin{aligned} {\varvec{\rho }}={\varvec{\sigma }}-{\varvec{\omega }} \end{aligned}$$
(58)

defining the relative position of the generic point \({\varvec{\sigma }}=(x,z)\) of \(\varOmega\) with respect to \(P\), see, e.g., Fig. 2. Hence, the gravity anomaly at \(P\) is given by

$$\begin{aligned} \mathbf{g}_z(P) =\mathbf{g}_z({\varvec{\omega }}) = 2G\int \limits _{\varOmega }\frac{\theta ({\varvec{\sigma }})({\varvec{\rho }}\cdot {\varvec{\kappa }}_z)}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A \end{aligned}$$
(59)

an expression which trivially simplifies to (6) whenever \({\varvec{\omega }}={\varvec{o}}\). On account of (7), the previous expression becomes

$$\begin{aligned} \mathbf{g}_z({\varvec{\omega }})&= 2G\left\{ \theta _{\varvec{o}}\int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A + \mathbf{c}\cdot \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}{\varvec{\sigma }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A\right. \nonumber \\&\quad \left. +\, \mathbf{C}\cdot \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}\mathbf{D}_{{\varvec{\sigma }}{\varvec{\sigma }}}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A + {\varvec{{\mathbb {C}}}}\cdot \int \limits _{\varOmega } \frac{\iota _{\varvec{\rho }}{\varvec{{\mathbb {D}}}}_{{\varvec{\sigma }}{\varvec{\sigma }}{\varvec{\sigma }}}}{{\varvec{\rho }}\cdot {\varvec{\rho }}}\hbox {d}A \right\} \end{aligned}$$
(60)

where \(\mathbf{D}_{{\varvec{\sigma }}{\varvec{\sigma }}}\) and \({\varvec{{\mathbb {D}}}}_{{\varvec{\sigma }}{\varvec{\sigma }}{\varvec{\sigma }}}\) are defined as in (8).

Fig. 2
figure 2

Representation of geometric quantities used to assign density contrast (\({\varvec{\sigma }}\)) and define the position of \(\varOmega\) with respect to an arbitrary point \(P\)

To exploit the results illustrated in the previous section, it is convenient to express \({\varvec{\sigma }}\) as a function of \({\varvec{\rho }}\). For brevity, this is detailed only for the rank-three tensor \({\varvec{{\mathbb {D}}}}_{{\varvec{\sigma }}{\varvec{\sigma }}{\varvec{\sigma }}}\) since it is the more cumbersome to handle. In particular, recalling (58), one has

$$\begin{aligned} {\varvec{{\mathbb {D}}}}_{{\varvec{\sigma }}{\varvec{\sigma }}{\varvec{\sigma }}}&= {\varvec{\sigma }}\otimes {\varvec{\sigma }}\otimes {\varvec{\sigma }}= ({\varvec{\rho }}+{\varvec{\omega }})\otimes ({\varvec{\rho }}+{\varvec{\omega }})\otimes ({\varvec{\rho }}+{\varvec{\omega }})\nonumber \\&= {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}+ {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\omega }}}+ {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\rho }}}+ {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\omega }}} \end{aligned}$$
(61)

where \({\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\omega }}}={\varvec{\omega }}\otimes {\varvec{\omega }}\otimes {\varvec{\omega }},\)

$$\begin{aligned} {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\omega }}}= {\varvec{\rho }}\otimes {\varvec{\rho }}\otimes {\varvec{\omega }}+ {\varvec{\rho }}\otimes {\varvec{\omega }}\otimes {\varvec{\rho }}+ {\varvec{\omega }}\otimes {\varvec{\rho }}\otimes {\varvec{\rho }} \end{aligned}$$
(62)

and

$$\begin{aligned} {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\rho }}}&= {\varvec{\omega }}\otimes {\varvec{\omega }}\otimes {\varvec{\rho }}+ {\varvec{\omega }}\otimes {\varvec{\rho }}\otimes {\varvec{\omega }}+ {\varvec{\rho }}\otimes {\varvec{\omega }}\otimes {\varvec{\omega }}\nonumber \\&= \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\otimes {\varvec{\rho }}+ {\varvec{\omega }}\otimes {\varvec{\rho }}\otimes {\varvec{\omega }}+ {\varvec{\rho }}\otimes \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}} \end{aligned}$$
(63)

Hence, (60) becomes

$$\begin{aligned} \mathbf{g}_z({\varvec{\omega }})&= 2G\left\{ \left[ \theta _{\varvec{o}}+ \mathbf{c}\cdot {\varvec{\omega }}+ \mathbf{C}\cdot \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}} + {\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\omega }}}\right] d_{\varvec{\rho }}^{\varOmega }+ \mathbf{c}\cdot \mathbf{d}_{\varvec{\rho }}^{\varOmega }\right. \nonumber \\&\quad +\, \mathbf{C}\cdot \left[ \mathbf{d}_{\varvec{\rho }}^{\varOmega }\otimes {\varvec{\omega }}+ {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\varOmega }+ \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }\right] \nonumber \\&\quad +\,{\varvec{{\mathbb {C}}}}\cdot \left[ \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\otimes \mathbf{d}_{\varvec{\rho }}^{\varOmega }+ {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\varOmega }\otimes {\varvec{\omega }}+ \mathbf{d}_{\varvec{\rho }}^{\varOmega }\otimes \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\right] \nonumber \\&\quad +\left. \,{\varvec{{\mathbb {C}}}}\cdot \left[ \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }\otimes {\varvec{\omega }}+ \mathbf{d}_{\varvec{\rho }}^{\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\varOmega }+ {\varvec{\omega }}\otimes \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }\right] +{\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}^\varOmega _{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}} \right\}, \end{aligned}$$
(64)

which represents the generalization of (16) to the case \({\varvec{\omega }}\not ={\varvec{o}}\).

Special attention has to be paid to the symbol \(\mathbf{d}_{\varvec{\rho }}^{\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\varOmega },\) which is a shorthand to denote the third-order tensor

$$\begin{aligned} \mathbf{d}_{\varvec{\rho }}^{\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\varOmega }= \int \limits _\varOmega \frac{({\varvec{\rho }}\cdot {\varvec{\kappa }}_z){\varvec{\rho }}\otimes {\varvec{\omega }}\otimes {\varvec{\rho }}}{{\varvec{\rho }}\cdot {\varvec{\rho }}} \hbox {d}A \end{aligned}$$
(65)

In spite of its symbol, which has been adopted to emphasize its symmetric expression, the tensor above cannot be obtained as triple tensor product of the vectors \(\mathbf{d}_{\varvec{\rho }}^{\varOmega }\) and \({\varvec{\omega }}\). Rather, as detailed in Sect. 3.3, it is conveniently computed starting from the rank-two tensor \(\mathbf{D}^\varOmega _{{\varvec{\rho }}{\varvec{\rho }}}\). For the sake of clarity, and to parallel the treatment developed in the previous section, we shall consider separately the analytical expression of the gravity attraction at an arbitrary point \(P\) and its algebraic counterpart, i.e., the formula useful for programming.

3.1 Analytical Expression of the Gravity Anomaly at an Arbitrary Point P in Terms of Boundary Integral

Although \({\varvec{\rho }}\) is now defined from (58), it can be shown that formula (19) holds as well. Thus, recalling (30) and setting

$$\begin{aligned} \theta _{{\varvec{\omega }}}=\mathbf{c}\cdot {\varvec{\omega }}+ \mathbf{C}\cdot \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}+ {\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\omega }}} \end{aligned}$$
(66)

formula (64) simplifies to

$$\begin{aligned} \mathbf{g}_z({\varvec{\omega }})&= 2G\left\{ ( \theta _{\varvec{o}}+ \theta _{{\varvec{\omega }}}) d_{\varvec{\rho }}^{\partial {\varOmega }}+ \frac{\mathbf{c}\cdot \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}}{2} + \mathbf{C}\cdot \left[ \frac{\mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}}{2} \otimes {\varvec{\omega }}+ {\varvec{\omega }}\otimes \frac{\mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}}{2} + \frac{\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}}{3} \right] \right. \nonumber \\&\left. \quad \quad \quad +\, {\varvec{{\mathbb {C}}}}\cdot \left[ \frac{1}{2}\left( \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}+ {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}\otimes {\varvec{\omega }}+ \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}\otimes \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\right) \right. \right. \nonumber \\&\left. \left. \quad \quad \quad+\,\frac{1}{3}\left( \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}\otimes {\varvec{\omega }}+ \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial {\varOmega }}+ {\varvec{\omega }}\otimes \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial {\varOmega }}\right) +\frac{{\varvec{{\mathbb {D}}}}^{\partial \varOmega }_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}}{4} \right] \right\} \end{aligned}$$
(67)

Obviously, (67) coincides with (31) when \({\varvec{\omega }}={\varvec{o}}\). We are now in the position to simplify (67) to the case of a polygonal boundary.

3.2 Algebraic Expression of the Gravity Anomaly at an Arbitrary Point P

On account of (38) and (39), formula (67) becomes

$$\begin{aligned} \mathbf{g}_z({\varvec{\omega }})&= 2G\sum \limits _{i=1}^{n} {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \left\{ [\theta _{\varvec{o}}+ \theta _{{\varvec{\omega }}}] d_{\varvec{\rho }}^{\partial _{i}\varOmega }+ \frac{\mathbf{c}\cdot \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }}{2} + \mathbf{C}\cdot \left[ \frac{\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }}{2} \otimes {\varvec{\omega }}+ {\varvec{\omega }}\otimes \frac{\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }}{2} + \frac{\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }}{3} \right] \right. \nonumber \\&\left. \quad +\,{\varvec{{\mathbb {C}}}}\cdot \left[ \frac{1}{2}\left( \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }+{\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}+ \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\right) \right. \right. \nonumber \\&\left. \left. \quad +\,\frac{1}{3}\left( \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}+ \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }+ {\varvec{\omega }}\otimes \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\right) +\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }}{4} \right] \right\} \end{aligned}$$
(68)

Furthermore, recalling the definitions (41)–(43), (45), (49), and (57), one can express (35)–(37)

$$\begin{aligned} d_{\varvec{\rho }}^{\partial _{i}\varOmega }&= a_i I_{0i}+b_i I_{1i}\end{aligned}$$
(69)
$$\begin{aligned} \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }&= (a_i I_{0i}+b_i I_{1i}){\varvec{\rho }}_{i}+(a_i I_{1i}+b_i I_{2i})\Delta {{\varvec{\rho }}_{i}}\end{aligned}$$
(70)
$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }&= (a_i I_{0i}+b_i I_{1i})\mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}+ (a_i I_{1i}+b_i I_{2i})\mathbf{D}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}\nonumber \\&\quad +\, (a_i I_{2i}+b_i I_{3i})\mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}\end{aligned}$$
(71)
$$\begin{aligned} {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }&= (a_i I_{0i}+b_i I_{1i}){\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}} + (a_i I_{1i}+b_i I_{2i}){\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}} \nonumber \\&\quad +\, (a_i I_{2i}+b_i I_{3i}){\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} + (a_i I_{3i}+b_i I_{4i}){\varvec{{\mathbb {D}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}} \end{aligned}$$
(72)

In order to shorten the subsequent formulas to the maximum extent, it is convenient to introduce the following additional notation

$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\omega }}}= {\varvec{\rho }}_{i}\otimes {\varvec{\omega }}+{\varvec{\omega }}\otimes {\varvec{\rho }}_{i}\qquad \mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}= \Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\omega }}+{\varvec{\omega }}\otimes \Delta {{\varvec{\rho }}_{i}} \end{aligned}$$
(73)

and

(74)
(75)
(76)
$$\begin{aligned} {{\varvec{{\mathbb {D}}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\rho }}_{i}}&= {\varvec{\omega }}\otimes {\varvec{\omega }}\otimes {\varvec{\rho }}_{i}+{\varvec{\omega }}\otimes {\varvec{\rho }}_{i}\otimes {\varvec{\omega }}+{\varvec{\rho }}_{i}\otimes {\varvec{\omega }}\otimes {\varvec{\omega }}\nonumber \\&= \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\otimes {\varvec{\rho }}_{i}+{\varvec{\omega }}\otimes {\varvec{\rho }}_{i}\otimes {\varvec{\omega }}+ {\varvec{\rho }}_{i}\otimes \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\end{aligned}$$
(77)
$$\begin{aligned} {{\varvec{{\mathbb {D}}}}}_{{\varvec{\omega }}{\varvec{\omega }}\Delta {{\varvec{\rho }}_{i}}}&= {\varvec{\omega }}\otimes {\varvec{\omega }}\otimes \Delta {{\varvec{\rho }}_{i}}+{\varvec{\omega }}\otimes \Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\omega }}+\Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\omega }}\otimes {\varvec{\omega }}\nonumber \\&= \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}}\otimes \Delta {{\varvec{\rho }}_{i}}+{\varvec{\omega }}\otimes \Delta {{\varvec{\rho }}_{i}}\otimes {\varvec{\omega }}+ \Delta {{\varvec{\rho }}_{i}}\otimes \mathbf{D}_{{\varvec{\omega }}{\varvec{\omega }}} \end{aligned}$$
(78)

The symbols , , , and denote quantities that have been formally introduced in the previous expression simply to preserve its symmetry of representation and to facilitate the reader in checking the correctness of formula (81). As a matter of fact, they do not have to be computed since they are associated with the integral (65) and its discrete counterpart \(\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\) in (68). The computation of this last quantity is addressed in Sect. 3.3.

Substituting the previous expressions in (68) and defining

$$\begin{aligned} \theta _{{\varvec{\rho }}_{i}}^P&= \frac{\mathbf{C}\cdot \mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\omega }}}}{2} + \frac{{\varvec{{\mathbb {C}}}}}{3}\cdot \left( {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\rho }}_{i}}+ {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\omega }}}\right) \end{aligned}$$
(79)
$$\begin{aligned} \theta _{\Delta {{\varvec{\rho }}_{i}}}^P&= \frac{\mathbf{C}\cdot \mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}}{2} + \frac{{\varvec{{\mathbb {C}}}}}{3}\cdot \left( {\varvec{{\mathbb {D}}}}_{{\varvec{\omega }}{\varvec{\omega }}\Delta {{\varvec{\rho }}_{i}}}+ {\varvec{{\mathbb {D}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}\right) \qquad \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^P = \frac{{\varvec{{\mathbb {C}}}}\cdot {\varvec{{\mathbb {D}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}}{3}, \end{aligned}$$
(80)

we get

$$\begin{aligned} \mathbf{g}_z({\varvec{o}})&= 2G\sum \limits _{i=1}^{n}\left( {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \right) \left\{ I_{0i}\left[ a_i\left( \theta _{\varvec{o}}+ \theta _{{\varvec{\rho }}_{i}}^O+\theta _{{\varvec{\omega }}}+\theta _{{\varvec{\rho }}_{i}}^P \right) \right] \right. \nonumber \\&\left. \quad +\,I_{1i}\left[ a_i\left( \theta _{\Delta {{\varvec{\rho }}_{i}}}^O + \theta _{\Delta {{\varvec{\rho }}_{i}}}^P\right) + b_i \left( \theta _{\varvec{o}}+ \theta _{{\varvec{\rho }}_{i}}^O +\theta _{{\varvec{\omega }}}+\theta _{{\varvec{\rho }}_{i}}^P\right) \right] \right. \nonumber \\&\left. \quad +\,I_{2i}\left[ a_i\left( \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O + \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^P\right) + b_i \left( \theta _{\Delta {{\varvec{\rho }}_{i}}}^O + \theta _{\Delta {{\varvec{\rho }}_{i}}}^P\right) \right] \right. \nonumber \\&\left. \quad +\, I_{3i}\left[ a_i\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O + b_i \left( \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O + \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^P\right) \right] + I_{4i}b_i \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O \right\} \end{aligned}$$
(81)

where \(\theta _{\varvec{o}}\) is defined in (13), \(a_i,b_i\) in (42), \(I_{ki}\) \((k=0,1,2,3\)) in (57), \(\theta _{{\varvec{\rho }}_{i}}^O-\theta _{\Delta {{\varvec{\rho }}_{i}}}^O-\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O- \theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^O\) in (52)–(55), \(\theta _{{\varvec{\omega }}}\) in (66), \(\theta _{{\varvec{\rho }}_{i}}^P-\theta _{\Delta {{\varvec{\rho }}_{i}}}^P-\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^P\) in (79) and (80).

By eliminating all terms depending explicitly on \({\varvec{\omega }}\), i.e., \(\theta _{{\varvec{\omega }}}\), \(\theta _{{\varvec{\rho }}_{i}}^P\), \(\theta _{\Delta {{\varvec{\rho }}_{i}}}^P\) and \(\theta _{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}^P\), it can be easily checked that the previous expression does simplify to (56) when \({\varvec{\omega }}={\varvec{o}}\), i.e., when the gravity anomaly is evaluated at the origin of the reference frame. The previous expression is particularly useful for programming since \(I_{2i}\), \(I_{3i}\) and \(I_{4i}\) can be expressed as a function of \(I_{0i}\) and \(I_{1i}\) by means of formulas (130)–(132) detailed in Appendix 2. The resulting formula is not reported explicitly since it amounts to performing straightforward algebraic manipulations.

To derive an alternative expression of the gravity anomaly which can be conveniently used to check the correct implementation of the more efficient one reported in (81), one can set

$$\begin{aligned} \iota _{ki} = a_i I_{ki}+b_i I_{(k+1)i} \quad k=0,\ldots ,3 \end{aligned}$$
(82)

and replace formulas (69)–(72) with

$$\begin{aligned} d_{\varvec{\rho }}^{\partial _{i}\varOmega }&= \iota _{0i}\qquad \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }=\iota _{0i}{\varvec{\rho }}_{i}+\iota _{1i}\Delta {{\varvec{\rho }}_{i}}\end{aligned}$$
(83)
$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }&= \iota _{0i}\mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}+\iota _{1i}\mathbf{D}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}+\iota _{2i}\mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}\end{aligned}$$
(84)
$$\begin{aligned} {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }&= \iota _{0i}{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}+\iota _{1i}{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}\nonumber \\&\quad +\,\iota _{2i}{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}+\iota _{3i}{{\varvec{{\mathbb {D}}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}\end{aligned}$$
(85)

Hence, formula (68) becomes

$$\begin{aligned} \mathbf{g}_z({\varvec{\omega }})&= 2G\sum \limits _{i=1}^{n} {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \left\{ [ \theta _{\varvec{o}}+ \theta _{{\varvec{\omega }}}] \iota _{0i}+ \frac{\mathbf{c}}{2}\cdot (\iota _{0i}{\varvec{\rho }}_{i}+\iota _{1i}\Delta {{\varvec{\rho }}_{i}}) \right. \nonumber \\&\left. \quad +\, \mathbf{C}\cdot \left[ \iota _{0i}\left( \frac{\mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\omega }}}}{2}+\frac{\mathbf{D}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}}{3}\right) +\iota _{1i}\left( \frac{\mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}}{2}+\frac{\mathbf{D}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}}{3}\right) +\iota _{2i}\frac{\mathbf{D}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}}{3}\right] \right. \nonumber \\&\left. \quad +\, {\varvec{{\mathbb {C}}}}\cdot \left[ \iota _{0i}\left( \frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\omega }}{\varvec{\omega }}{\varvec{\rho }}_{i}}}{2}+\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\omega }}}}{3} +\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}}}{4}\right) +\iota _{1i}\left( \frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\omega }}{\varvec{\omega }}\Delta {{\varvec{\rho }}_{i}}}}{2}+\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}}{3}+\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}}}{4}\right) \right. \right. \nonumber \\&\left. \left. \quad +\,\iota _{2i}\left( \frac{{{\varvec{{\mathbb {D}}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}{\varvec{\omega }}}}{3}+\frac{{{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}_{i}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}}{4}\right) +\iota _{3i}\frac{{{\varvec{{\mathbb {D}}}}}_{\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}\Delta {{\varvec{\rho }}_{i}}}}{4}\right] \right\} \end{aligned}$$
(86)

a formula which can be further elaborated upon by expressing \(I_{2i}, I_{3i}\) and \(I_{4i}\) as a function of \(I_{0i}\) and \(I_{1i}\) in the formulas for \(\iota _{2i},\iota _{3i}\) and \(\iota _{4i}\).

3.3 Evaluation of the Third-Order Tensor \(\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\)

We have denoted by the symbol \(\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\) in (68) the third-order tensor

$$\begin{aligned} \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }=\int \limits _{0}^1 \frac{[{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\kappa }}_z]{\varvec{\rho }}(\lambda _{i})\otimes {\varvec{\omega }}\otimes {\varvec{\rho }}(\lambda _{i})}{{\varvec{\rho }}(\lambda _{i})\cdot {\varvec{\rho }}(\lambda _{i})} \hbox {d}\lambda _i \end{aligned}$$
(87)

As a matter of fact, the tensor to evaluate is the rank-two tensor \(\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\) since its components have to be suitably combined with those of \({\varvec{\omega }}\) in order to compute (87). In turn, this depends upon the rule which is adopted to define the matrix associated with a third-order tensor, a rule which usually depends upon the adopted programming language. For instance, extending the rule defined in (11) to three arbitrary vectors \(\mathbf{t}\), \(\mathbf{v}\) and \(\mathbf{w},\) one obtains

(88)

The products \(t_1 w_1\), \(t_1 w_2\) are the components of the tensor \(\mathbf{t}\otimes \mathbf{w}\) which plays the role of the tensor \(\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\), i.e., the one to be actually computed.

Accordingly, we can define the matrix associated with \(\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\otimes {\varvec{\omega }}\otimes \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\) as

(89)

where \([\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }]_{ij}\) denotes the \(ij\) entry of the matrix associated with \(\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\).

4 Ineffective Singularities of the Algebraic Expressions of the Gravity Anomaly

It has already been shown that the analytical expression (31) of the gravity anomaly is singularity-free in the sense that its expression holds rigorously whatever is the position of the point \(O\) with respect to \(\varOmega\). The same property holds true for the expression (67) referred to an arbitrary point \(P\). However, the algebraic counterparts of (31) and (67), which are provided by formulas (56) and (81), respectively, still hide some singularities.

They are associated with the expression of the integrals \(I_{ki}\), provided in (57), since some special positions of the generic edge of \(\partial {\varOmega }\) with respect to the observation point can make the denominator of (57) vanish. However, we are going to prove that such singularities are ineffective from the computational point of view since they can actually be ignored when evaluating the ith addend of the sums (56) and (81).

To fully understand this point, let us first notice that the opposite of the discriminant \(\varDelta _{i}\) of the quadratic function at the denominator in (57) is always nonnegative, being

$$\begin{aligned} \varDelta _i=p_i u_i-q_i^2=({\varvec{\rho }}_{i+1}\cdot {\varvec{\rho }}_{i+1})({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i})-({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1})^2\ge 0 \end{aligned}$$
(90)

by virtue of the Cauchy–Schwarz inequality (Tang 2006). The quantity \(\varDelta _i\) can vanish, making undefined the integral \(I_{ki}\) in (57), if and only if either \({\varvec{\rho }}_{i}({\varvec{\rho }}_{i+1}) = {\varvec{o}}\) or \({\varvec{\rho }}_{i}\) and \({\varvec{\rho }}_{i+1}\) are parallel. In turn, this happens when the observation point does belong to the line containing the ith edge. Accordingly, if \(\varDelta _i>0\), formulas (124) and (125) simplify to

$$\begin{aligned} I_{0i}=\frac{1}{\sqrt{\varDelta _i}}\left[ \hbox { arctan}\frac{{\varvec{\rho }}_{i+1}\cdot \Delta {{\varvec{\rho }}_{i}}}{\sqrt{\varDelta _i}} - \hbox { arctan}\frac{{\varvec{\rho }}_{i}\cdot \Delta {{\varvec{\rho }}_{i}}}{\sqrt{\varDelta _i}}\right] \end{aligned}$$
(91)

and

$$\begin{aligned} I_{1i}=\frac{1}{\Delta {{\varvec{\rho }}_{i}}\cdot \Delta {{\varvec{\rho }}_{i}}}\left[ \frac{1}{2}\hbox { log} \frac{{\varvec{\rho }}_{i+1}\cdot {\varvec{\rho }}_{i+1}}{{\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i}} - ({\varvec{\rho }}_{i}\cdot \Delta {{\varvec{\rho }}_{i}}) I_{0i}\right], \end{aligned}$$
(92)

respectively. Furthermore, formulas (130)–(132) can be used to evaluate \(I_{2i}\), \(I_{3i}\) and \(I_{4i}\).

Clearly, the previous expressions become singular if \(\varDelta _i=0\), i.e., when the ith edge does belong to a line containing the observation point. Nevertheless, we shall prove that the contribution of the ith edge to the gravity anomaly is zero. Hence, from the computational point of view, it is possible to skip the evaluation of the ith addend in formula (56) whenever the ith edge does belong to a line containing \(O\). The same property can be invoked for formulas (81) and (86) whenever the ith edge does belong to a line containing the arbitrary point \(P\) at which the gravity anomaly is required. The conditions stated above do hold when \({\varvec{\rho }}_{i}={\varvec{o}}\) or \({\varvec{\rho }}_{i+1}={\varvec{o}}\) or \({\varvec{\rho }}_{i}\) is parallel to \({\varvec{\rho }}_{i+1}\). These three cases will be addressed separately in the sequel.

4.1 Simplification of the Line Integrals (35)–(37) to the Case \({\varvec{\rho }}_{i}={\varvec{o}}\)

Recalling (41), the parameterization of the ith edge becomes

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)=\lambda _i{\varvec{\rho }}_{i+1} \end{aligned}$$
(93)

so that

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)\cdot {\varvec{\kappa }}_z=\lambda _i{\varvec{\rho }}_{i+1}\cdot {\varvec{\kappa }}_z=b_i\lambda _i \end{aligned}$$
(94)

and

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)\cdot {\varvec{\rho }}(\lambda _i)=\lambda _i^2{\varvec{\rho }}_{i+1}\cdot {\varvec{\rho }}_{i+1}=p_i\lambda _i^2 \end{aligned}$$
(95)

Accordingly, we get from (35) to (37)

$$\begin{aligned} d_{\varvec{\rho }}^{\partial _{i}\varOmega }= \frac{b_i}{p_i}\int \limits _{0}^1 \frac{\hbox {d}\lambda _i}{\lambda _i}= \frac{b_i}{p_i}\lim _{\varepsilon \rightarrow 0}[\hbox { log}\lambda _i]_\varepsilon ^1 \end{aligned},$$
(96)

which is singular at \(\lambda _i=0\), and

$$\begin{aligned} \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }= \frac{b_i}{p_i}{\varvec{\rho }}_{i+1}\qquad \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }=\frac{1}{2} \frac{b_i}{p_i}{\varvec{\rho }}_{i+1}\otimes {\varvec{\rho }}_{i+1}\qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }=\frac{1}{3}\frac{b_i}{p_i}{\varvec{\rho }}_{i+1}\otimes {\varvec{\rho }}_{i+1}\otimes {\varvec{\rho }}_{i+1} \end{aligned}$$
(97)

However, \(d_{\varvec{\rho }}^{\partial _{i}\varOmega }\) in formulas (40) and (68), and hence the logarithm in (96), is scaled by \({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp\). Setting \(\varepsilon =|{\varvec{\rho }}_{i}|\), we infer that

$$\begin{aligned} \lim _{\varepsilon \rightarrow 0}\left( {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \right) I_{0i}= \lim _{\varepsilon \rightarrow 0}\varepsilon \frac{b_i}{p_i}\hbox { log}\varepsilon =0 \end{aligned}$$
(98)

since the logarithm tends to infinite with an arbitrarily low degree. In addition, being \(\mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }\), \(\mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\) and \({{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }\) finite, we ultimately infer that the contribution of the ith edge to the expressions (56), (81), and (86) of the gravity anomaly is zero.

4.2 Simplification of the Line Integrals (35)–(37) to the Case \({\varvec{\rho }}_{i+1}={\varvec{o}}\)

In this case, the ith edge is parameterized in the form

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)=\eta _i{\varvec{\rho }}_{i}=(1-\lambda _i){\varvec{\rho }}_{i}\qquad 0\le \eta \le 1 \end{aligned}$$
(99)

Hence,

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)\cdot {\varvec{\kappa }}_z=\eta _i{\varvec{\rho }}_{i}\cdot {\varvec{\kappa }}_z=a_i\eta _i \end{aligned}$$
(100)

and

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)\cdot {\varvec{\rho }}(\lambda _i)=\eta _i^2{\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i}=u_i\eta _i^2 \end{aligned}$$
(101)

Being \(\hbox {d}\lambda _i=-\hbox {d}\eta _i,\) one has

$$\begin{aligned} d_{\varvec{\rho }}^{\partial _{i}\varOmega }&= - \frac{a_i}{u_i}\int \limits _{1}^0 \frac{\hbox {d}\eta _i}{\eta _i}= \frac{a_i}{u_i}\lim _{\varepsilon \rightarrow 0}[\hbox { log}\lambda _i]_\varepsilon ^1 \end{aligned}$$
(102)
$$\begin{aligned} \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }&= \frac{a_i}{u_i}{\varvec{\rho }}_{i}\qquad \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }=\frac{1}{2} \frac{a_i}{u_i}{\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }=\frac{1}{3}\frac{a_i}{u_i}{\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\end{aligned}$$
(103)

Hence, we can repeat the considerations developed in the previous subsection, by exchanging the role of \({\varvec{\rho }}_{i}\) and \({\varvec{\rho }}_{i+1}\), and conclude that the contribution of the ith edge to the expressions (56), (81), and (86) of the gravity anomaly vanishes.

4.3 Simplification of the Line Integrals (35)–(37) to the Case \({\varvec{\rho }}_{i}\Vert {\varvec{\rho }}_{i+1}\)

In this case, we can set \({\varvec{\rho }}_{i+1}=\beta _i{\varvec{\rho }}_{i}\) with \(0 < \beta _i= |{\varvec{\rho }}_{i+1}|/|{\varvec{\rho }}_{i}|\) and parameterize the ith edge as

$$\begin{aligned} {\varvec{\rho }}[\lambda _i(\xi _i)]=\xi _i{\varvec{\rho }}_{i} \end{aligned}$$
(104)

where

$$\begin{aligned} \xi _i=1+\lambda _i(\beta _i-1)\qquad 1\le \xi _i\le \beta _i, \end{aligned}$$
(105)

and it has been assumed \(\beta _i>1\). As it will be apparent in the sequel, the case \(\beta _i<1\) does not modify the final result. Being also

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)\cdot {\varvec{\kappa }}_z=\xi _i{\varvec{\rho }}_{i}\cdot {\varvec{\kappa }}_z=a_i\xi _i \end{aligned}$$
(106)

and

$$\begin{aligned} {\varvec{\rho }}(\lambda _i)\cdot {\varvec{\rho }}(\lambda _i)=p_i\xi _i^2 \end{aligned}$$
(107)

and \(\hbox {d}\xi _i=\hbox {d}\lambda _i(\beta _i - 1),\) we now have

$$\begin{aligned} d_{\varvec{\rho }}^{\partial _{i}\varOmega }&= \frac{a_i}{p_i(\beta _i - 1)}\int \limits _{1}^{\beta _i} \frac{\hbox {d}\xi _i}{\xi _i}= \frac{a_i}{p_i}\frac{\hbox { log}\beta _i}{\beta _i - 1} \end{aligned}$$
(108)
$$\begin{aligned} \mathbf{d}_{\varvec{\rho }}^{\partial _{i}\varOmega }&= \frac{a_i}{p_i}{\varvec{\rho }}_{i}\qquad \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }= \frac{1}{2}\frac{a_i}{p_i}(\beta _i + 1){\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\partial _{i}\varOmega }=\frac{1}{3}\frac{a_i}{p_i}\frac{\beta _i^3 - 1}{\beta _i - 1}{\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i}\otimes {\varvec{\rho }}_{i} \end{aligned}$$
(109)

The four integrals above are well defined but are scaled by the quantity \({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp,\) which is zero by hypothesis. Hence, recalling formulas (40) and (68), the ith edge does not give any contribution to the sum in (56), (81), and (86). In conclusion, it has been proved that, whenever \({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp =0\), which is equivalent to state \({\varvec{\rho }}_{i}=0\) or \({\varvec{\rho }}_{i+1}=0\) or \({\varvec{\rho }}_{i}\Vert {\varvec{\rho }}_{i+1}\), the computation of the ith addend of the sum in (56), (81), and (86) can be skipped. Clearly, from the numerical point of view, the analytical condition \({\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp =0\) is replaced by \(\Vert {\varvec{\rho }}_{i}\cdot {\varvec{\rho }}_{i+1}^\perp \Vert \le \hbox{tol}\) where tol is a machine-dependent numerical tolerance (Table 1).

Table 1 Numerical values of the gravity anomaly (mGal) in Fig. 4: (a) computed in this paper (CT = 0.07923 s), (b) derived from the diagram in Zhang et al. (2001)

5 Numerical Examples

The formulas illustrated in the previous sections have been coded in a MATLAB program in order to check their correctness and robustness. They have been applied to model tests and case studies derived from the specialized literature. In particular, the density contrast has been assumed to vary separately along the horizontal and the vertical directions or along both of them. In all examples, the density contrast is expressed in units grams per cubic centimeter while distances are expressed in kilometers; the value of the gravitational constant \(G\) is 6.67259 × \(10^{-11}\) m\(^{3}\) kg\(^{-1}\) s\(^{-2}\).

For all the examples, we include a graphical and a tabular comparison between our results and those already published in the literature, although these last ones have been inferred, to the best of the author’s expertise, from the diagrams in which they have been originally reported. We also include the computing time (CT) obtained by running the MATLAB code on a INTEL CORE2 PC with 16 Gb of RAM and a i7-4700HQ CPU having clock speed of 2.40 GHz. They can be useful to allow for a comparison with computations carried out by using different methods or with more complex modellings, e.g., those required to evaluate the gravitational effects of an arbitrary volumetric mass layer in which a laterally varying radial density change has been assumed (Tenzer et al. 2012a, b, c).

The model test in Fig. 3 is a 2D rectangular cylinder at a depth of 1 km, 6 km wide, and 1 km high; it has been first considered by Rao (1986), and subsequently by Zhang et al. (2001), by assuming a density contrast given by

$$\begin{aligned} \theta (z) = 1.54 + 0.24z - 0.035z^2 \end{aligned}$$
(110)

Figure 4 shows a perfect agreement between the solid line, representing jointly the results by Rao (1986) and Zhang et al. (2001), and the dotted line that has been computed by means of the proposed approach. Each point in the figure represents the gravity anomaly associated with a position of the observation point having as coordinates \(z=0\) and an abscissa \(x\) equal to that of the plotted point.

Fig. 3
figure 3

2D rectangular domain, derived from Rao (1986), with density contrast given by (110)

Fig. 4
figure 4

Comparison between the results of the present approach and those in Zhang et al. (2001) for the domain in Fig. 3

The second example, shown in Fig. 5, has been first addressed by García-Abdeslem et al. (2005b) and later considered in Zhou (2008). It refers to the Sebastián Vizcaíno Basin in Mexico for which the density contrast has been assumed in the form

$$\begin{aligned} \theta (z) = -0.7 + 2.548 \times 10^{-4}z - 2.73 \times 10^{-8}z^2 \end{aligned}$$
(111)

where \(z\) is expressed in meters. The gravity anomaly along a transect on the x-axis is shown in Fig. 6 and successfully compared with that computed in Zhou (2008) by two distinct methodologies named LI with arctangent kernel and density integrated LI. In both methodologies, Zhou evaluated the resulting integrals by the Gauss–Legendre quadrature method (Table 2).

Fig. 5
figure 5

Domain derived from García-Abdeslem et al. (2005b) with density contrast given by (111)

Fig. 6
figure 6

Comparison between the results of the present approach and those in Zhou (2008) for the domain in Fig. 5

Table 2 Numerical values of the gravity anomaly (mGal) in Fig. 6: (a) computed in this paper (CT = 0.07081 s), (b) derived from the diagram in Zhou (2008)

Figure 7 illustrates an elongated segment valley first considered by Murthy and Rao (1979) and later analyzed by Zhang et al. (2001). The density contrast is given by

$$\begin{aligned} \theta (z) = -0.55 + 2 \times 10^{-4}z \end{aligned}$$
(112)

where \(z\) is expressed in meters. Figure 8 shows the comparison of the gravity anomaly computed by different procedures, i.e., the one presented in Zhang et al. (2001), the two methodologies quoted above by Zhou (2008) and that contributed in the present paper (Table 3).

Fig. 7
figure 7

Domain derived from Murthy and Rao (1979) with density contrast given by (112)

Fig. 8
figure 8

Comparison between the results of the present approach and those in Zhang et al. (2001) and Zhou (2008) for the domain in Fig. 7

Table 3 Numerical values of the gravity anomaly (mGal) in Fig. 8: (a) computed in this paper (CT = 0.04594 s), (b) derived from the diagram in Zhou (2008), (c) derived from the diagram in Zhang et al. (2001)

Figure 9 illustrates a case analyzed by Martín-Atienza and García-Abdeslem (1999), Zhou (2009a, 2010) in which the density contrast varies only along the horizontal position

$$\begin{aligned} \theta (z) = 0.5 + 2 \times 10^{-5}x - 2 \times 10^{-8} x^2 \end{aligned}$$
(113)

The gravity anomaly, calculated along a transect on the x-axis, is shown in Fig. 10 where our results are compared with those obtained by Zhou (2010). These last results had been previously compared by Zhou with those based on the LI method with logarithmic kernel, previously contributed in Zhou (2009a), and the original results by Martín-Atienza and García-Abdeslem (1999) (Table 4).

Fig. 9
figure 9

Domain derived from Martín-Atienza and García-Abdeslem (1999) with density contrast given by (113)

Fig. 10
figure 10

Comparison between the results of the present approach and those in Zhou (2010) for the domain in Fig. 9

Table 4 Numerical values of the gravity anomaly (mGal) in Fig. 10: (a) computed in this paper (CT = 0.05527s), (b) derived from the diagram in Zhou (2010)

The last numerical example, shown in Fig. 11, refers to a case first studied by Martín-Atienza and García-Abdeslem (1999) and later re-examined in Zhou (2009a). The geometry in Fig. 11 refers to folded and overturned strata in a sedimentary basin in which the density contrast varies simultaneously along the horizontal and vertical directions

$$\begin{aligned} \theta (x,z) = -0.7 - 5 \times 10^{-8}xz + 4 \times 10^{-8}x^2 + 6 \times 10^{-8}z^2 \end{aligned}$$
(114)

The boundary of the body has been approximated by a 26-sided polygon, and the gravity anomaly has been computed at 41 stations. The high number of polygon vertices and the more complex density contrast function explain the computing time of 0.32681 s which is considerably higher than those experienced in previous examples. Figure 12 superimposes our results with those obtained by Martín-Atienza and García-Abdeslem (1999), the seminumerical LI method by Zhou (2009a), and the analytical method in Zhou (2010) (Table 5).

Table 5 Numerical values of the gravity anomaly (mGal) in Fig. 12: (a) computed in this paper (CT = 0.32681 s), (b) derived from the diagram in Zhou (2010)
Fig. 11
figure 11

Domain derived from Martín-Atienza and García-Abdeslem (1999) with density contrast given by (114)

Fig. 12
figure 12

Comparison between the results of the present approach and those in Zhou (2010) for the domain in Fig. 11

5.1 Error Analysis

It is interesting to consider the susceptibility of the formulas derived in the paper to numerical rounding error. As shown in Holstein and Ketteridge (1996), this depends on the target aspect ratio \(\gamma =\alpha /\delta\) where \(\alpha\) is the typical linear dimension of the target and \(\delta\) its typical distance from the observation point. For 2D bodies, the anomaly calculation (6) is governed by an area integral weighted by the density contrast, the vertical component of the position vector, proportional to \(\delta\), and the inverse square law factor, proportional to \(1/\delta ^2\).

The density contrast functions considered in the previous examples show that \(\theta ({\varvec{\rho }})\) is obtained as the sum of separate terms having substantially the same order of magnitude as the constant term \(\theta _{\varvec{o}}\). Nevertheless one has to consider separately the integrals (17) and (18), and compute their one-dimensional counterparts (28) and (29).

In particular, we have

$$\begin{aligned} d_{\varvec{\rho }}^{\varOmega }\approx O (\alpha )=O(\delta \gamma ) \qquad \mathbf{d}_{\varvec{\rho }}^{\varOmega }\approx O (\delta \alpha )=O(\delta ^2\gamma ) \end{aligned}$$
(115)

and

$$\begin{aligned} \mathbf{D}_{{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }\approx O (\delta ^2\alpha )=O(\delta ^3\gamma ) \qquad {{\varvec{{\mathbb {D}}}}}_{{\varvec{\rho }}{\varvec{\rho }}{\varvec{\rho }}}^{\varOmega }\approx O (\delta ^3\alpha )=O(\delta ^4\gamma ) \end{aligned}$$
(116)

where \(\approx\) means “has order of magnitude equal to.”

Thus, when computed in a finite floating point precision \(\epsilon\), the rounding error \(O(\delta ^k\gamma \epsilon ),k=1,\ldots 4\), progressively increases as the target distance \(\delta\) increases relative to the target size \(\alpha\). However, as shown in the previous figures, this is generally beyond the region of geophysical interest.

As a final remark, it is worth mentioning that higher-order terms in the density contrast, though more prone to computational noise as \(\delta\) increases, provide a progressively lower contribution to the gravity anomaly. This is in accordance with the significance of higher-order density polynomials in 2D modelling. As a matter of fact, geological settings require mostly 3D gravity modelling: the errors caused by 2D gravity modelling with high-order polynomials will often be larger than the errors caused by piecewise constant densities in a relative few number of 3D polygonal bodies.

6 Conclusions

The gravity anomaly at arbitrary points produced by a 2D body whose shape is an arbitrary polygon and where density contrast varies with a polynomial law has been obtained in closed form. It is expressed as a sum of quantities that depend only upon the coordinates of the vertices of the polygon and upon the parameters that define the density contrast. The solution procedure, based upon a generalized application of Gauss theorem, takes consistently into account the singularity intrinsic to the integrals to evaluate. Accordingly, by means of rigorous mathematical arguments, singularities are proved to give no contribution either to the analytical expression of the gravity anomaly or to its algebraic counterpart.

The formulation presented in the paper, which has been limited to polynomial density contrasts varying with a cubic law as a maximum, can be easily extended to polynomials of higher degree. The effectiveness of the proposed approach has been intensively tested by numerical comparisons, carried out by means of a MATLAB code, with several examples derived from the specialized literature. Future contributions will concern the cases of density contrast variable with exponential law for 2D domains and 3D polyhedral bodies endowed with polynomial or exponential density contrasts.