# Dirichlet hyperbola method

In number theory, the Dirichlet hyperbola method is a technique to evaluate the sum

${\displaystyle F(n)=\sum _{k=1}^{n}f(k),}$

where ${\displaystyle f}$ is a multiplicative function. The first step is to find a pair of multiplicative functions ${\displaystyle g}$ and ${\displaystyle h}$ such that, using Dirichlet convolution, we have ${\displaystyle f=g\ast h}$; the sum then becomes

${\displaystyle F(n)=\sum _{k=1}^{n}\sum _{xy=k}^{}g(x)h(y),}$

where the inner sum runs over all ordered pairs ${\displaystyle (x,y)}$ of positive integers such that ${\displaystyle xy=k}$. In the Cartesian plane, these pairs lie on a hyperbola, and when the double sum is fully expanded, there is a bijection between the terms of the sum and the lattice points in the first quadrant on the hyperbolas of the form ${\displaystyle xy=k}$, where ${\displaystyle k}$ runs over the integers ${\displaystyle 1\leq k\leq n}$: for each such point ${\displaystyle (x,y)}$, the sum contains a term ${\displaystyle g(x)h(y)}$, and vice versa.

Let ${\displaystyle a}$ be a real number, not necessarily an integer, such that ${\displaystyle 1, and let ${\displaystyle b=n/a}$. Then the lattice points can be split into three overlapping regions: one region is bounded by ${\displaystyle 1\leq x\leq a}$ and ${\displaystyle 1\leq y\leq n/x}$, another region is bounded by ${\displaystyle 1\leq y\leq b}$ and ${\displaystyle 1\leq x\leq n/y}$, and the third is bounded by ${\displaystyle 1\leq x\leq a}$ and ${\displaystyle 1\leq y\leq b}$. In the diagram, the first region is the union of the blue and red regions, the second region is the union of the red and green, and the third region is the red. Note that this third region is the intersection of the first two regions. By the principle of inclusion and exclusion, the full sum is therefore the sum over the first region, plus the sum over the second region, minus the sum over the third region. This yields the formula

 ${\displaystyle F(n)=\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).}$ (1)

## Examples

Let ${\displaystyle \sigma _{0}(n)}$ be the divisor-counting function, and let ${\displaystyle D(n)}$ be its summatory function:

${\displaystyle D(n)=\sum _{k=1}^{n}\sigma _{0}(k).}$

Computing ${\displaystyle D(n)}$ naïvely requires factoring every integer in the interval ${\displaystyle [1,n]}$; an improvement can be made by using a modified Sieve of Eratosthenes, but this still requires ${\displaystyle {\widetilde {O}}(n)}$ time. Since ${\displaystyle \sigma _{0}}$ admits the Dirichlet convolution ${\displaystyle \sigma _{0}=1\ast 1}$, taking ${\displaystyle a=b={\sqrt {n}}}$ in (1) yields the formula

${\displaystyle D(n)=\sum _{x=1}^{\sqrt {n}}\sum _{y=1}^{n/x}1\cdot 1+\sum _{y=1}^{\sqrt {n}}\sum _{x=1}^{n/y}1\cdot 1-\sum _{x=1}^{\sqrt {n}}\sum _{y=1}^{\sqrt {n}}1\cdot 1,}$

which simplifies to

${\displaystyle D(n)=2\cdot \sum _{x=1}^{\sqrt {n}}\left\lfloor {\frac {n}{x}}\right\rfloor -\left\lfloor {\sqrt {n}}\right\rfloor ^{2},}$

which can be evaluated in ${\displaystyle O\left({\sqrt {n}}\right)}$ operations.

The method also has theoretical applications: for example, Peter Gustav Lejeune Dirichlet introduced the technique in 1849 to obtain the estimate[1][2]

${\displaystyle D(n)=n\log n+(2\gamma -1)n+O({\sqrt {n}}),}$

where ${\displaystyle \gamma }$ is the Euler–Mascheroni constant.

## References

1. ^ Dirichlet, Peter Gustav Lejeune (1849). "Über die Bestimmung der mittleren Werthe in der Zahlentheorie". Abhandlungen der Königlich Preussischen Akademie der Wissenchaften (in German): 49–66 – via Gallica.
2. ^ Tenenbaum, Gérald (2015-07-16). Introduction to Analytic and Probabilistic Number Theory. American Mathematical Soc. p. 44. ISBN 9780821898543.