1 Introduction

Menon’s identity [5] states that for every \(n\in {\mathbb {N}}\),

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n (a-1,n) = \varphi (n) \tau (n), \end{aligned}$$
(1.1)

the notations used here and throughout the paper being fixed in Sect. 2. There are many generalizations and analogs of identity (1.1) in the literature. See, e.g., the papers [3, 6,7,8,9, 11] and the references therein.

Let \(\chi \) be a Dirichlet character (\(\hbox {mod}\ n\)) with conductor d, where \(n,d\in {\mathbb {N}}\), \(d\mid n\). Zhao and Cao [11] derived the formula

$$\begin{aligned} \sum _{a=1}^n (a-1,n) \chi (a)= \varphi (n) \tau (n/d), \end{aligned}$$
(1.2)

which recovers (1.1) if \(\chi \) is the principal character (\(\hbox {mod}\ n\)), that is \(d=1\).

The author [8, Theorem  2.4] generalized identity (1.2) into

$$\begin{aligned} \sum _{a=1}^n f_n(a-s) \chi (a) = \varphi (n) \chi ^*(s) \sum _{\begin{array}{c} \delta \mid n/d\\ (\delta ,s)=1 \end{array}} \frac{(\mu *f_n)(\delta d)}{\varphi (\delta d)}, \end{aligned}$$
(1.3)

where \(f_n\) is an even function (\(\hbox {mod}\ n\)), \(s\in {\mathbb {Z}}\), and \(\chi ^*\) is the primitive character (\(\hbox {mod}\ d\)) that induces \(\chi \). We recall that a function \(f_n:{\mathbb {Z}}\rightarrow {\mathbb {C}}\), \(a\mapsto f_n(a)\) is said to be an even function (\(\hbox {mod}\ n\)) if \(f_n((a,n))=f_n(a)\) holds for every \(a\in {\mathbb {Z}}\), where \(n\in {\mathbb {N}}\) is fixed. Examples of even functions (\(\hbox {mod}\ n\)) are \(f_n(a)=(a,n)\), more generally \(f_n(a)=F((a,n))\), where \(F:{\mathbb {N}}\rightarrow {\mathbb {C}}\) is an arbitrary arithmetic function, and \(f_n(a)=c_n(a)\), representing Ramanujan’s sum.

In the case \(f_n(a)=c_n(a)\), (1.3) gives ([8, Cor. 2.6])

$$\begin{aligned} \sum _{a=1}^n c_n(a-s) \chi (a) = d \varphi (n) \chi ^*(s) \sum _{\begin{array}{c} \delta \mid n/d\\ (\delta ,s)=1 \end{array}} \frac{\delta \mu (n/(\delta d))}{\varphi (\delta d)}. \end{aligned}$$
(1.4)

Notice that in (1.2), (1.3) and (1.4), the sums on the left hand sides are, in fact, over \(1\le a\le n\) with \((a,n)=1\), since \(\chi (a)=0\) for \((a,n)>1\). Here, (1.4) is a generalization of the first identity, due to Cohen [2, Eq. (5.1)], of formulas

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n c_n(a-s) = \varphi (n) \sum _{\begin{array}{c} \delta \mid n \\ (\delta ,s)=1 \end{array}} \frac{\delta \mu (n/\delta )}{\varphi (\delta )} = \mu (n) c_n(s), \end{aligned}$$
(1.5)

the second formula of (1.5) being the Brauer–Rademacher identity. See [2, Cor. 34] and [4, Ch. 2].

Recently, Li and Kim [3] investigated the sums

$$\begin{aligned} S(n,k):= \sum _{a=1}^n (a-1,n) e(ak/n) \end{aligned}$$

and

$$\begin{aligned} S^*(n,k):= \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n (a-1,n) e(ak/n), \end{aligned}$$
(1.6)

by considering the additive characters \(a\mapsto e(ak/n):= \mathrm{e}^{2\pi iak/n}\) of the group \({\mathbb {Z}}_n\). According to [3, Theorem  2.1], for every \(n\in {\mathbb {N}}\) and every \(k\in {\mathbb {Z}}\) one has the identity

$$\begin{aligned} S(n,k)= e(k/n) \sum _{\ell \mid (n,k)} \ell \varphi (n/\ell ), \end{aligned}$$

previously known in the literature, as mentioned by the authors, which is related to the discrete Fourier transform (DFT) of the gcd function.

To investigate the sums \(S^*(n,k)\) defined by (1.6), Li and Kim [3] showed first that these sums enjoy the modified multiplicativity property

$$\begin{aligned} S^*(n_1n_2,k)= S^*(n_1,kn_2') S^*(n_2,kn_1') \end{aligned}$$

for every \(n_1,n_2\in {\mathbb {N}}\) with \((n_1,n_2)=1\), where \(n_1n_1'\equiv 1\) (\(\hbox {mod}\ n_2\)), \(n_2n_2'\equiv 1\) (\(\hbox {mod}\ n_1\)). See [3, Prop. 3.1]. Then, they computed the values \(S^*(p^m,k)\) for prime powers \(p^m\) and deduced that for every \(n\in {\mathbb {N}}\), \(k\in {\mathbb {Z}}\) such that \(\nu _p(n)-\nu _p(k)\ne 1\) for every prime \(p\mid n\) one has ([3, Theorem  3.3])

$$\begin{aligned} S^*(n,k)= e(k/n) \varphi (n) \tau ((n,k)), \end{aligned}$$
(1.7)

which reduces to (1.1) in the case \(n\mid k\). Furthermore, Li and Kim [3, Theorem  3.5] established a formula for \(S^*(n,k)\), valid for every \(n\in {\mathbb {N}}\) and \(k\in {\mathbb {Z}}\).

In this paper, we consider the following generalization of the sum \(S^*(n,k)\):

$$\begin{aligned} S_f(n,k,s):= \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n f_n(a-s) e(ak/n), \end{aligned}$$
(1.8)

where \(f=f_n\) is an even function (\(\hbox {mod}\ n\)), \(n\in {\mathbb {N}}\), \(s,k\in {\mathbb {Z}}\). If \(f_n\) is the constant 1 function, then (1.8) reduces to the Ramanujan sum \(c_n(k)\). The sum (1.8) can be viewed as the DFT of the function \(h_n\) attached to \(f_n\) and defined by \(h_n(a)=f_n(a-s)\) if \((a,n)=1\) and \(h_n(a)=0\) if \((a,n)>1\). Several properties of the DFT of even functions (\(\hbox {mod}\ n\)) were discussed in our paper [10]. However, if the function \(f_n\) is even (\(\hbox {mod}\ n\)), then \(h_n\) does not have this property, in general.

Our results generalize those by Li and Kim [3]. We use a different approach, similar to our paper [8], based on certain convolutional identities valid for every \(n\in {\mathbb {N}}\).

We deduce in Theorem 3.1 identities for the sums \(S_f(n,k,s)\), valid for every \(n\in {\mathbb {N}}\) and \(k\in {\mathbb {Z}}\), which are simpler than the corresponding formula in [3]. Then, we consider the cases when \(\nu _p(n)\ge \nu _p(k)+2\) for every \(p\mid n\), respectively, \(\nu _p(n)\le \nu _p(k)\) for every \(p\mid n\) (Theorems 3.2, 3.3). Finally, by taking sequences \((f_n)_{n\in {\mathbb {N}}}\) of even functions (\(\hbox {mod}\ n\)) such that \(n\mapsto f_n(a)\) is multiplicative for every fixed \(a\in {\mathbb {Z}}\), we give in Theorem 3.6 and in Corollaries 3.7 and 3.8 direct generalizations of formula (1.7). Some other applications, including identities for Ramanujan sums are derived as well. For example, Theorem 3.1 gives that for every \(n\in {\mathbb {N}},s\in {\mathbb {Z}}\),

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n c_n(a-s) e(a/n) = \sum _{\begin{array}{c} d\delta =n \\ (d, \delta s)=1 \end{array}} d \mu ^2(\delta ) e(\delta \delta '/n), \end{aligned}$$
(1.9)

where \(\delta ' \in {\mathbb {Z}}\) is such that \(\delta \delta ' \equiv s\) (\(\hbox {mod}\ d\)). If \(n\in {\mathbb {N}}\) is squarefull (that is, \(\nu _p(n)\ge 2\) for every prime \(p\mid n\)) and \((s,n)=1\), then part (iii) of Corollary 3.8 shows that the sums in (1.9) equal \(n\, e(s/n)\). These identities may be compared to (1.5).

We point out that the key results, used in the proofs, are those concerning the sums \(T_n(k,s,d)\), defined by (4.1), which are themselves generalizations of the Ramanujan sums.

2 Notations

We use the following notations:

  • \({\mathbb {N}}=\{1,2,\ldots \}\), \({\mathbb {Z}}\) is the set of integers,

  • the prime power factorization of \(n\in {\mathbb {Z}}\) is \(n=\pm \prod _p p^{\nu _p(n)}\), the product being over the primes p, where all but a finite number of the exponents \(\nu _p(n)\) are zero, with the convention \(\nu _p(0)=\infty \) for every prime p,

  • (ab) denotes the greatest common divisor of \(a,b\in {\mathbb {Z}}\),

  • \((f*g)(n)=\sum _{d\mid n} f(d)g(n/d)\) is the Dirichlet convolution of the functions \(f,g:{\mathbb {N}}\rightarrow {\mathbb {C}}\),

  • \(\mu \) is the Möbius function,

  • \(\sigma _s(n)=\sum _{d\mid n} d^s\) (\(s\in {\mathbb {R}}\)),

  • \(\tau (n)=\sigma _0(n)\) is the number of divisors of n,

  • \(\sigma (n)=\sigma _1(n)\) is the sum of divisors of n,

  • \(J_s\) is the Jordan function of order s given by \(J_s(n)=n^s\prod _{p\mid n} (1-1/p^s)\) (\(s\in {\mathbb {R}}\)),

  • \(\varphi =J_1\) is Euler’s totient function,

  • \(e(x)=e^{2\pi i x}\) (\(x\in {\mathbb {R}}\)),

  • \(c_n(k)=\sum _{1\le a \le n, (a,n)=1} e(ak/n)\) is Ramanujan’s sum (\(n\in {\mathbb {N}}\), \(k\in {\mathbb {Z}}\)).

3 Main results

Theorem 3.1

Let \(n\in {\mathbb {N}}\), \(s,k\in {\mathbb {Z}}\) and let \(f=f_n\) be an even function (\(\hbox {mod}\ n\)). Then

$$\begin{aligned} S_f(n,k,s)= & {} n \sum _{\begin{array}{c} d\mid n\\ (d,s)=1 \end{array}} \frac{(\mu *f_n)(d)}{d} \sum _{\begin{array}{c} \delta \mid n \\ (\delta ,d)=1\\ \frac{n}{d\delta }\mid k \end{array}} \frac{\mu (\delta )}{\delta } e(\delta \delta ' k/n)\nonumber \\= & {} \sum _{e \mid (n,k)} e \sum _{\begin{array}{c} d\delta =n/e \\ (d, \delta s)=1 \end{array}} (\mu *f_n)(d) \mu (\delta ) e(\delta \delta ' k/n), \end{aligned}$$
(3.1)

where \(\delta ' \in {\mathbb {Z}}\) is such that \(\delta \delta ' \equiv s\) (\(\mathrm{mod}\ d\)).

For \(n\mid k\), formula (3.1) is a special case of (1.3).

Theorem 3.2

Under the assumptions of Theorem 3.1 and with \(\nu _p(n)\ge \nu _p(k)+2\) for every prime \(p\mid n\), we have

$$\begin{aligned} S_f(n,k,s) = e(ks/n) \sum _{\begin{array}{c} d\mid (n,k)\\ (n/d,s)=1 \end{array}} d\, (\mu *f_n)(n/d). \end{aligned}$$
(3.2)

If \(\nu _p(n)\le \nu _p(k)\) for every prime \(p\mid n\) (that is, \(n\mid k\)), then \(e(ak/n)=1\) for every integer a and

$$\begin{aligned} S_f(n,k,s) = \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n f_n(a-s). \end{aligned}$$

As a direct generalization of Menon’s identity (1.1), we have the following result.

Theorem 3.3

Under the assumptions of Theorem 3.1 and with \(\nu _p(n)\le \nu _p(k)\) for every prime \(p\mid n\), one has

$$\begin{aligned} S_f(n,k,s) = \varphi (n) \sum _{\begin{array}{c} d\mid n\\ (d,s)=1 \end{array}} \frac{(\mu *f_n)(d)}{\varphi (d)}. \end{aligned}$$
(3.3)

Formula (3.3) is, in fact, a special case of our result [8, Theorem  2.1], i.e., the case when \(\chi \) is the principal character (\(\hbox {mod}\ n\)) in (1.3).

Corollary 3.4

Theorems 3.13.2 and 3.3 apply to the following functions:

  1. (i)

    \(f_n(a)=(a,n)^m\) (\(m\in {\mathbb {R}}\)) with \((\mu *f_n)(d)=J_m(d)\) (\(d\mid n\)),

  2. (ii)

    \(f_n(a)=\sigma _m((a,n))\) (\(m\in {\mathbb {R}}\)) with \((\mu *f_n)(d)=d^m\) (\(d\mid n\)),

  3. (iii)

    \(f_n(a)=c_n(a)\) with \((\mu *f_n)(d)=d \mu (n/d)\) (\(d\mid n\)).

Note that Theorem 3.3 applied with (i) of Corollary 3.4 and \(m=1\) yields

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n (a-s,n) = \varphi (n) \tau (n'), \end{aligned}$$

where \(n=n'n''\), \(n'=\max \{d: d\mid n, (d,s)=1\}\). This generalizes Menon’s identity (1.1) to any \(n\in {\mathbb {N}}\) and \(s\in {\mathbb {Z}}\). Also, see [6, Eq. (35)].

See, e.g., [10, Appl. 1] for the identity \(\sum _{ab=d} \mu (a)c_n(b)= d\mu (n/d)\) (\(d\mid n\)), mentioned in (iii) of Corollary 3.4. Several other special cases can be considered as well.

Theorem 3.5

Let \((f_n)_{n\in {\mathbb {N}}}\) be a sequence of even functions (\(\hbox {mod}\ n\)) such that \(n\mapsto f_n(a)\) is multiplicative for every fixed \(a\in {\mathbb {Z}}\). Let \(n_1,n_2\in {\mathbb {N}}\), \((n_1,n_2)=1\), \(s,k\in {\mathbb {Z}}\). Then

$$\begin{aligned} S_f(n_1n_2,k,s)=S_f(n_1,kn_2',s) S_f(n_2,kn_1',s), \end{aligned}$$

where \(n_1',n_2'\in {\mathbb {Z}}\) are such that \(n_1n_1'\equiv 1\) (\(\mathrm{mod}\ n_2\)) and \(n_2n_2'\equiv 1\) (\(\mathrm{mod}\ n_1\)).

Note that under assumptions of Theorem 3.5, \(f_n(a)\) is multiplicative viewed as a function of two variables. See [10, Prop. 4]. Examples of sequences of functions satisfying the assumptions of Theorem 3.5 are the sequence of the Ramanujan sums and \((f_n)_{n\in {\mathbb {N}}}\), where \(f_n(a)=F((a,n))\) and F is an arbitrary multiplicative function.

Theorem 3.6

Under the assumptions of Theorem 3.5 and if \(\nu _p(n)- \nu _p(k)\ne 1\) for every prime \(p\mid n\), we have

$$\begin{aligned} S_f(n,k,s) = e(ks/n) \varphi (n_2) \sum _{\begin{array}{c} d\mid (n_1,k)\\ (n_1/d,s)=1 \end{array}} d\, (\mu *f_{n_1})(n_1/d) \sum _{\begin{array}{c} d\mid n_2\\ (d,s)=1 \end{array}} \frac{(\mu *f_{n_2})(d)}{\varphi (d)}, \end{aligned}$$

where \(n=n_1n_2\) such that \(\nu _p(n)\ge \nu _p(k)+2\) for every prime \(p\mid n_1\), and \(\nu _p(n)\le \nu _p(k)\) for every prime \(p\mid n_2\).

Corollary 3.7

Let \(n\in {\mathbb {N}}\), \(s,k\in {\mathbb {Z}}\) such that \(\nu _p(n)- \nu _p(k)\ne 1\) for every prime \(p\mid n\). Let \(m\in {\mathbb {R}}\). Then

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n (a-s,n)^m e(ak/n)= & {} e(ks/n) J_m(n_1) \varphi (n_2) \sum _{\begin{array}{c} d\mid (n_1,k)\\ (n_1/d,s)=1 \end{array}} d^{1-m} \sum _{\begin{array}{c} d\mid n_2 \\ (d,s)=1 \end{array}} \frac{J_m(d)}{\varphi (d)}, \end{aligned}$$
(3.4)
$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n \sigma _m((a-s,n)) e(ak/n)= & {} e(ks/n) n_1^m \varphi (n_2) \sum _{\begin{array}{c} d\mid (n_1,k)\\ (n_1/d,s)=1 \end{array}} d^{1-m} \sum _{\begin{array}{c} d\mid n_2 \\ (d,s)=1 \end{array}} \frac{d^m}{\varphi (d)}, \end{aligned}$$
(3.5)
$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n c_n(a-s) e(ak/n)= & {} e(ks/n) n_1 \varphi (n_2) \sum _{\begin{array}{c} d\mid (n_1,k)\\ (n_1/d,s)=1 \end{array}} \mu (d) \sum _{\begin{array}{c} d\mid n_2 \\ (d,s)=1 \end{array}} \frac{d\mu (n_2/d)}{\varphi (d)}, \end{aligned}$$
(3.6)

where \(n_1\) and \(n_2\) are defined as in Theorem 3.6.

Next, we consider the case when \((s,n)=1\).

Corollary 3.8

Let \(n\in {\mathbb {N}}\), \(s,k\in {\mathbb {Z}}\) such that \((s,n)=1\) and \(\nu _p(n)- \nu _p(k)\ne 1\) for every prime \(p\mid n\). Let \(n_1\) and \(n_2\) be defined as in Theorem 3.6.

  1. (i)

    If \(m\in {\mathbb {R}}\), \(m\ne 1\), then

    $$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n (a-s,n)^m e(ak/n) = e(ks/n) J_m(n_1) \sigma _{1-m}((n_1,k)) \varphi (n_2) F_m(n_2), \end{aligned}$$

where

$$\begin{aligned} F_m(n_2):=\sum _{d\mid n_2} \frac{J_m(d)}{\varphi (d)}= \prod _{p^{\nu _p(n_2)}\mid \mid n_2} \left( 1+\frac{p^m-1}{p-1} \cdot \frac{p^{(m-1)\nu _p(n_2)}-1}{p^{m-1}-1}\right) . \end{aligned}$$

For \(m=1\),

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n (a-s,n) e(ak/n) = e(ks/n) \varphi (n)\tau ((n,k)). \end{aligned}$$
(3.7)
  1. (ii)

    If \(m\in {\mathbb {R}}\), \(m\ne 1\), then

    $$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n \sigma _m((a-s,n)) e(ak/n) = e(ks/n) n_1^m \sigma _{1-m}((n_1,k))\varphi (n_2) G_m(n_2), \end{aligned}$$

where

$$\begin{aligned} G_m(n_2): =\sum _{d\mid n_2} \frac{d^m}{\varphi (d)}= \prod _{p^{\nu _p(n_2)}\mid \mid n_2} \left( 1+\frac{p^m}{p-1} \cdot \frac{p^{(m-1)\nu _p(n_2)}-1}{p^{m-1}-1}\right) . \end{aligned}$$

For \(m=1\),

$$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n \sigma ((a-s,n)) e(ak/n) = e(ks/n) n_1 \tau ((n_1,k))\varphi (n_2) G_1(n_2), \end{aligned}$$

where

$$\begin{aligned} G_1(n_2): =\sum _{d\mid n_2} \frac{d}{\varphi (d)}= \prod _{p^{\nu _p(n_2)}\mid \mid n_2} \left( 1+ \frac{p\nu _p(n_2)}{p-1}\right) . \end{aligned}$$
  1. (iii)

    We have

    $$\begin{aligned} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n c_n(a-s) e(ak/n) ={\left\{ \begin{array}{ll} e(ks/n) n_1, &{} \quad \text { if }(n_1,k)=1\text { and }n_2\text { is squarefree}, \\ 0, &{} \quad \text { otherwise}. \end{array}\right. } \end{aligned}$$

In the case \(s=1\), (3.7) reduces to the identity (1.7) by Li and Kim.

4 Proofs

We need the following lemmas. For \(n,d\in {\mathbb {N}}\) and \(k,s\in {\mathbb {Z}}\) consider the sum

$$\begin{aligned} T_n(k,s,d):=\sum _{\begin{array}{c} a=1\\ (a,n)=1\\ a\equiv s (\mathrm{mod}\ d) \end{array}}^n e(ak/n), \end{aligned}$$
(4.1)

which reduces to Ramanujan’s sum \(c_n(k)\) if \(d=1\).

Lemma 4.1

Let \(n,d\in {\mathbb {N}}\), \(k,s\in {\mathbb {Z}}\) such that \(d\mid n\). Then

$$\begin{aligned} T_n(k,s,d)= {\left\{ \begin{array}{ll} \displaystyle \frac{n}{d} \sum _{\begin{array}{c} \delta \mid n \\ (\delta ,d)=1\\ \frac{n}{d\delta }\mid k \end{array}} \frac{\mu (\delta )}{\delta } e(\delta \delta ' k/n), &{} \text { if}\ (s,d)=1, \\ 0, &{} \text { otherwise}, \end{array}\right. } \end{aligned}$$

where \(\delta ' \in {\mathbb {Z}}\) is such that \(\delta \delta ' \equiv s\) (\(\mathrm{mod}\ d\)).

Note that in the case \(d=1\), this recovers the familiar formula

$$\begin{aligned} c_n(k)= \sum _{\delta \mid (n,k)} \delta \mu (n/\delta ), \end{aligned}$$

concerning Ramanujan’s sum.

Proof of Lemma 4.1

For each term of the sum, \((a,n)=1\). Hence, if \(a\equiv s\) (\(\hbox {mod}\ d\)), then \((s,d)=(a,d)=1\). We assume that \((s,d)=1\) is satisfied (otherwise the sum is empty and equals zero).

Using the property of the Möbius \(\mu \) function, the given sum can be written as:

$$\begin{aligned} T_n(k,s,d)= & {} \sum _{\begin{array}{c} a=1\\ a\equiv s (\mathrm{mod}\ d) \end{array}}^n e(ak/n) \sum _{\delta \mid (a,n)} \mu (\delta )\\= & {} \sum _{\delta \mid n} \mu (\delta ) \sum _{\begin{array}{c} j=1\\ \delta j\equiv s (\mathrm{mod}\ d) \end{array}}^{n/\delta } e(\delta jk/n). \end{aligned}$$

Let \(\delta \mid n\) be fixed. The linear congruence \(\delta j\equiv s\) (\(\hbox {mod}\ d\)) has solutions in j if and only if \((\delta ,d)\mid s\), equivalent to \((\delta ,d)=1\), since \((s,d)=1\). There are \(n/(d\delta )\) solutions j (\(\hbox {mod}\ n/\delta \)) and these are \(j=\delta '+\ell d\), where \(1\le \ell \le n/(d\delta )\) and \(\delta '\) is any integer such that \(\delta \delta ' \equiv s\) (\(\mathrm{mod}\ d\)).

We deduce that

$$\begin{aligned} T_n(k,s,d)= & {} \sum _{\begin{array}{c} \delta \mid n\\ (\delta ,d)=1 \end{array}} \mu (\delta ) \sum _{\ell =1}^{n/(d\delta )} e(\delta (\delta '+\ell d) k/n)\\= & {} \sum _{\begin{array}{c} \delta \mid n\\ (\delta ,d)=1 \end{array}} \mu (\delta ) e(\delta \delta ' k/n) \sum _{\ell =1}^{n/(d\delta )} e(\ell k/(n/d\delta )), \end{aligned}$$

where the inner sum is \(n/(d\delta )\) if \(n/(d\delta )\mid k\) and is 0 otherwise. This gives the formula. \(\square \)

Lemma 4.2

Let \(n,d\in {\mathbb {N}}\), \(k,s\in {\mathbb {Z}}\) such that \(d\mid n\) and \(\nu _p(n)\ge \nu _p(k)+2\) for all primes \(p\mid n\). Then

$$\begin{aligned} T_n(k,s,d) = {\left\{ \begin{array}{ll} \displaystyle \frac{n}{d} e(ks/n), &{} \text { if}\ \frac{n}{d} \mid k\ \text {and}\ (s,d)=1, \\ 0, &{} \text { otherwise}. \end{array}\right. } \end{aligned}$$

Proof of Lemma 4.2

We use Lemma 4.1. Assume that \((s,d)=1\). In the sum, it is enough to consider the squarefree values of \(\delta \), that is \(\nu _p(\delta )\le 1\) for all primes \(p\mid n\), since otherwise \(\mu (\delta )=0\). We claim that the only possible value is \(\delta =1\), that is \(\nu _p(\delta )=0\) for all primes \(p\mid n\). Indeed, if there is a prime p such that \(\nu _p(\delta )=1\), then \(\nu _p(d)=0\), since \((d,\delta )=1\), and by the assumption \(\nu _p(n)\ge \nu _p(k)+2\) we get \(\nu _p(\frac{n}{d\delta })=\nu _p(n)-1\ge \nu _p(k)+1>\nu _p(k)\), which contradicts the condition \(\frac{n}{d\delta }\mid k\).

Now for \(\delta =1\) one can select \(\delta '=s\). This completes the proof. \(\square \)

Lemma 4.3

Let \(n,d\in {\mathbb {N}}\), \(k,s\in {\mathbb {Z}}\) such that \(d\mid n\) and \(\nu _p(n)\le \nu _p(k)\) for all primes \(p\mid n\) (that is, \(n\mid k\), in particular \(k=0\)). Then

$$\begin{aligned} T_n(k,s,d)= \sum _{\begin{array}{c} a=1\\ (a,n)=1\\ a\equiv s (\mathrm{mod}\ d) \end{array}}^n 1 = {\left\{ \begin{array}{ll} \displaystyle \frac{\varphi (n)}{\varphi (d)}, &{} \text { if}\ (s,d)=1, \\ 0, &{} \text { otherwise}, \end{array}\right. } \end{aligned}$$

Proof of Lemma 4.3

Use Lemma 4.1. Assume that \((s,d)=1\). Since \(n\mid k\), in the sum \(e(\delta \delta 'k/n)=1\) for every \(\delta \), and we have

$$\begin{aligned} T_n(k,s,d)= \frac{n}{d} \sum _{\begin{array}{c} \delta \mid n\\ (\delta ,d)=1 \end{array}} \frac{\mu (\delta )}{\delta }= \frac{n}{d} \prod _{\begin{array}{c} p\mid n \\ p\not \mid d \end{array}} \left( 1-\frac{1}{p}\right) =\frac{n}{d}\cdot \frac{\varphi (n)/n}{\varphi (d)/d}=\frac{\varphi (n)}{\varphi (d)}. \end{aligned}$$

\(\square \)

Lemma 4.3 is known in the literature and is usually proved by the inclusion–exclusion principle. See, e.g., [1, Theorem  5.32].

Proof of Theorem 3.1

Since the function \(f_n\) is even (\(\hbox {mod}\ n\)), we have for every \(a\in {\mathbb {N}}\),

$$\begin{aligned} f_n(a)=f_n((a,n))= \sum _{d\mid (a,n)} (\mu *f_n)(d). \end{aligned}$$

Hence,

$$\begin{aligned} S_f(n,k,s)= & {} \sum _{\begin{array}{c} a=1\\ (a,n)=1 \end{array}}^n e(ak/n) \sum _{\begin{array}{c} d\mid (a-s,n) \end{array}} (\mu *f_n)(d) \\= & {} \sum _{d\mid n} (\mu *f_n)(d) \sum _{\begin{array}{c} a=1\\ (a,n)=1\\ a\equiv s (\mathrm{mod}\ d) \end{array}}^n e(ak/n), \end{aligned}$$

that is,

$$\begin{aligned} S_f(n,k,s) = \sum _{d\mid n} (\mu *f_n)(d) T_n(k,s,d). \end{aligned}$$
(4.2)

According to Lemma 4.1, we deduce

$$\begin{aligned} S_f(n,k,s)= & {} n \sum _{\begin{array}{c} d\mid n\\ (d,s)=1 \end{array}} \frac{(\mu *f_n)(d)}{d} \sum _{\begin{array}{c} \delta \mid n \\ (\delta ,d)=1\\ \frac{n}{d\delta }\mid k \end{array}} \frac{\mu (\delta )}{\delta } e(\delta \delta ' k/n), \\= & {} n \sum _{\begin{array}{c} d\delta e=n\\ (d,\delta s)=1\\ e\mid k \end{array}} \frac{(\mu *f_n)(d)}{d} \cdot \frac{\mu (\delta )}{\delta } e(\delta \delta ' k/n), \end{aligned}$$

which gives the result. \(\square \)

Proof of Theorem 3.2

Using identity (4.2) and Lemma 4.2, we have

$$\begin{aligned} S_f(n,k,s)= n e(ks/n) \sum _{\begin{array}{c} d\mid n \\ \frac{n}{d} \mid k\\ (d,s)=1 \end{array}} \frac{(\mu *f_n)(d)}{d}, \end{aligned}$$

and interchange d and n / d. This gives identity (3.2). \(\square \)

Proof of Theorem 3.3

Follows immediately by identity (4.2) and Lemma 4.3. \(\square \)

Proof of Theorem 3.5

Since \((n_1,n_2)=1\), if \(a_1\) runs over a reduced residue system (\(\hbox {mod}\ n_1\)) and \(a_2\) runs through a reduced residue system (\(\hbox {mod}\ n_2\)), then \(a=a_1n_2+a_2n_1\) runs through a reduced residue system (\(\hbox {mod}\ n_1n_2\)). Hence

$$\begin{aligned} S_f(n_1n_2,k,s)= \sum _{\begin{array}{c} a_1=1\\ (a_1,n_1)=1 \end{array}}^{n_1} \sum _{\begin{array}{c} a_2=1\\ (a_2,n_2)=1 \end{array}}^{n_2} f_{n_1n_2}(a_1n_2+a_2n_1-s) e((a_1n_2+a_2n_1)k/(n_1n_2)). \end{aligned}$$

Using that \(f_n\) are even functions (\(\hbox {mod}\ n\)) and that \(n\mapsto f_n(a)\) is multiplicative for every \(a\in {\mathbb {Z}}\), we have

$$\begin{aligned} f_{n_1n_2}(a_1n_2+a_2n_1-s)= & {} f_{n_1}(a_1n_2+a_2n_1-s) f_{n_2}(a_1n_2+a_2n_1-s) \\= & {} f_{n_1}((a_1n_2+a_2n_1-s,n_1)) f_{n_2}((a_1n_2+a_2n_1-s,n_2))\\= & {} f_{n_1}((a_1n_2-s,n_1)) f_{n_2}((a_2n_1-s,n_2)) = f_{n_1}(a_1n_2-s) f_{n_2}(a_2n_1-s) \end{aligned}$$

Therefore

$$\begin{aligned} S_f(n_1n_2,k,s)= & {} \sum _{\begin{array}{c} a_1=1\\ (a_1,n_1)=1 \end{array}}^{n_1} f_{n_1}(a_1n_2-s) e(a_1n_2n_2'k/n_1) \\&\times \sum _{\begin{array}{c} a_2=1\\ (a_2,n_2)=1 \end{array}}^{n_2} f_{n_2}(a_2n_1-s) e(a_2n_1n_1'k/n_2) = S_f(n_1,kn_2',s) S_f(n_2,kn_1',s), \end{aligned}$$

where \(a_1n_2\) runs through a reduced residue system (\(\hbox {mod}\ n_1\)) and \(a_2n_1\) runs through a reduced residue system (\(\hbox {mod}\ n_2\)). \(\square \)

Proof of Theorem 3.6

Using Theorems 3.53.2 and 3.3, we have

$$\begin{aligned} S_f(n,k,s)= & {} S_f(n_1n_2,k,s) = S_f(n_1,kn_2',s) S_f(n_2,kn_1',s) \\= & {} e(kn_2's/n_1) \sum _{\begin{array}{c} d\mid (n_1,kn_2')\\ (n_1/d,s)=1 \end{array}} d\, (\mu *f_{n_1})(n_1/d) \varphi (n_2) \sum _{\begin{array}{c} d\mid n_2\\ (d,s)=1 \end{array}} \frac{(\mu *f_{n_2})(d)}{\varphi (d)}, \end{aligned}$$

with

$$\begin{aligned} e(kn_2's/n_1)= & {} e(ks n_2 n_2'/n_1n_2)= e(ks(1+tn_1)/n_1n_2) \\= & {} e(ks/n) e(kst/n_2)= e(ks/n), \end{aligned}$$

where \(k/n_2\in {\mathbb {Z}}\) by the definition of \(n_2\). Also, since \((n_2',n_1)=1\), one has \((n_1,kn_2')=(n_1,k)\). \(\square \)

Proof of Corollary 3.7

Apply Theorem 3.6 for \(f_n(a)=(a,n)^m\), \(f_n(a)=\sigma _m((a,n))\) and \(f_n(a)=c_n(a)\), respectively.

If \(f_n(a)=(a,n)^m\), then \((\mu *f_n)(d)=J_m(d)\) for every \(d\mid n\), as noted in Corollary 3.4. Also, for \(d\mid (n_1,k)\) we have \(\nu _p(n_1)\ge \nu _p(k)+2\ge \nu _p(d)+2\) for every prime \(p\mid n_1\) which implies that \(J_m(n_1/d)= J_m(n_1)/d^m\), giving (3.4).

If \(f_n(a)=\sigma _m((a,n))\), then \((\mu *f_n)(d)= d^m\) for every \(d\mid n\), leading to (3.5)

If \(f_n(a)=c_n(a)\), then \((\mu *f_n)(d)=d \mu (n/d)\) for every \(d\mid n\). See Corollary 3.4. This implies (3.6). \(\square \)

Proof of Corollary 3.8

Follows immediately by Corollary 3.7. \(\square \)