# Divisor sum identities

The purpose of this page is to catalog new, interesting, and useful identities related to number-theoretic divisor sums, i.e., sums of an arithmetic function over the divisors of a natural number $n$, or equivalently the Dirichlet convolution of an arithmetic function $f(n)$ with one:
    $g(n):=\sum _{d\mid n}f(d).$
These identities include applications to sums of an arithmetic function over just the proper prime divisors of $n$. We also define periodic variants of these divisor sums with respect to the greatest common divisor function in the form of
    $g_{m}(n):=\sum _{d\mid (m,n)}f(d),\ 1\leq m\leq n$
Well-known inversion relations that allow the function $f(n)$ to be expressed in terms of $g(n)$ are provided by the Möbius inversion formula. Naturally, some of the most interesting examples of such identities result when considering the average order summatory functions over an arithmetic function $f(n)$ defined as a divisor sum of another arithmetic function $g(n)$. Particular examples of divisor sums involving special arithmetic functions and special Dirichlet convolutions of arithmetic functions can be found on the following pages: here, here, here, here, and here.

## Average order sum identities
### Interchange of summation identities

The following identities are the primary motivation for creating this topics page. These identities do not appear to be well-known, or at least well-documented, and are extremely useful tools to have at hand in some applications. In what follows, we consider that $f,g,h,u,v:\mathbb {N} \rightarrow \mathbb {C}$ are any prescribed arithmetic functions and that G(x):=∑$_{n≤x}$g(n){\textstyle G(x):=\sum _{n\leq x}g(n)} denotes the summatory function of $g(n)$. A more common special case of the first summation below is referenced here.
* $\sum _{n=1}^{x}v(n)\sum _{d\mid n}h(d)u\left({\frac {n}{d}}\right)=\sum _{n=1}^{x}h(n)\sum _{k=1}^{\left\lfloor {\frac {x}{n}}\right\rfloor }u(k)v(nk)$
* ${\begin{aligned}\sum _{n=1}^{x}\sum _{d\mid n}f(d)g\left({\frac {n}{d}}\right)&=\sum _{n=1}^{x}f(n)G\left(\left\lfloor {\frac {x}{n}}\right\rfloor \right)=\sum _{i=1}^{x}\left(\sum _{\left\lceil {\frac {x+1}{i+1}}\right\rceil \leq n\leq \left\lfloor {\frac {x-1}{i}}\right\rfloor }f(n)\right)G(i)+\sum _{d\mid x}G(d)f\left({\frac {x}{d}}\right)\end{aligned}}$
* $\sum _{d=1}^{x}f(d)\left(\sum _{r\mid (d,x)}g(r)h\left({\frac {d}{r}}\right)\right)=\sum _{r\mid x}g(r)\left(\sum _{1\leq d\leq x/r}h(d)f(rd)\right)$
* $\sum _{m=1}^{x}\left(\sum _{d\mid (m,x)}f(d)g\left({\frac {x}{d}}\right)\right)=\sum _{d\mid x}f(d)g\left({\frac {x}{d}}\right)\cdot {\frac {x}{d}}$
* $\sum _{m=1}^{x}\left(\sum _{d\mid (m,x)}f(d)g\left({\frac {x}{d}}\right)\right)t^{m}=(t^{x}-1)\cdot \sum _{d\mid x}{\frac {t^{d}f(d)}{t^{d}-1}}g\left({\frac {x}{d}}\right)$
In general, these identities are collected from the so-called "rarities and b-sides" of both well established and semi-obscure analytic number theory notes and techniques and the papers and work of the contributors. The identities themselves are not difficult to prove and are an exercise in standard manipulations of series inversion and divisor sums. Therefore, we omit their proofs here.

### The convolution method

The convolution method is a general technique for estimating average order sums of the form
    $\sum _{n\leq x}f(n)\qquad {\text{ or }}\qquad \sum _{\stackrel {q\leq x}{q{\text{ squarefree}}}}f(q),$
where the multiplicative function f can be written as a convolution of the form $f(n)=(g\ast h)(n)$ for suitable, application-defined arithmetic functions g and h. A short survey of this method can be found here.
A related technique is the use of the formula
    $\sum _{k=1}^{n}f(k)=\sum _{k=1}^{n}\sum _{xy=k}^g(x)h(y)=\sum _{x=1}^{a}\sum _{y=1}^{n/x}g(x)h(y)+\sum _{y=1}^{b}\sum _{x=1}^{n/y}g(x)h(y)-\sum _{x=1}^{a}\sum _{y=1}^{b}g(x)h(y);$
this is known as the Dirichlet hyperbola method.

## Periodic divisor sums

An arithmetic function is periodic (mod k), or k-periodic, if $f(n+k)=f(n)$ for all $n\in \mathbb {N}$. Particular examples of k-periodic number theoretic functions are the Dirichlet characters $f(n)=\chi (n)$ modulo k and the greatest common divisor function $f(n)=(n,k)$. It is known that every k-periodic arithmetic function has a representation as a finite discrete Fourier series of the form
    $f(n)=\sum _{m=1}^{k}a_{k}(m)e\left({\frac {mn}{k}}\right),$
where the Fourier coefficients $a_{k}(m)$ defined by the following equation are also k-periodic:
    $a_{k}(m)={\frac {1}{k}}\sum _{n=1}^{k}f(n)e\left(-{\frac {mn}{k}}\right).$
We are interested in the following k-periodic divisor sums:
    $s_{k}(n):=\sum _{d\mid (n,k)}f(d)g\left({\frac {k}{d}}\right)=\sum _{m=1}^{k}a_{k}(m)e\left({\frac {mn}{k}}\right).$
It is a fact that the Fourier coefficients of these divisor sum variants are given by the formula
    $a_{k}(m)=\sum _{d\mid (m,k)}g(d)f\left({\frac {k}{d}}\right){\frac {d}{k}}.$

### Fourier transforms of the GCD

We can also express the Fourier coefficients in the equation immediately above in terms of the Fourier transform of any function h at the input of $\operatorname {gcd} (n,k)$ using the following result where $c_{q}(n)$ is a Ramanujan sum (cf. Fourier transform of the totient function):
    $F_{h}(m,n)=\sum _{k=1}^{n}h((k,n))e\left(-{\frac {km}{n}}\right)=(h\ast c_{\bullet }(m))(n).$
Thus by combining the results above we obtain that
    $a_{k}(m)=\sum _{d\mid (m,k)}g(d)f\left({\frac {k}{d}}\right){\frac {d}{k}}=\sum _{d\mid k}\sum _{r\mid d}f(r)g(d)c_{\frac {d}{r}}(m).$

## Sums over prime divisors

Let the function $a(n)$ denote the characteristic function of the primes, i.e., $a(n)=1$ if and only if $n$ is prime and is zero-valued otherwise. Then as a special case of the first identity in equation (1) in section interchange of summation identities above, we can express the average order sums
    $\sum _{n=1}^{x}\sum _{\stackrel {p\mid n}{p{\text{ prime}}}}f(p)=\sum _{p=1}^{x}a(p)f(p)\left\lfloor {\frac {x}{p}}\right\rfloor =\sum _{\stackrel {p=1}{p{\text{ prime}}}}^{x}f(p)\left\lfloor {\frac {x}{p}}\right\rfloor .$
We also have an integral formula based on Abel summation for sums of the form
    $\sum _{\stackrel {p=1}{p{\text{ prime}}}}^{x}f(p)=\pi (x)f(x)-\int _{2}^{x}\pi (t)f^{\prime }(t)dt\approx {\frac {xf(x)}{\log x}}-\int _{2}^{x}{\frac {t}{\log t}}f^{\prime }(t)dt,$
where $\pi (x)\sim {\frac {x}{\log x}}$ denotes the prime-counting function. Here we typically make the assumption that the function f is continuous and differentiable.

## Some lesser appreciated divisor sum identities

We have the following divisor sum formulas for f any arithmetic function and g completely multiplicative where $\varphi (n)$ is Euler's totient function and $\mu (n)$ is the Möbius function:
* $\sum _{d\mid n}f(d)\varphi \left({\frac {n}{d}}\right)=\sum _{k=1}^{n}f(\operatorname {gcd} (n,k))$
* $\sum _{d\mid n}\mu (d)f(d)=\prod _{\stackrel {p\mid n}{p{\text{ prime}}}}(1-f(p))$
* $f(m)f(n)=\sum _{d\mid (m,n)}g(d)f\left({\frac {mn}{d^{2}}}\right).$
* If f is completely multiplicative then the pointwise multiplication $\cdot$ with a Dirichlet convolution yields $f\cdot (g\ast h)=(f\cdot g)\ast (f\cdot h)$.
* $\sum _{d^{k}\mid n}\mu (d)={\Biggl \{\begin{array}{ll}0,&{\text{ if }}m^{k}\mid n{\text{ for some }}m>1;\\1,&{\text{otherwise.}}\end{array}}$
* If $m\geq 1$ and n has more than m distinct prime factors, then $\sum _{d\mid n}\mu (d)\log ^{m}(d)=0.$

## The Dirichlet inverse of an arithmetic function

We adopt the notation that $\varepsilon (n)=\delta _{n,1}$ denotes the multiplicative identity of Dirichlet convolution so that $(\varepsilon \ast f)(n)=(f\ast \varepsilon )(n)=f(n)$ for any arithmetic function f and $n\geq 1$. The Dirichlet inverse of a function f satisfies $(f\ast f^{-1})(n)=(f^{-1}\ast f)(n)=\varepsilon (n)$ for all $n\geq 1$. There is a well-known recursive convolution formula for computing the Dirichlet inverse $f^{-1}(n)$ of a function f by induction given in the form of
    $f^{-1}(n)={\Biggl \{\begin{array}{ll}{\frac {1}{f(1)}},&{\text{ if }}n=1;\\-{\frac {1}{f(1)}}\sum _{\stackrel {d\mid n}{d>1}}f(d)f^{-1}\left({\frac {n}{d}}\right),&{\text{ if }}n>1.\end{array}}$
For a fixed function f, let the function $f_{\pm }(n):=(-1)^{\delta _{n,1}}f(n)={\Biggl \{\begin{matrix}-f(1),&{\text{ if }}n=1;\\f(n),&{\text{ if }}n>1\end{matrix}}$
Next, define the following two multiple, or nested, convolution variants for any fixed arithmetic function f:
    ${\begin{aligned}{\widetilde {\operatorname {ds} }}_{j,f}(n)&:=\underbrace {\left(f_{\pm }\ast f\ast \cdots \ast f\right)} _{j{\text{ times}}}(n)\\\operatorname {ds} _{j,f}(n)&:={\Biggl \{\begin{array}{ll}f_{\pm }(n),&{\text{ if }}j=1;\\\sum \limits _{\stackrel {d\mid n}{d>1}}f(d)\operatorname {ds} _{j-1,f}(n/d),&{\text{ if }}j>1.\end{array}}\end{aligned}}$
The function $D_{f}(n)$ by the equivalent pair of summation formulas in the next equation is closely related to the Dirichlet inverse for an arbitrary function f.
    $D_{f}(n):=\sum _{j=1}^{n}\operatorname {ds} _{2j,f}(n)=\sum _{m=1}^{\left\lfloor {\frac {n}{2}}\right\rfloor }\sum _{i=0}^{2m-1}{\binom {2m-1}{i}}(-1)^{i+1}{\widetilde {\operatorname {ds} }}_{i+1,f}(n)$
In particular, we can prove that
    $f^{-1}(n)=\left(D+{\frac {\varepsilon }{f(1)}}\right)(n).$
A table of the values of $D_{f}(n)$ for $2\leq n\leq 16$ appears below. This table makes precise the intended meaning and interpretation of this function as the signed sum of all possible multiple k-convolutions of the function f with itself.
| n | $D_{f}(n)$ | n | $D_{f}(n)$ | n | $D_{f}(n)$ |
| 2 | $-{\frac {f(2)}{f(1)^{2}}}$ | 7 | $-{\frac {f(7)}{f(1)^{2}}}$ | 12 | ${\frac {2f(3)f(4)+2f(2)f(6)-f(1)f(12)}{f(1)^{3}}}-{\frac {3f(2)^{2}f(3)}{f(1)^{4}}}$ |
| 3 | $-{\frac {f(3)}{f(1)^{2}}}$ | 8 | ${\frac {2f(2)f(4)-f(1)f(8)}{f(1)^{3}}}-{\frac {f(2)^{3}}{f(1)^{4}}}$ | 13 | $-{\frac {f(13)}{f(1)^{2}}}$ |
| 4 | ${\frac {f(2)^{2}-f(1)f(4)}{f(1)^{3}}}$ | 9 | ${\frac {f(3)^{2}-f(1)f(9)}{f(1)^{3}}}$ | 14 | ${\frac {2f(2)f(7)-f(1)f(14)}{f(1)^{3}}}$ |
| 5 | $-{\frac {f(5)}{f(1)^{2}}}$ | 10 | ${\frac {2f(2)f(5)-f(1)f(10)}{f(1)^{3}}}$ | 15 | ${\frac {2f(3)f(5)-f(1)f(15)}{f(1)^{3}}}$ |
| 6 | ${\frac {2f(2)f(3)-f(1)f(6)}{f(1)^{3}}}$ | 11 | $-{\frac {f(11)}{f(1)^{2}}}$ | 16 | ${\frac {f(2)^{4}}{f(1)^{5}}}-{\frac {3f(4)f(2)^{2}}{f(1)^{4}}}+{\frac {f(4)^{2}+2f(2)f(8)}{f(1)^{3}}}-{\frac {f(16)}{f(1)^{2}}}$ |
Let $p_{k}(n):=p(n-k)$ where p is the Partition function (number theory). Then there is another expression for the Dirichlet inverse given in terms of the functions above and the coefficients of the q-Pochhammer symbol for $n>1$ given by
    $f^{-1}(n)=\sum _{k=1}^{n}\left[(p_{k}\ast \mu )(n)+(p_{k}\ast D_{f}\ast \mu )(n)\right]\times [q^{k-1}]{\frac {(q;q)_{\infty }}{1-q}}.$