# Natural density

In number theory, natural density, also referred to as asymptotic density or arithmetic density, is one method to measure how "large" a subset of the set of natural numbers is. It relies chiefly on the probability of encountering members of the desired subset when combing through the interval [1, n] as n grows large.
For example, it may seem intuitively that there are more positive integers than perfect squares, because every perfect square is already positive and yet many other positive integers exist besides. However, the set of positive integers is not in fact larger than the set of perfect squares: both sets are infinite and countable and can therefore be put in one-to-one correspondence. Nevertheless if one goes through the natural numbers, the squares become increasingly scarce. The notion of natural density makes this intuition precise for many, but not all, subsets of the naturals (see Schnirelmann density, which is similar to natural density but defined for all subsets of $\mathbb {N}$).
If an integer is randomly selected from the interval [1, n], then the probability that it belongs to A is the ratio of the number of elements of A in [1, n] to the total number of elements in [1, n]. If this probability tends to some limit as n tends to infinity, then this limit is referred to as the asymptotic density of A. This notion can be understood as a kind of probability of choosing a number from the set A. Indeed, the asymptotic density (as well as some other types of densities) is studied in probabilistic number theory.

## Definition

A subset A of positive integers has natural density α if the proportion of elements of A among all natural numbers from 1 to n converges to α as n tends to infinity.
More explicitly, if one defines for any natural number n the counting function a(n) as the number of elements of A less than or equal to n, then the natural density of A being α exactly means that
It follows from the definition that if a set A has natural density α then 0 ≤ α ≤ 1.

### Upper and lower asymptotic density

Let $A$ be a subset of the set of natural numbers $\mathbb {N} =\{1,2,\ldots \}.$ For any $n\in \mathbb {N}$, define $A(n)$ to be the intersection $A(n)=\{1,2,\ldots ,n\}\cap A,$ and let $a(n)=|A(n)|$ be the number of elements of $A$ less than or equal to $n$.
Define the upper asymptotic density ${\overline {d}}(A)$ of $A$ (also called the "upper density") by ${\overline {d}}(A)=\limsup _{n\rightarrow \infty }{\frac {a(n)}{n}}$ where lim sup is the limit superior.
Similarly, define the lower asymptotic density ${\underline {d}}(A)$ of $A$ (also called the "lower density") by ${\underline {d}}(A)=\liminf _{n\rightarrow \infty }{\frac {a(n)}{n}}$ where lim inf is the limit inferior. One may say $A$ has asymptotic density $d(A)$ if ${\underline {d}}(A)={\overline {d}}(A)$, in which case $d(A)$ is equal to this common value.
This definition can be restated in the following way: $d(A)=\lim _{n\rightarrow \infty }{\frac {a(n)}{n}}$ if this limit exists.
These definitions may equivalently be expressed in the following way. Given a subset $A$ of $\mathbb {N}$, write it as an increasing sequence indexed by the natural numbers: $A=\{a_{1}<a_{2}<\ldots \}.$ Then ${\underline {d}}(A)=\liminf _{n\rightarrow \infty }{\frac {n}{a_{n}}},$ ${\overline {d}}(A)=\limsup _{n\rightarrow \infty }{\frac {n}{a_{n}}}$ and $d(A)=\lim _{n\rightarrow \infty }{\frac {n}{a_{n}}}$ if the limit exists.
A somewhat weaker notion of density is the upper Banach density $d^{*}(A)$ of a set $A\subseteq \mathbb {N} .$ This is defined as $d^{*}(A)=\limsup _{N-M\rightarrow \infty }{\frac {|A\cap \{M,M+1,\ldots ,N\}|}{N-M+1}}.$

## Properties and examples

* For any finite set F of positive integers, d(F) = 0.
* If d(A) exists for some set A and A$^c$ denotes its complement set with respect to $\mathbb {N}$, then d(A$^c$) = 1 − d(A).
** Corollary: If $F\subset \mathbb {N}$ is finite (including the case $F=\emptyset$), $d(\mathbb {N} \setminus F)=1.$
* If $d(A),d(B),$ and $d(A\cup B)$ exist, then $\max\{d(A),d(B)\}\leq d(A\cup B)\leq \min\{d(A)+d(B),1\}.$
* If $A=\{n^{2}:n\in \mathbb {N} \}$ is the set of all squares, then d(A) = 0.
* If $A=\{2n:n\in \mathbb {N} \}$ is the set of all even numbers, then d(A) = 0.5. Similarly, for any arithmetical progression $A=\{an+b:n\in \mathbb {N} \}$ we get $d(A)={\tfrac {1}{a}}.$
* For the set P of all primes we get from the prime number theorem that d(P) = 0.
* The set of all square-free integers has density ${\tfrac {6}{\pi ^{2}}}.$ More generally, the set of all nth-power-free numbers for any natural n has density ${\tfrac {1}{\zeta (n)}},$ where $\zeta (n)$ is the Riemann zeta function.
* The set of abundant numbers has non-zero density. Marc Deléglise showed in 1998 that the density of the set of abundant numbers is between 0.2474 and 0.2480.
* The set $A=\bigcup _{n=0}^{\infty }\left\{2^{2n},\ldots ,2^{2n+1}-1\right\}$ of numbers whose binary expansion contains an odd number of digits is an example of a set which does not have an asymptotic density, since the upper density of this set is ${\overline {d}}(A)=\lim _{m\to \infty }{\frac {1+2^{2}+\cdots +2^{2m}}{2^{2m+1}-1}}=\lim _{m\to \infty }{\frac {2^{2m+2}-1}{3(2^{2m+1}-1)}}={\frac {2}{3}},$ whereas its lower density is ${\underline {d}}(A)=\lim _{m\to \infty }{\frac {1+2^{2}+\cdots +2^{2m}}{2^{2m+2}-1}}=\lim _{m\to \infty }{\frac {2^{2m+2}-1}{3(2^{2m+2}-1)}}={\frac {1}{3}}.$
* The set of numbers whose decimal expansion begins with the digit 1 similarly has no natural density: the lower density is 1/9 and the upper density is 5/9. (See Benford's law.)
* Consider an equidistributed sequence $\{\alpha _{n}\}_{n\in \mathbb {N} }$ in $[0,1]$ and define a monotone family $\{A_{x}\}_{x\in [0,1]}$ of sets: $A_{x}:=\{n\in \mathbb {N} :\alpha _{n}<x\}.$ Then, by definition, $d(A_{x})=x$ for all $x$.
* If S is a set of positive upper density then Szemerédi's theorem states that S contains arbitrarily large finite arithmetic progressions, and the Furstenberg–Sárközy theorem states that some two members of S differ by a square number.

## Other density functions

Other density functions on subsets of the natural numbers may be defined analogously. For example, the logarithmic density of a set A is defined as the limit (if it exists)
    $\mathbf {\delta } (A)=\lim _{x\rightarrow \infty }{\frac {1}{\log x}}\sum _{n\in A,n\leq x}{\frac {1}{n}}\ .$
Upper and lower logarithmic densities are defined analogously as well.
For the set of multiples of an integer sequence, the Davenport–Erdős theorem states that the natural density, when it exists, is equal to the logarithmic density.