1 Introduction

1.1 Background

A lattice point \((m,n)\in {\mathbb {N}}\times {\mathbb {N}}\) is said to be visible to the lattice point \((u,v)\in {\mathbb {N}}\times {\mathbb {N}}\) along lines if there are no other integer lattice points on the straight line segment joining (mn) and (uv). In 1883, it was showed by Sylvester [15] that the proportion of lattice points that are visible to the origin (0, 0) is \(1/\zeta (2)=6/\pi ^2\approx 0.60793\), where \(\zeta (s)\) is the Riemann zeta function. Since then, the study of the distribution of visible lattice points continues to intrigue mathematicians till now. For example, one may refer to Adhikari and Granville [1], Baker [2], Boca et al. [4], Chaubey et al. [5], Chen [6], Huxley and Nowak [10] for part of related works and some generalizations in recent years.

In 2018, Goins et al. [7] considered the integer lattice points in the plane which are visible to the origin (0, 0) along curves \(y=r x^k\) with \(k\in {\mathbb {N}}\) fixed and some \(r\in \mathbb {Q}\). They showed that the proportion of such integer lattice points is \(1/\zeta (k+1)\). In the same year, Harris and Omar [8] further considered the case of rational exponent k. Recently, Benedetti et al. [3] studied the proportion of visible lattice points to the origin along such curves in higher dimensional space.

All the above results are concerned about the lattice points visible to only one base point. It is natural to consider the distribution of lattice points which are visible to more base points simultaneously. For the case of visibility along straight lines, the earliest work originates from Rearick in 1960s. In his Ph.D. thesis, Rearick [13] first showed that the density of integer lattice points in the plane which are jointly visible along straight lines to N (\(N=2\) or 3) base points is \(\prod _p\left( 1-N/p^2\right) \), where the base points are mutually visible in pairs and the product is over all the primes. Then in [14], he generalized this result to lattice points in higher dimensional space and larger N.

The joint visibility of lattice points along curves has not been considered yet. In this paper, we focus on this topic and we also propose the concept of level of visibility. Level-1 visibility matches the definition of “k-visible” in [7]. We use higher level of visibility to analyze more carefully about the “invisible” points along certain curves. We give asymptotic formulas for the number of lattice points which are visible to a set of N base points along certain curves in different levels of visibility.

1.2 Our results

For any positive integer k and integer lattice points \((u,v),(m,n)\in {\mathbb {N}}\times {\mathbb {N}}\), let \(r\in \mathbb {Q}\) be given by \(n-v=r(m-u)^k\) and \({\mathcal {C}}\) be the curve \(y-v=r(x-u)^k\). If there is no integer lattice points lying on the segment of \({\mathcal {C}}\) between points (mn) and (uv), we say (mn) is (Level-1) k -visible to (uv). Further, if there is at most one integer lattice points lying on the segment of \({\mathcal {C}}\) between points (mn) and (uv), we say point (mn) is Level-2 k -visible to (uv).

One can see that k-visibility is mutual. Precisely, if a point (mn) is Level-1 or Level-2 k-visible to the point (uv) along the curve \(y-v=r(x-u)^k\), then (uv) is also Level-1 or Level-2 k-visible to (mn), respectively, along the curve \(y-n=(-1)^{k+1}r(x-m)^k\).

Throughout this paper, we always assume \({\varvec{S}}\) is a given set of integer lattice points in the plane. We say an integer lattice point (mn) is Level-1 k-visible to \({\varvec{S}}\) if it belongs to the set

$$\begin{aligned} {\varvec{V}}_k^1({\varvec{S}}):=\{(m,n)\in \mathbb {N}\times \mathbb {N}: (m,n) ~\text {is}~k\text {-visible to every point in}~ {\varvec{S}} \}. \end{aligned}$$

Similarly, we say a point \((m,n)\in \mathbb {N}\times \mathbb {N}\) is Level-2 k-visible to \({\varvec{S}}\) if it belongs to the set

$$\begin{aligned} {\varvec{V}}_k^2({\varvec{S}}):=\{(m,n)\in \mathbb {N}\times \mathbb {N}: (m,n) ~\text {is Level-2}~k\text {-visible to every point in}~ {\varvec{S}} \}. \end{aligned}$$

One may define higher Level k-visible points to \({\varvec{S}}\) this way. But in this paper, we focus on Level-1 and Level-2 k-visible points.

For \(x\ge 2\), we consider visible lattice points along curves in the square \([1,x]\times [1,x]\). Denote

$$\begin{aligned} N^1_k({\varvec{S}},x)&:=\#\{(m,n)\in {\varvec{V}}_k^1({\varvec{S}}): m,n\le x\}, \end{aligned}$$

and

$$\begin{aligned} N^2_k({\varvec{S}},x)&:=\#\{(m,n)\in {\varvec{V}}_k^2({\varvec{S}}): m,n\le x\}. \end{aligned}$$

An important case is that the points of \({\varvec{S}}\) are pairwise k-visible to each other. The cardinality of such \({\varvec{S}}\) can’t be too large. In fact, we have \(\#{\varvec{S}}\le 2^{k+1}\) by Proposition 2.1 in the next section. For such type of \({\varvec{S}}\), we obtain the following asymptotic formulas for \(N^1_k({\varvec{S}},x)\) and \(N_k^2({\varvec{S}},x)\).

Theorem 1.1

Assume the elements of \({\varvec{S}}\) are pairwise k-visible to each other and \(N=\#{\varvec{S}}< 2^{k+1}\). For any \(k\ge 2\), we have

$$\begin{aligned} N^1_k({\varvec{S}}, x)=x^2\prod _p \Bigg (1-\frac{N}{p^{k+1}} \Bigg )+E_1(x), \end{aligned}$$
(1.1)

where p runs over all primes, and

$$\begin{aligned} E_1(x)={\left\{ \begin{array}{ll} O_k(x\log ^N x),&{} \text {if}~1\le N\le k;\\ O_{k,\varepsilon }(x^{2-\frac{2k}{N+k}+\varepsilon }), &{}\text {if}~k<N<2^{k+1}. \end{array}\right. } \end{aligned}$$

Remark 1

If \(N=\#{\varvec{S}}=2^{k+1}\), by Proposition  2.1, there is no lattice point outside \({\varvec{S}}\) which is (Level-1) k-visible to all elements of \({\varvec{S}}\).

By the above Theorem, the density of (Level-1) k-visible points to every elements of \({\varvec{S}}\) is \(\prod _p \left( 1-N/p^{k+1}\right) \). For \(k=1\), it is done by the work in [14], where the author studied the visible points along straight lines. The special case \(N=1\) for \(k\ge 2\) in Theorem 1.1 covers the result in [7], where only the main term was given.

We also give asymptotic formulas for Level-2 k-visible points. Note that such set actually includes some “invisible” points in the definition of previous research. We are able to analyze more carefully about these “invisible” points.

Theorem 1.2

Assume the elements of \({\varvec{S}}\) are pairwise k-visible to each other and \(N=\#{\varvec{S}}\le 2^{k+1}\). For any \(k\ge 1\), we have

$$\begin{aligned} N_k^2({\varvec{S}}, x)= N_k^1({\varvec{S}}, x)+x^2 \frac{N}{2^{k+1}}\left( 1-\frac{1}{2^{k+1}}\right) \prod _{p>2~\mathrm{prime}} \bigg ( 1-\frac{N}{p^{k+1}}\bigg )+E_2(x), \end{aligned}$$
(1.2)

where

$$\begin{aligned} E_2(x)={\left\{ \begin{array}{ll} O_k(x\log ^N x)&{} \text {if}~1\le N\le k;\\ O_{k,\varepsilon }(x^{2-\frac{2k}{N+k}+\varepsilon }) &{}\text {if}~k<N\le 2^{k+1}. \end{array}\right. } \end{aligned}$$

Remark 2

Note that when \(N=2^{k+1}\), \(N_k^1({\varvec{S}}, x)=0\), there is no Level-1 k-visible points to \({\varvec{S}}\). But there are still positive proportion of lattice points in the plane which are Level-2 k-visible to \({\varvec{S}}\).

For the special case \(N=1\) and \(k=1\), our problem is the same as the so-called “primitive lattice problem” inside a square. Nowak [12], Zhai [17] and Wu [16] have studied the number of primitive lattice points inside a circle. Primitive lattice points in general planar domains have also been studied by Hensley [9], Huxley and Nowak [10] and Baker [2] etc. Assuming the Riemann hypothesis(RH), they continuously improved the error term of the concerned asymptotic formulas by estimating certain exponential sums. One may wonder how much we can do to improve the estimates of \(E_1(x)\) and \(E_2(x)\) by similar argument under RH. However, we do not focus on pursuing the best possible error term in this paper.

Taking \({\varvec{S}}=\{ (0,0), (1,1)\}\), we did numerical calculations for densities of Level-1 and Level-2 k-visible points for \(x=10{,}000\) and \(k=2, 3, \ldots , 9\) (see Table 1 and Fig. 1). We see that the numerical results match the theoretical predictions very well.

Table 1 Densities of k-visible points to set of two elements
Fig. 1
figure 1

Densities of k-visible points to set of two elements

We also calculate the case when \({\varvec{S}}=\{ (0,0), (1,2), (2,1) \}\), and we get the following data for densities of Level-1 and Level-2 k-visible points to \({\varvec{S}}\) (see Table 2 and Fig. 2).

Table 2 Densities of k-visible points to set of three elements
Fig. 2
figure 2

Densities of k-visible points to set of three elements

Notations

We use \(\mathbb {Z}\) to denote the set of integers; \({\mathbb {N}}\) to denote the set of positive integers; \(\mathbb {Q}\) to denote the set of rational numbers; \(\# S\) to denote the cardinality of a set S. As usual, we use the expressions \(f=O(g)\) or \(f\ll g\) to mean \(|f|\le Cg\) for some constant \(C>0\). In the case when this constant \(C>0\) may depend on some parameters \(\rho \), we write \(f=O_\rho (g)\) or \(f\ll _\rho g\).

2 Preliminaries

We define the degree-k greatest common divisor of m, \(n\in \mathbb {Z}\) as

$$\begin{aligned} {\mathrm{gcd}_k }(m,n):=\max \{d\in \mathbb {N}: d\mid m,\ d^k\mid n \}. \end{aligned}$$

Proposition 2.1

For any integer \(k\ge 1\), assume any two distinct elements \((u_i, v_i)\), \((u_j, v_j)\in {\varvec{S}}\) are k-visible to each other, then we have \(\#{\varvec{S}}\le 2^{k+1}\).

Proof

To see this, we consider the map

$$\begin{aligned} \lambda : {\varvec{S}}\rightarrow \widetilde{{\varvec{S}}}:=\{ (u\bmod 2, v\bmod 2^{k}) : (u, v)\in {\varvec{S}} \}. \end{aligned}$$

The size of the image \(\widetilde{{\varvec{S}}}\) is at most \(2^{k+1}\). If \({\varvec{S}}\) has more than \(2^{k+1}\) points, there must be two distinct elements which map to the same element in \(\widetilde{{\varvec{S}}}\), say

$$\begin{aligned} \lambda ((u_1, v_1) )=\lambda ((u_2, v_2)). \end{aligned}$$

Thus we have

$$\begin{aligned} 2\mid (u_2-u_1) ~\text {and}~ 2^k\mid (v_2-v_1), \end{aligned}$$

and hence \({\mathrm{gcd}_k }(u_2-u_1, v_2-v_1)\ge 2\), which contradicts our assumption on \({\varvec{S}}\). \(\square \)

By the definition of k-visible points and elementary argument, we get the following lemma. One may refer to [7] (Proposition 3) for similar argument. Here we omit the proof.

Lemma 2.2

For any \(k\ge 1\), if \(m-u\ne 0\) and \(n-v\ne 0\), we have

  1. (i)

    Point (mn) is k-visible to point (uv) if and only if \({\mathrm{gcd}_k }(m-u,n-v)=1\).

  2. (ii)

    There exists exactly one integer point lying on the segment of the curve \(y-v=r(x-u)^k\) joining (uv) and (mn) for some \(r\in \mathbb {Q}\) if and only if \({\mathrm{gcd}_k }(m-u,n-v)=2\).

We also need the following well-known result for l-fold divisor function \(\tau _l(n)=\sum _{d_1\cdots d_l=n} 1\).

Lemma 2.3

([11], formula (1.80)) Let \(l\ge 2\) be an integer. For any \(x\ge 2\), we have

$$\begin{aligned} \sum \limits _{n\le x}\tau _l(n)\ll _{l} x\log ^{l-1} x. \end{aligned}$$

3 Proof of Theorem 1.1

Given a set \({\varvec{S}}\), if we shift \({\varvec{S}}\) such that it contains the origin, the error occurs to our counting function is \(O_{{\varvec{S}}}(x)\). Thus, we may assume \((0,0)\in {\varvec{S}}\). Denote the elements of \({\varvec{S}}\) as \((u_j, v_j),\ 0\le j\le N-1\) with \((u_0,v_0)=(0,0)\). By Proposition 2.1, the contribution of points (mn) with \(m=u_j\) or \(n=v_{j'}\) for some \(j, j'\) is \(O(|{\varvec{S}}|x)=O_k(x)\). Hence, we only need to estimate the contribution of points (mn) with \(m\ne u_j\) and \(n\ne v_{j'}\) for all \(0\le j, j'\le N-1\). Throughout all our proofs, we implicitly assume the input of \({\mathrm{gcd}_k }(*, *)\) has no zero coordinates unless otherwise specified.

By Lemma 2.2 we have

$$\begin{aligned} N^1_k({\varvec{S}}, x)&=\sum _{\begin{array}{c} m, n\le x\\ {\mathrm{gcd}_k }(m-u_j, n-v_j)=1\\ m\ne u_j, n\ne v_j\\ 0\le j\le N-1 \end{array}} 1+O_k(x)=: {\widetilde{N}}^1_k({\varvec{S}},x)+O_k(x). \end{aligned}$$

Applying the formula

$$\begin{aligned} \sum _{d|n}\mu (d)= {\left\{ \begin{array}{ll} 1\quad \mathrm{if}\ n=1;\\ 0\quad \mathrm{otherwise}, \end{array}\right. } \end{aligned}$$
(3.1)

where \(\mu \) is the Möbius function, we write

$$\begin{aligned} {\widetilde{N}}^1_k({\varvec{S}},x)=\sum _{m, n\le x}\sum \limits _{\begin{array}{c} d_j|\gcd _k(m-u_j,n-v_j)\\ 0\le j\le N-1 \end{array}}\mu (d_0)\cdots \mu (d_{N-1}). \end{aligned}$$
(3.2)

Let \(D>0\) be a parameter to be chosen later. Divide the sum over \(d_0,\cdots ,d_{N-1}\) into two parts: \(d_0\cdots d_{N-1}\le D\) and \(d_0\cdots d_{N-1}> D\), and denote their contributions to \({\widetilde{N}}^1_k({\varvec{S}},x)\) by \(\sum _{\le }\) and \(\sum _{>}\), respectively. Then we have

$$\begin{aligned} {\widetilde{N}}^1_k({\varvec{S}},x)={\sum }_{\le }+{\sum }_{>}. \end{aligned}$$
(3.3)

For \(\sum _{\le }\), we change the order of the summation and obtain

$$\begin{aligned} {\sum }_{\le }=\sum _{\begin{array}{c} d_0\cdots d_{N-1}\le D \end{array}}\mu (d_0)\cdots \mu (d_{N-1})\Bigg (\sum _{\begin{array}{c} m,n\le x\\ d_j\mid m-u_j,d_j^k\mid n-v_j\\ 0\le j\le N-1 \end{array}}1\Bigg ). \end{aligned}$$
(3.4)

Note that \((u_0,v_0)=(0,0)\), then for any given \(d_0\), \(\cdots \), \(d_{N-1}\), the inner sum over mn in the above formula actually equals

$$\begin{aligned} \Bigg (\sum _{\begin{array}{c} s\le x/d_0\\ sd_0\equiv u_j(\bmod d_j)\\ 1\le j\le N-1 \end{array}}1\Bigg )\Bigg (\sum _{\begin{array}{c} t\le x/d_0^k\\ td_0^k\equiv v_j(\bmod d_{j}^k)\\ 1\le j\le N-1 \end{array}}1\Bigg ). \end{aligned}$$

Since the points in \({\varvec{S}}\) are mutually k-visible, then by Lemma 2.2 we have

$$\begin{aligned} {\mathrm{gcd}_k }(u_l-u_j, v_l-v_j)=1\quad \text {for}\ (u_l, v_l), (u_j, v_j)\in {\varvec{S}},\quad 0\le j\ne l\le N-1. \end{aligned}$$

This implies

$$\begin{aligned} \gcd (d_j, d_l)=1 \quad \text {for}\ 0\le j\ne l\le N-1. \end{aligned}$$

It then follows that

$$\begin{aligned} {\sum }_{\le }&=\sum _{\begin{array}{c} d_0\cdots d_{N-1}\le D\\ \gcd (d_j, d_l)=1, ~\forall \ 0\le j\ne l\le N-1 \end{array}}\mu (d_0)\cdots \mu (d_{N-1})\\&\quad \times \left( \frac{x}{d_0\cdots d_{N-1}}+O(1)\right) \left( \frac{x}{d_0^k\cdots d_{N-1}^k}+O(1)\right) . \end{aligned}$$

Then by Lemma 2.3 we obtain

$$\begin{aligned} {\sum }_{\le }&=x^2\sum _{\begin{array}{c} d_0\cdots d_{N-1}\le D\\ \gcd (d_j, d_l)=1, ~\forall \ 0\le j\ne l\le N-1 \end{array}}\frac{\mu (d_0)\cdots \mu (d_{N-1})}{d_0^{k+1}\cdots d_{N-1}^{k+1}}\nonumber \\&\quad +O\Bigg (x\sum _{d_0\cdots d_{N-1}\le D} \frac{1}{d_0\cdots d_{N-1}} \Bigg )\nonumber \\&\quad +O\Bigg (x\sum _{d_0\cdots d_{N-1}\le D} \frac{1}{d_0^k\cdots d^k_{N-1}} \Bigg )+O\Bigg ( \sum _{d_0\cdots d_{N-1}\le D} 1 \Bigg ) \nonumber \\&= x^2\sum _{\begin{array}{c} d_0\cdots d_{N-1}\le D\\ \gcd (d_j, d_l)=1, ~\forall \ 0\le j\ne l\le N-1 \end{array}}\frac{\mu (d_0)\cdots \mu (d_{N-1})}{d_0^{k+1}\cdots d_{N-1}^{k+1}}\nonumber \\&\quad + O_k\Big (D\log ^{N-1}D+x\log ^{N}D\Big ). \end{aligned}$$
(3.5)

Writing \(n=d_0\cdots d_{N-1}\), we then have

$$\begin{aligned} {\sum }_{\le }=x^2\sum _{n\le D}\frac{\mu (n)\tau _{N}(n)}{n^{k+1}}+O_k(D\log ^{N-1}D+x\log ^N D). \end{aligned}$$

Using Lemma 2.3, we obtain

$$\begin{aligned} {\sum }_{\le }=x^2\sum _{n=1}^{\infty }\frac{\mu (n)\tau _{N}(n)}{n^{k+1}}+O_k \big ({x^2D^{-k}\log ^{N-1} D}+D\log ^{N-1}D+x\log ^N D\big ). \end{aligned}$$
(3.6)
  1. (i)

    If \(1\le N\le k\), then we choose \(D=x\). In this case, since each \(d_j\le x^{1/k}\), \(d_0\cdots d_{N-1}\le x^{N/k}\le x\). Thus the second sum \(\sum _{>}\) in (3.3) is empty since we already exclude zero inputs of \({\mathrm{gcd}_k }(*,*)\) in the beginning of the proof. Inserting (3.6) into (3.3) yields (1.1) in Theorem 1.1 with

    $$\begin{aligned} E_1(x)\ll _k x\log ^{N}x ~\text {for}~1\le N\le k. \end{aligned}$$
  2. (ii)

    If \(k<N<2^{k+1}\), we need to make another choice for D, and deal with \({\sum }_{>}\) more carefully. Taking absolute value of \(\mu (d)\), we obtain

    $$\begin{aligned} {\sum }_{>}=\sum _{m, n\le x}\sum \limits _{\begin{array}{c} d_0\cdots d_{N-1}>D\\ d_j|\gcd _k(m-u_j,n-v_j)\\ 0\le j\le N-1 \end{array}}\mu (d_0)\cdots \mu (d_{N-1})\ll \sum _{m, n\le x}\sum \limits _{\begin{array}{c} d_0\cdots d_{N-1}>D\\ d_j|\gcd _k(m-u_j,n-v_j)\\ 0\le j\le N-1 \end{array}}1, \end{aligned}$$

    which implies

    $$\begin{aligned} {\sum }_{>}\ll \sum _{\begin{array}{c} m, n\le x\\ \prod \limits _{0\le j\le N-1}\gcd _{k}(m-u_j,n-v_j)>D \end{array}}&\tau \big ({\mathrm{gcd}_k }(m-u_0,n-v_0)\big )\cdots \\&\tau \big ({\mathrm{gcd}_k }(m-u_{N-1},n-v_{N-1})\big ) \end{aligned}$$

    Using the bounds \(\tau (n)\ll _{\varepsilon }n^{\varepsilon }\) for any \(\varepsilon >0\), \(N<2^{k+1}\) and \({\mathrm{gcd}_k }(m-u_j, n-v_j)\le x^{1/k}\), we have

    $$\begin{aligned} {\sum }_{>}\ll _{k, \varepsilon } x^{\varepsilon }\sum _{\begin{array}{c} m, n\le x\\ \prod \limits _{0\le j\le N-1}{\mathrm{gcd}_k }(m-u_j,n-v_j)>D \end{array}}1. \end{aligned}$$

    Since \(\prod \limits _{0\le j\le N-1}\gcd _{k}(m-u_j,n-v_j)>D\) implies \({\mathrm{gcd}_k }(m-u_{j^*},n-v_{j^*})>D^{1/N}\) for some \(j^*\in \{0,\cdots ,N-1\}\), we obtain

    $$\begin{aligned} {\sum }_{>}\ll _{k, \varepsilon } x^{\varepsilon }\sum \limits _{0\le j\le N-1}\sum _{\begin{array}{c} m, n\le x\\ {\mathrm{gcd}_k }(m-u_j,n-v_j)>D^{1/N} \end{array}}1. \end{aligned}$$

    By the definition of \({\mathrm{gcd}_k }\), we have

    $$\begin{aligned} {\sum }_{>}\ll _{k, \varepsilon } x^{\varepsilon }\sum \limits _{0\le j\le N-1}\sum \limits _{D^{1/N}<d\le x^{1/k}}\sum _{\begin{array}{c} m, n\le x\\ d\mid m-u_j\\ d^k\mid n-v_j \end{array}}1. \end{aligned}$$

    It follows that

    $$\begin{aligned} {\sum }_{>}\ll _{k, \varepsilon } x^{2+\varepsilon }\sum \limits _{0\le j\le N-1}\sum \limits _{D^{1/N}<d\le x^{1/k}}\frac{1}{d^{1+k}}\ll _{k, \epsilon } x^{2+\varepsilon }D^{-k/N}. \end{aligned}$$
    (3.7)

    Collecting all the above gives

    $$\begin{aligned} N^1_k({\varvec{S}}, x)=x^2\prod _p \Bigg (1-\frac{N}{p^{k+1}} \Bigg )+O_{k,\epsilon }\big (D\log ^{N-1}D+x^{2+\varepsilon }D^{-k/N}+x\log ^N x\big ). \end{aligned}$$

    Taking \(D=x^{\frac{2N}{N+k}}\) yields (1.1) with

    $$\begin{aligned} E_{1}(x)\ll _{k, \epsilon } x^{2-\frac{2k}{N+k}+\varepsilon } ~\text {for}~k<N<2^{k+1}. \end{aligned}$$

4 Proof of Theorem 1.2

In this section, we also assume \({\mathrm{gcd}_k }(*,*)\) does not take any input with zero coordinates.

If elements of \({\varvec{S}}\) are pairwise k-visible to each other, then for any \((m,n)\in {\varvec{V}}_k^2({\varvec{S}})\), there exists at most one \((u,v)\in {\varvec{S}}\) such that \({\mathrm{gcd}_k }(m-u, n-v)=2\). Indeed, suppose \({\mathrm{gcd}_k }(m-u_1, n-v_1)={\mathrm{gcd}_k }(m-u_2, n-v_2)=2\) for some \((u_1, v_1)\ne (u_2, v_2)\in {\varvec{S}}\), then we have

$$\begin{aligned} 2|(m-u_1), ~2|(m-u_2), ~2^k|(n-v_1), ~2^k|(n-v_2). \end{aligned}$$

Thus, \(2|(u_2-u_1)\) and \(2^k|(v_2-v_1)\), which contradicts the assumption \({\mathrm{gcd}_k }(u_2-u_1, v_2-v_1)=1\).

By the above argument, we write

$$\begin{aligned} N_k^2({\varvec{S}}, x)=N_k^1({\varvec{S}}, x)+\sum _{0\le l\le N-1}\sum _{\begin{array}{c} m, n\le x\\ {\mathrm{gcd}_k }(m-u_l, n-v_l)=2\\ {\mathrm{gcd}_k }(m-u_j, n-v_j)=1\\ j\ne l \end{array}}1+O_k(x). \end{aligned}$$
(4.1)

Without loss of generality, we may assume \((u_0, v_0)=(0,0)\). We only need to estimate the inner sum of the second term in (4.1) for \(l=0\), other cases are similar. Denote

$$\begin{aligned} I(x):=\sum _{\begin{array}{c} m, n\le x\\ {\mathrm{gcd}_k }(m, n)=2\\ {\mathrm{gcd}_k }(m-u_j, n-v_j)=1\\ 1\le j\le N-1 \end{array} } 1. \end{aligned}$$

We have

$$\begin{aligned} I(x)=\sum _{\begin{array}{c} m, n\le x\\ 2\mid m,2^k\mid n\\ {\mathrm{gcd}_k }(m/2, n/2^{k})=1\\ {\mathrm{gcd}_k }(m-u_j, n-v_j)=1\\ 1\le j\le N-1 \end{array} } 1=\sum _{\begin{array}{c} m,n\le x\\ 2\mid m,2^k\mid n \end{array}}\sum _{\begin{array}{c} d_0\mid {\mathrm{gcd}_k }(m/2, n/2^k)\\ d_j\mid {\mathrm{gcd}_k }(m-u_j, n-v_j)\\ 1\le j\le N-1 \end{array}} \mu (d_0)\cdots \mu (d_{N-1}). \end{aligned}$$
(4.2)

By changing the order of summation and making the substitutions \(m=2d_0s\) and \(n=(2d_0)^kt\), we obtain

$$\begin{aligned} I(x)=\sum _{d_0, \cdots , d_{N-1}\le x^{1/k}}\mu (d_0)\cdots \mu (d_{N-1})\sum _{\begin{array}{c} s\le x/(2d_0), t\le x/(2d_0)^k\\ 2d_0 s\equiv u_j(\bmod d_j) \\ (2d_0)^k t\equiv v_j(\bmod d_j^k) \\ 1\le j\le N-1 \end{array} }1. \end{aligned}$$
(4.3)

In order to get estimates of I(x), we need to analyze the conditions in the inner sum. Fix \(d_0, \cdots , d_{N-1}\), in order for those congruence equations having solutions, we need

$$\begin{aligned} \gcd (2d_0, d_j)\mid u_j, ~\gcd ((2d_0)^k, d_j^k)\mid v_j \end{aligned}$$

for \(1\le j\le N-1\). Since points \((u_j,v_j)\) are k-visible to point \((u_0,v_0)\), then Lemma 2.2 gives \({\mathrm{gcd}_k }(u_j, v_j)=1\). It follows that \( \gcd (2d_0, d_j)=1\) for \(1\le j\le N-1\). Moreover, in order for those congruence equations having solutions, we also need the following equations

$$\begin{aligned} d_{j_1}l_{1}-d_{j_2}l_{2}= u_{j_2}-u_{j_1}, ~d^k_{j_1}t_{1}-d^k_{j_2}t_{2}= v_{j_2}-v_{j_1} \end{aligned}$$

have solutions for any \(d_{j_1}\) and \(d_{j_2}\) with \(1\le j_1\ne j_2\le N-1\). This implies

$$\begin{aligned} \gcd (d_{j_1},d_{j_2})\mid u_{j_2}-u_{j_1},\ \gcd (d_{j_1}^k,d_{j_2}^k)\mid v_{j_2}-v_{j_1} \end{aligned}$$

for \(1\le j_1\ne j_2\le N-1\). By the assumption of pairwise k-visibility of elements of \({\varvec{S}}\), we have \({\mathrm{gcd}_k }(u_{j_2}-u_{j_1}, v_{j_2}-v_{j_1})=1\), and thus \(\gcd (d_{j_1}, d_{j_2})=1\) for any \(1\le j_1\ne j_2\le N-1\).

As what we did in Sect. 3, we divide the sum over \(d_0,\cdots ,d_{N-1}\) into two parts according to \(d_0\cdots d_{N-1}\le D\) or not. Denote them by \(I_{\le }\) and \(I_{>}\), respectively, then

$$\begin{aligned} I(x)=I_{\le }+I_{>}. \end{aligned}$$
(4.4)

For \(I_{\le }\), we have

$$\begin{aligned} I_{\le }= & {} \sum _{\begin{array}{c} d_0\cdots d_{N-1}\le D\\ \gcd (d_{j_1}, d_{j_2})=1, \forall j_1\ne j_2\\ \gcd (2, d_j)=1, 1\le j\le N-1 \end{array}} \mu (d_0)\cdots \mu (d_{N-1})\left( \frac{x}{2d_0\cdots d_{N-1}}+O(1)\right) \\&\quad \times \left( \frac{x}{2^kd_0^k\cdots d_{N-1}^k}+O(1)\right) , \end{aligned}$$

and by Lemma 2.3, we get

$$\begin{aligned} I_{\le }=\frac{x^2}{2^{k+1}} \sum _{\begin{array}{c} d_0\cdots d_{N-1}\le D\\ \gcd (d_{j_1}, d_{j_2})=1,\forall j_1\ne j_2\\ \gcd (2, d_j)=1, 1\le j\le N-1 \end{array}}\frac{\mu (d_0)\cdots \mu (d_{N-1})}{d_0^{k+1}\cdots d_{N-1}^{k+1}}+O_k\left( x\log ^N x+D\log ^{N-1} D\right) . \end{aligned}$$

Making the substitution \(n=d_0\cdots d_{N-1}\), we obtain

$$\begin{aligned} I_{\le }=\frac{x^2}{2^{k+1}} \sum _{n\le D} \frac{\mu (n)}{n^{k+1}}h(n)+O_k\left( x\log ^N x+D\log ^{N-1} D\right) . \end{aligned}$$

where

$$\begin{aligned} h(n)=\sum \limits _{\begin{array}{c} n=d_0\cdots d_{N-1}\\ d_1,\cdots , d_{N-1} ~\text {odd} \end{array}} 1. \end{aligned}$$

Extending the sum over n and using the bound \(h(n)\le \tau _{N}(n)\), and by Lemma 2.3, we derive

$$\begin{aligned} I_{\le }=\frac{x^2}{2^{k+1}} \sum _{n=1}^{\infty } \frac{\mu (n)}{n^{k+1}}h(n)+O_k\left( x^{2}D^{-k}\log ^{N-1} D+x\log ^N x+D\log ^{N-1} D\right) . \end{aligned}$$
(4.5)

Note that h(n) is multiplicative with \(h(2)=1\) and \(h(p)=N\) for \(p> 2\) prime. Thus

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{\mu (n)}{n^{k+1}}h(n)=\bigg (1-\frac{1}{2^{k+1}} \bigg ) \prod _{p>2} \bigg (1-\frac{N}{p^{k+1}} \bigg ). \end{aligned}$$
  1. (i)

    If \(1\le N\le k\), then we choose \(D=x\). In this case, since each \(d_j\le x^{1/k}\), \(d_0\cdots d_{N-1}\le x^{N/k}\le x\). Thus the second term \(I_{>}\) in (4.4) is empty. Inserting (4.5) into (4.4) yields (1.2) in Theorem 1.2 with

    $$\begin{aligned} E_1(x)\ll _k x\log ^{N}x \quad \text {for}~1\le N\le k. \end{aligned}$$
  2. (ii)

    If \(k<N\le 2^{k+1}\), we need to make another choice for D and deal with \(I_{>}\). By similar argument as before, we obtain

    $$\begin{aligned} I_{>}\ll \sum _{\begin{array}{c} m,n\le x\\ 2\mid m,2^k\mid n \end{array}}\sum _{\begin{array}{c} d_0\cdots d_{N-1}>D\\ d_0\mid {\mathrm{gcd}_k }(m/2, n/2^k)\\ d_j\mid {\mathrm{gcd}_k }(m-u_j, n-v_j)\\ 1\le j\le N-1 \end{array}} 1, \end{aligned}$$

    which gives

    $$\begin{aligned} I_{>}&\ll \sum \limits _{\begin{array}{c} m,n\le x\\ 2\mid m,2^k\mid n\\ \prod \limits _{0\le j\le N-1}{\mathrm{gcd}_k }(m-u_j,n-v_j)>D \end{array}}\tau ({\mathrm{gcd}_k }(m/2,n/2^k)) \\&\quad \times \prod \limits _{1\le j\le N-1}\tau ({\mathrm{gcd}_k }(m-u_j,n-v_j)). \end{aligned}$$

    Using the bound \(\tau (n)\ll _{\varepsilon } n^{\varepsilon }\) for any \(\varepsilon >0\), by a similar argument as in the proof of Theorem 1.1, we obtain

    $$\begin{aligned} I_{>}\ll _{\varepsilon } x^{\varepsilon }\sum \limits _{\begin{array}{c} m,n\le x\\ \prod \limits _{0\le j\le N-1}{\mathrm{gcd}_k }(m-u_j,n-v_j)>D \end{array}}1\ll _{\varepsilon } x^{2+\varepsilon }D^{-k/N}. \end{aligned}$$

Hence, combining all the estimates and taking \(D=x^{\frac{2N}{N+k}}\) yields

$$\begin{aligned} I(x)=\frac{x^2}{2^{k+1}} \bigg (1-\frac{1}{2^{k+1}} \bigg ) \prod _{p>2} \bigg (1-\frac{N}{p^{k+1}} \bigg ) +O_{k,\epsilon }(x^{2-\frac{2k}{N+k}+\varepsilon }+x\log ^N x). \end{aligned}$$

Plugging this into (4.1), we obtain (1.2) in Theorem 1.2 with

$$\begin{aligned} E_{2}(x)\ll _{k,\varepsilon } x^{2-\frac{2k}{N+k}+\varepsilon } ~\text {for}~k<N\le 2^{k+1}. \end{aligned}$$