# Dirichlet series inversion

In analytic number theory, a Dirichlet series, or Dirichlet generating function (DGF), of a sequence is a common way of understanding and summing arithmetic functions in a meaningful way. A little known, or at least often forgotten about, way of expressing formulas for arithmetic functions and their summatory functions is to perform an integral transform that inverts the operation of forming the DGF of a sequence. This inversion is analogous to performing an inverse Z-transform to the generating function of a sequence to express formulas for the series coefficients of a given ordinary generating function.
For now, we will use this page as a compendia of "oddities" and oft-forgotten facts about transforming and inverting Dirichlet series, DGFs, and relating the inversion of a DGF of a sequence to the sequence's summatory function. We also use the notation for coefficient extraction usually applied to formal generating functions in some complex variable, by denoting $[n^{-s}]D_{f}(s)=:f(n)$ for any positive integer $n\geq 1$, whenever
    $D_{f}(s):=\sum _{n\geq 0}{\frac {f(n)}{n^{s}}},\quad \Re (s)>\sigma _{0,f},$
denotes the DGF (or Dirichlet series) of f which is taken to be absolutely convergent whenever the real part of s is greater than the abscissa of absolute convergence, $\sigma _{0,f}\in \mathbb {R}$.
The relation of the Mellin transformation of the summatory function of a sequence to the DGF of a sequence provides us with a way of expressing arithmetic functions $f(n)$ such that $f(1)\neq 0$, and the corresponding Dirichlet inverse functions, $f^{-1}(n)$, by inversion formulas involving the summatory function, defined by
    $S_{f}(x):={\sum _{n\leq x}}^{\prime }f(n),\quad \forall x\geq 1.$
In particular, provided that the DGF of some arithmetic function f has an analytic continuation to $s\mapsto -s$, we can express the Mellin transform of the summatory function of f by the continued DGF formula as
    ${\mathcal {M}}[S_{f}](s)=-{\frac {D_{f}(-s)}{s}}.$
It is often also convenient to express formulas for the summatory functions over the Dirichlet inverse function of f using this construction of a Mellin inversion type problem.

## Preliminaries: Notation, conventions and known results on DGFs
### DGFs for Dirichlet inverse functions

Recall that an arithmetic function is Dirichlet invertible, or has an inverse $f^{-1}(n)$ with respect to Dirichlet convolution such that $(f\ast f^{-1})(n)=\delta _{n,1}$, or equivalently $f\ast f^{-1}=\mu \ast 1\equiv \varepsilon$, if and only if $f(1)\neq 0$. It is not difficult to prove that is $D_{f}(s)$ is the DGF of f and is absolutely convergent for all complex s satisfying $\Re (s)>\sigma _{0,f}$, then the DGF of the Dirichlet inverse is given by $D_{f^{-1}}(s)=1/D_{f}(s)$ and is also absolutely convergent for all $\Re (s)>\sigma _{0,f}$. The positive real $\sigma _{0,f}$ associated with each invertible arithmetic function f is called the abscissa of convergence.
We also see the following identities related to the Dirichlet inverse of some function g that does not vanish at one:
    ${\begin{aligned}(g^{-1}\ast \mu )(n)&=[n^{-s}]\left({\frac {1}{\zeta (s)D_{g}(s)}}\right)\\(g^{-1}\ast 1)(n)&=[n^{-s}]\left({\frac {\zeta (s)}{D_{g}(s)}}\right).\end{aligned}}$

### Summatory functions

Using the same convention in expressing the result of Perron's formula, we assume that the summatory function of a (Dirichlet invertible) arithmetic function $f$, is defined for all real $x\geq 0$ according to the formula
    $S_{f}(x):={\sum _{n\leq x}}^{\prime }f(n)={\begin{cases}0,&0\leq x<1\\\sum \limits _{n<[x]}f(n),&x\in \mathbb {R} \setminus \mathbb {Z} ^{+}\wedge x\geq 1\\\sum \limits _{n\leq [x]}f(n)-{\frac {f(x)}{2}},&x\in \mathbb {Z} ^{+}.\end{cases}}$
We know the following relation between the Mellin transform of the summatory function of f and the DGF of f whenever $\Re (s)>\sigma _{0,f}$:
    $D_{f}(s)=s\cdot \int _{1}^{\infty }{\frac {S_{f}(x)}{x^{s+1}}}dx.$
Some examples of this relation include the following identities involving the Mertens function, or summatory function of the Moebius function, the prime zeta function and the prime-counting function, and the Riemann prime-counting function:
    ${\begin{aligned}{\frac {1}{\zeta (s)}}&=s\cdot \int _{1}^{\infty }{\frac {M(x)}{x^{s+1}}}dx\\P(s)&=s\cdot \int _{1}^{\infty }{\frac {\pi (x)}{x^{s+1}}}dx\\\log \zeta (s)&=s\cdot \int _{0}^{\infty }{\frac {\Pi _{0}(x)}{x^{s+1}}}dx.\end{aligned}}$

## Statements of the integral formula for Dirichlet inversion
### Classical integral formula

For any s such that $\sigma :=\Re (s)>\sigma _{0,f}$, we have that
    $f(x)\equiv [x^{-s}]D_{f}(s)=\lim _{T\rightarrow \infty }{\frac {1}{2T}}\int _{-T}^{T}x^{\sigma +\imath t}D_{f}(\sigma +\imath t)\,dt.$
If we write the DGF of f according to the Mellin transform formula of the summatory function of f, then the stated integral formula simply corresponds to a special case of Perron's formula. Another variant of the previous formula stated in Apostol's book provides an integral formula for an alternate sum in the following form for $c,x>0$ and any real $\sigma >\sigma _{0,f}-c$ where we denote $\Re (s):=\sigma$:
    ${\sum _{n\leq x}}^{\prime }{\frac {f(n)}{n^{s}}}={\frac {1}{2\pi \imath }}\int _{c-\imath \infty }^{c+\imath \infty }D_{f}(s+z){\frac {x^{z}}{z}}dz.$

#### Direct proof: from Apostol's book

* Define the Dirichlet series f(s)=∑$_{n=1}$$^∞$a$_n$n$^{−s}${\textstyle f(s)=\sum _{n=1}^{\infty }a_{n}n^{-s}} and its associated partial sums F(x)=∑$_{n=1}$$^x$a$_n${\textstyle F(x)=\sum _{n=1}^{x}a_{n}}.
* Define the function g(x)=∑$_{n=1}$$^x$a$_n$⌊x/n⌋{\textstyle g(x)=\sum _{n=1}^{x}a_{n}\lfloor x/n\rfloor }.
* Use partial summation to write F(x)=∫$_1$$^x$g(t)dt+a$_1${\textstyle F(x)=\int _{1}^{x}g(t)dt+a_{1}}.
* Apply the Euler–Maclaurin summation formula to obtain an approximation for F(x){\textstyle F(x)} in terms of g(x){\textstyle g(x)} and its derivatives.
* Express the error term in the approximation as an integral of a certain function R(u){\textstyle R(u)} over the interval [1, x]{\textstyle [1, x]}.
* Use Abel's summation formula to express g(x){\textstyle g(x)} as a sum of integrals involving f(s){\textstyle f(s)} and its derivatives.
* Express the integrals involving f(s){\textstyle f(s)} and its derivatives in terms of R(u){\textstyle R(u)} and its derivatives.
* Substitute the results from steps 4, 5, and 7 into the formula from step 3, and simplify to obtain the classical integral formula for Dirichlet inversion.
This proof shows that the function f(s){\textstyle f(s)} can be recovered from its associated Dirichlet series by means of an integral, which is known as the classical integral formula for Dirichlet inversion.

#### Special cases of the formula

If we are interested in expressing formulas for the Dirichlet inverse of f, denoted by $f^{-1}(n)$ whenever $f(1)\neq 0$, we write $D_{f}(s)=1+s\cdot A_{f}(s)$. Then we have by absolute convergence of the DGF for any $\Re (s)>\sigma _{0,f}$ that
    ${\begin{aligned}\int {\frac {x^{\imath t}}{D_{f}(\sigma +\imath t)}}\,dt&=\int \left(\sum _{j\geq 0}(\sigma +\imath t)^{j}\times \sum _{k=0}^{j}(-1)^{k}D_{f}(\sigma +\imath t)^{k}{\frac {\log ^{j-k}(x)}{(j-k)!}}\right)\,dt.\end{aligned}}$
Now we can call on integration by parts to see that if we denote by $F^{(-m)}(x)=\sum _{n\geq 0}{\frac {F^{(n)}(0)}{n!}}x^{n+m}\times {\frac {n!}{(n+m)!}}$ denotes the $m^{th}$ antiderivative of F, for any fixed non-negative integers $k\geq 0$, we have
    $\int (ax+b)^{k}\cdot F(ax+b)\,dx=\sum _{j=0}^{k}{\frac {k!}{a\cdot j!}}(-1)^{k-j}t^{j}F^{(j+1-k)}(ax+b).$
Thus we obtain that
    ${\begin{aligned}\int _{-T}^{T}{\frac {x^{\imath t}}{D_{f}(\sigma +\imath t)}}\,dt&={\frac {1}{\imath }}\left(\sum _{j\geq 0}\sum _{k=0}^{j}\sum _{m=0}^{k}{\frac {k!}{m!}}(-1)^{m}(\sigma +\imath t)^{m}\left[D_{f}^{k}\right]^{(j+1-k)}(\sigma +\imath t){\frac {\log ^{j-k}(x)}{(j-k)!}}\right){\Biggr |}_{t=-T}^{t=+T}.\end{aligned}}$
We also can relate the iterated integrals for the $k^{th}$ antiderivatives of F by a finite sum of k single integrals of power-scaled versions of F:
    $F^{(-k)}(x)=\sum _{i=0}^{k-1}{\binom {k-1}{i}}{\frac {(-1)^{i}}{(k-1)!}}\int {\frac {F(x)}{x^{i}}}\,dx.$
In light of this expansion, we can then write the partially limiting T-truncated Dirichlet series inversion integrals at hand in the form of
    ${\begin{aligned}{\frac {1}{2T}}\int _{-T}^{T}{\frac {x^{\imath t}}{D_{f}(\sigma +\imath t)}}\,dt&={\frac {1}{2T\cdot \imath }}\left(\sum _{j\geq 0}\sum _{k=0}^{j}\sum _{m=0}^{k}\sum _{n=0}^{j-k}{\binom {j-k}{n}}{\frac {(-1)^{k+n+m}\cdot k!}{(j-k)!\cdot m!}}(\sigma +\imath t)^{m}{\frac {\log ^{j-k}(x)}{(j-k)!}}\int _{0}^{\sigma +\imath t}\left[A_{f}^{k}\right](v){\frac {dv}{v^{n}}}\right){\Biggr |}_{t=-T}^{t=+T}\\&={\frac {1}{2T\cdot \imath }}\left(\sum _{j\geq 0}\sum _{k=0}^{j}\sum _{m=0}^{k}{\frac {(-1)^{j-k}\cdot (-s)^{m}}{m!}}{\frac {\log ^{k}(x)}{k!}}\int _{0}^{1}s\cdot D_{f}^{j-k}(rs)\left(1-{\frac {1}{rs}}\right)^{k}\,dv\right){\Biggr |}_{s=\sigma -\imath T}^{s=\sigma +\imath T}\\&={\frac {s\left(e^{-s}+O_{s}(1)\right)}{2T\cdot \imath }}\int _{0}^{1}{\frac {x^{1-{\frac {1}{rs}}}}{1+D_{f}(rs)}}dr{\Biggr |}_{s=\sigma -\imath T}^{s=\sigma +\imath T}\\&={\frac {\left(e^{-s}+O_{s}(1)\right)}{2T\cdot \imath }}\int _{0}^{s}{\frac {x^{1-{\frac {1}{v}}}}{1+D_{f}(v)}}\,dv{\Biggr |}_{s=\sigma -\imath T}^{s=\sigma +\imath T}.\end{aligned}}$

### Statements in the language of Mellin transformations

* The Dirichlet generating function of a sequence $a(n)$ is the Mellin transform of the sequence, evaluated at $s=1$: ∑$_{n=1}$$^∞$ a$_n$/n$^s$=∫$_0$$^∞$x$^{s−1}$(∑$_{n=1}$$^∞$a$_n$e$^{−nx}$)dx=Ma$_n$(s){\textstyle \sum _{n=1}^{\infty }{\frac {a_{n}}{n^{s}}}=\int _{0}^{\infty }x^{s-1}\left(\sum _{n=1}^{\infty }a_{n}e^{-nx}\right)dx={\mathcal {M}}{a_{n}}(s)}.
* The Dirichlet inverse of a sequence $a(n)$ is related to the inverse Mellin transform of its generating function: a$_n$=1/2πi ∫$_{c−i∞}$$^{c+i∞}$ ∑$_{m=1}$$^∞$ μ(m)/m$^s$ Ma$_n$(s)/n$^s$ ds{\textstyle a_{n}={\frac {1}{2\pi i}}\int _{c-i\infty }^{c+i\infty }{\frac {\sum _{m=1}^{\infty }{\frac {\mu (m)}{m^{s}}}{\mathcal {M}}{a_{n}}(s)}{n^{s}}}ds}, where $c$ is a real number greater than the abscissa of convergence of the Dirichlet series ∑$_{n=1}$$^∞$a$_n$/n$^s${\textstyle \sum _{n=1}^{\infty }a_{n}/n^{s}}.
* The Mellin transform of a convolution of two sequences $a(n)$ and $b(n)$ is the product of their Mellin transforms: M(a∗b)$_n$(s)=Ma$_n$(s)Mb$_n$(s){\textstyle {\mathcal {M}}{(a*b)_{n}}(s)={\mathcal {M}}{a_{n}}(s){\mathcal {M}}{b_{n}}(s)}.
* If $a(n)$ is a sequence and $f(x)$ is a function such that the integral ∫$_0$$^∞$ f(x)/(x$^{s+1}$) dx{\textstyle \int _{0}^{\infty }{\frac {f(x)}{x^{s+1}}}dx} converges absolutely and uniformly for $s$ in some right half plane, then we can define a Dirichlet series by a$_n$=1/n$^s$ ∫$_0$$^∞$f(x)e$^{−nx}$dx{\textstyle a_{n}={\frac {1}{n^{s}}}\int _{0}^{\infty }f(x)e^{-nx}dx}, and the Dirichlet series is the Mellin transform of $f(x)$.

### A formal generating-function-like convolution lemma

Suppose that we wish to treat the integrand integral formula for Dirichlet coefficient inversion in powers of $(\imath t)^{k}$ where $[(\imath t)^{k}]F(\sigma +\imath t)=F^{(k)})(\sigma )/k!$, and then proceed as if we were evaluating a traditional integral on the real line. Then we have that
    ${\begin{aligned}{\hat {D}}_{f}(x;\sigma ,T)&:=\int _{-T}^{T}x^{\sigma +\imath t}D_{f}(\sigma +\imath t)\,dt\\&=\sum _{m\geq 0}\int _{-T}^{T}x^{\sigma +\imath t}(\imath t)^{m}{\frac {D_{f}^{(m)}(\sigma )}{m!}}\\&=\sum _{m\geq 0}\int _{-T}^{T}t^{2m}x^{\sigma +\imath t}{\frac {(-1)^{m}D_{f}^{(2m)}(\sigma )}{(2m)!}}\,dt+\imath \times \sum _{m\geq 0}\int _{-T}^{T}t^{2m+1}x^{\sigma +\imath t}{\frac {(-1)^{m}A^{(2m+1)}(\sigma )}{(2m+1)!}}\,dt.\end{aligned}}$
We require the result given by the following formula, which is proved rigorously by an application of integration by parts, for any non-negative integer $m\geq 0$:
    ${\begin{aligned}{\hat {I}}_{m}(T)&:=\int _{-T}^{T}{\frac {(\imath t)^{m}}{m!}}x^{\imath t}\,dt\\&=\sum _{r=0}^{m}{\frac {\left(x^{\imath T}+(-1)^{r+1}x^{-\imath T}\right)(-\imath )^{r+1}}{\log ^{k+1-r}(x)}}\cdot {\frac {T^{r}}{r!}}\\&={\frac {\cos(T\log x)}{T\log x}}\times \sum _{r=0}^{\lfloor k/2\rfloor }{\frac {(-1)^{r+1}T^{2r}}{\log ^{k-2r}(x)(2r)!}}+{\frac {\sin(T\log x)}{T\log x}}\times \sum _{r=0}^{\lfloor k/2\rfloor }{\frac {(-1)^{r+1}T^{2r+1}}{\log ^{k-2r-1}(x)(2r+1)!}}.\end{aligned}}$
So the respective real and imaginary parts of our arithmetic function coefficients f at positive integers x satisfy:
    ${\begin{aligned}\operatorname {Re} (f(x))&=x^{\sigma }\times \lim _{T\rightarrow \infty }\sum _{m\geq 0}D_{f}^{(2m)}(\sigma )\cdot {\frac {{\hat {I}}_{2m}(T)}{2T}}\\\operatorname {Im} (f(x))&=x^{\sigma }\times \lim _{T\rightarrow \infty }\sum _{m\geq 0}D_{f}^{(2m+1)}(\sigma )\cdot {\frac {{\hat {I}}_{2m+1}(T)}{2T}}.\end{aligned}}$
The last identities suggest an application of the Hadamard product formula for generating functions. In particular, we can work out the following identities which express the real and imaginary parts of our function f at x in the following forms:
    ${\begin{aligned}\operatorname {Re} (f(x))&=\lim _{T\rightarrow \infty }\left[{\frac {x^{\sigma }}{2T}}\times {\frac {1}{2\pi }}\int _{-\pi }^{\pi }\left(D_{f}(\sigma +\imath T\cdot e^{\imath s})+D_{f}(\sigma -\imath Te^{\imath s})\right)\left(FUNC(e^{-\imath s})\right)\,ds\right]\\\operatorname {Im} (f(x))&=\lim _{T\rightarrow \infty }\left[{\frac {x^{\sigma }}{2T}}\times {\frac {1}{2\pi }}\int _{-\pi }^{\pi }\left(D_{f}(\sigma +\imath T\cdot e^{\imath s})-D_{f}(\sigma -\imath Te^{\imath s}\right)\,ds\right].\end{aligned}}$
Notice that in the special case where the arithmetic function f is strictly real-valued, we expect that the inner terms in the previous limit formula are always zero (i.e., for any T).