Arithmetic Progressions with Restricted Digits

Abstract: For an integer $b \geqslant 2$ and a set $S\subset \{0,\cdots,b-1\}$, we define the Kempner set $\mathcal{K}(S,b)$ to be the set of all non-negative integers whose base-$b$ digital expansions contain only digits from $S$. These well-studied sparse sets provide a rich setting for additive number theory, and in this paper we study various questions relating to the appearance of arithmetic progressions in these sets. In particular, for all $b$ we determine exactly the maximal length of an arithmetic progression that omits a base-$b$ digit.

\section{Introduction}

In 1914 Kempner \cite{Ke14} introduced a variant of the harmonic series which excluded from its sum all those positive integers that contain the digit $9$ in their base-$10$ expansions.  Unlike the familiar harmonic series, Kempner's modified series converges (the limit later shown to be $\approx 22.92$, see \cite{Ba79}).  A simple generalisation of Kempner's original argument shows that convergence occurs as long as any non-empty set of digits is excluded, and that this result holds in any base (see \cite{BS08}, for example).

Let us introduce some notation to describe these results in general. Fix an integer $b \geqslant 2$ and a subset of integers $S \subseteq [0,b-1]$. Here and throughout the paper, for two integers $x$ and $y$ we use $[x,y]$ to denote the set $\{n\in\mathbb{Z}:x \leqslant n\leqslant y\}$.  We then define the \emph{Kempner set} $\mathcal{K}(S,b)$ to be the set of non-negative integers that, when written in base $b$, contain only digits from $S$. Thus $\mathcal{K}([0,8],10)$ denotes the set originally studied by Kempner. We will assume throughout that $0 \in S$, to avoid the ambiguity of leading zeros, and require $S \neq [0,b-1]$, to preclude the trivial set $\mathcal{K}([0,b-1],b)$ (which is nothing more than $\mathbb{Z}_{\geqslant 0}$). These sets $S$ will be referred to as the \emph{permitted} sets $S$, and the related Kempner sets $K(S,b)$ as \emph{proper} Kempner sets.

The arithmetic properties of proper Kempner sets have been the object of considerable study in recent years, beginning with the work of Erd\H{o}s, Mauduit, and S\'ark\"ozy, who studied the distribution of residues in $\mathcal{K}(S,b)$ moduli small numbers \cite{EMS98} and proved the existence of integers in $\mathcal{K}(S,b)$ with many small prime factors \cite{EMS99}.
Notable recent work includes Maynard's proof \cite{May16} that the sets $\mathcal{K}(S,b)$ contain infinitely many primes whenever $b-\vert S\vert$ is at most $b^{23/80}$, provided $b$ is sufficiently large.

In this paper we consider the additive structure of proper Kempner sets. In particular, we consider the following extremal question: \emph{what is the length of the longest arithmetic progression in a proper Kempner set with a fixed given base?} Our methods will be combinatorial, rather than analytic (as in Maynard's work, \cite{May16}).

A well known conjecture of Erd\H{o}s-Tur\'{a}n (first given in \cite{ErTu36}) states that any set of positive integers with a divergent harmonic sum contains arithmetic progressions of arbitrary (finite) length. Since proper Kempner sets have convergent harmonic sums, this might suggest that the lengths of arithmetic progressions in a given proper Kempner set are uniformly bounded.

This is indeed the case.  Let us say that a set $T\subset \mathbb{Z}$ is $k$-free if $T$ contains no arithmetic progression of length $k$. By a simple argument, given in Proposition \ref{prop:ell_finite}, one may show that the proper Kempner set $\mathcal{K}(S,b)$ is $(b^2-b+1)$-free for any $b \geqslant 2$.

The main purpose of this article is to understand how close this trivial upper bound is to the truth. \\

In our main theorem, we improve this bound for all $b> 2$, obtaining a tight result that expresses the length of the longest arithmetic progression in $\mathcal{K}(S,b)$ in terms of the prime factorisation of $b$. To state this theorem, we need to introduce some arithmetic functions. If $n$ and $b$ are natural numbers, let $\rho(n)$ denote the square-free radical of $n$ (ie. the product of all distinct primes dividing $n$), and let $\beta(b)$ denote the largest integer less than $b$ such that $\rho(\beta(b))\vert b$.
For example, $\beta(10) = 8$, and $\beta(p^k) = p^{k-1}$ for any prime power $p^k$. In other words, $\beta(b)$ is the greatest integer less than $b$ that divides some power of $b$. Finally, let $\ell(b)$ be the length of the longest arithmetic progression contained in some proper Kempner set of base $b$.

Our main theorem gives an exact evaluation of $\ell(b)$.

\begin{theorem}
\label{thm:main theorem} For all $b\geqslant 2$, one has $\ell(b) = (b-1)\beta(b)$.
\end{theorem}
\noindent For example, $\ell(10)=72$. One particular set that achieves this bound is Kempner's original set, $\mathcal{K}([0,8],10)$, which contains the $72$-term arithmetic progression $\{0,125,250,375,\cdots,8875\}$.\\

The arithmetic functions $\beta(b)$ and $\ell(b)$ are of independent interest, but do not appear to have been considered seriously before.\footnote{The sequence $\beta(b)$ is entry A079277 on the Online Encyclopedia of integer Sequences.} We establish average order results for $\beta(b)$ which show that, for most $b$, the trivial upper bound on $\ell(b)$ from Proposition \ref{prop:ell_finite} is asymptotically correct.

\begin{theorem}
\label{thm: ell nearly always maximal epsilon free}
There is a set of integers $A\subset \mathbb{Z}$ with natural density $1$, i.e. with \[ \lim\limits_{N\rightarrow \infty} \frac{1}{N}\vert A\cap [1,N]\vert  = 1,\] such that $\ell(b)\sim b^2$ as $b\rightarrow \infty$ in $A$.
\end{theorem}
\noindent
\textit{Notation:} For $x\in \mathbb{R}$, let $\{x\}$ denote the fractional part of $x$ and let $ \lfloor x \rfloor$ denote the greatest integer that is at most $x$. For a natural number $n$, we let $[n]$ denote the set of integers $\{1,\cdots,n\}$. As mentioned previously, for two integers $x$ and $y$ we use $[x,y]$ to denote the set $\{ n\in \mathbb{Z}: x\leqslant n\leqslant y\}$. We use the notation $\log_q p$ to denote the logarithm of $p$ to base $q$ (as opposed to any iterations of logarithms).\\

\section{Progressions of Maximal Length in Kempner Sets}

In this section we give our proof of Theorem \ref{thm:main theorem}, which is an exact evaluation of $\ell(b)$ and the main result of this paper.  This will be done in two parts: a constructive lower bound and a proof that this lower bound is sharp.  Before that, as promised, we give a simple proof that the function $\ell(b)$ is at least well-defined, i.e. that Kempner sets do not contain arbitrarily long arithmetic progressions.

\begin{proposition} \label{prop:ell_finite}
For all $b\geqslant 2$, we have $\ell(b) \leqslant (b-1)b$.
\end{proposition}

\begin{proof}  Suppose that $A \subset \mathcal{K}(S,b)$ is a finite arithmetic progression of $\vert A\vert$ terms with common difference $\Delta$. Choose $k \geqslant 0$ such that $b^k \leqslant \Delta < b^{k+1}$.  If $I$ denotes the shortest interval of integers containing $A$, then $\vert I \vert = (\vert A \vert-1)\Delta+1$, hence $\vert A\vert = 1+ (\vert I\vert -1)/\Delta$.

If $A$ excludes the digit $d$, the upper bound $\Delta < b^{k+1}$ confines $A$ within the interval $[0,db^{k+1} - 1]$ or within an interval of the form
\[[b^{k+2} m + (d+1) b^{k+1}, b^{k+2}(m+1)+ db^{k+1}-1],\]
for some $m\in \mathbb{Z}_{\geqslant 0}$. Thus $\vert I\vert \leqslant  b^{k+2}-b^{k+1}$, which yields
\[\vert A\vert \leqslant 1 + \frac{b^{k+2}-b^{k+1}-1}{\Delta} < 1 + \frac{b^{k+2} - b^{k+1}}{b^{k}} \leqslant b^2-b+1,\]
hence $\vert A\vert  \leqslant b^2-b$ as claimed.
\end{proof}

The bound in the previous proposition is simple and -- as a consequence -- occasionally weak.  In particular, it neglects the potentially compounding effects of digit exclusion at different orders of magnitude, and the arithmetic properties of orbits in the group $\mathbb{Z}/b\mathbb{Z}$. This structure can affect the bounds dramatically, as seen most clearly in the case when the base $b$ is prime.

\begin{proposition}
\label{prime prop}
Let $p$ be prime. Then $\ell(p) \leqslant p-1$.
\end{proposition}
\begin{proof} Suppose that $\mathcal{K}(S,p)$ contains the progression $A = \{k+ j \Delta : j \in [p]\}$ with $\Delta\neq 0$.  By the pigeonhole principle, there exist distinct $i,j\in [p]$ with $k+j \Delta \equiv k+i \Delta \!\!\mod p$ for some $i\neq j$, hence $p \mid \Delta$ (since $p$ is prime).  By deleting the rightmost digits of the elements of $A$ we obtain a new progression in $\mathcal{K}(S,p)$ with common difference $\Delta/p$; in particular, the progression
$$\left\{\left\lfloor \frac{k}{p} \right\rfloor + j\frac{\Delta}{p}: j\in [p]\right\}.$$
The new common difference is strictly smaller, and we obtain a contradiction by infinite descent.
\end{proof}

With a little more bookkeeping this proof generalizes to prime powers, and implies that $\ell(p^k) \leqslant p^{k-1}(p^k-1)$. So certainly $\ell(b)$ is not asymptotic to $b^2$ as $b$ ranges over all integers; some restriction in Theorem \ref{thm: ell nearly always maximal epsilon free} is required.\\

We now begin the proof of Theorem \ref{thm:main theorem}. Searching for long progressions in $\mathcal{K}([0,8],10)$, one might happen across the example noted earlier, namely the first $71$ multiples of $125$, which -- together with $0$ -- form an arithmetic progression of length $72$, none of whose members contain the digit 9. This example succeeds due to properties of the prime factorisation of $1000/125$, in relation to the base $10$. These properties generalise, and one may use this to construct long digit-excluding arithmetic progressions in arbitrary bases.

\begin{proposition}
\label{prop:AP construction} For all $b \geqslant 2$, the Kempner set $\mathcal{K}([0,b-2],b)$ contains an arithmetic progression of length $(b-1)\beta(b)$. Hence $\ell(b) \geqslant (b-1)\beta(b)$.
\end{proposition}

\begin{proof}
Let $K\geqslant 1$ be the smallest natural number such that $\beta(b)\vert b^K$. We claim that all the members of the arithmetic progression $$ A = \frac{b^K}{\beta(b)}[0,(b-1)\beta(b)-1]$$ exclude the digit $b-1$ from their base-$b$ expansions. To see this, let $k$ satisfy $0\leqslant k\leqslant K-1$.
Then $\gcd(b^{k+1}\beta(b),b^{K})\geqslant b^{k+1}>b^k\beta(b)$, which implies that $\gcd(b^{k+1},b^K/\beta(b))>b^k$ (by dividing through by $\beta(b)$).
In particular, for all integers $x$ and $y$, either
\begin{equation}
\label{separation condition}
\left\vert x \frac{b^K}{\beta(b)} - y b^{k+1}\right\vert>b^k \qquad \text{or} \qquad x  \frac{b^K}{\beta(b)} = y b^{k+1}.
\end{equation}

This observation implies that none of the $K$ rightmost digits of any integer of the form $xb^K/\beta(b)$ can be equal to $b-1$. Indeed, in base $b$, the $b^{k}$ digit of $x b^K/\beta(b)$ is the unique integer $d$ in the range $0\leqslant d\leqslant b-1$ such that
\[\left\{\frac{xb^K/\beta(b)}{b^{k+1}} \right\}\in \left[\frac{d}{b},\frac{d+1}{b}\right).\]
Yet~\eqref{separation condition} implies that $\{\frac{x b^K}{b^{k+1}\beta(b)}\} \in \{0\} \cup (\frac{1}{b}, \frac{b-1}{b})$ for each $0 \leqslant k \leqslant K-1$.  Since this is disjoint from $[\frac{b-1}{b},1)$, we conclude that none of the $K$ rightmost digits of any integer of the form $x b^K/\beta(b)$ can be equal to $b-1$.

We now fix $x \in [0,(b-1)\beta(b)-1]$ and consider the leftmost digits of $x b^K/\beta(b)$. Certainly $x b^K/\beta(b) < (b-1)b^K$.  From this upper bound we see that the $b^{K}$ digit of $x b^K/\beta(b)$ lies in $[0,b-2]$ and that the digits associated to larger powers of $b$ are all $0$.  Combining this with our previous observations, we conclude that $xb^K/\beta(b)$ omits the digit $(b-1)$ for all $x \in [0,(b-1) \beta(b)-1]$, so $A \subset \mathcal{K}([0,b-2],b)$ as claimed.  Since $\vert A\vert = (b-1)\beta(b)$, we have $\ell(b) \geqslant (b-1)\beta(b)$.
\end{proof}

We now proceed with the second half of our evaluation of $\ell(b)$, the verification that this lower bound is exact. This requires a more technical argument.

\begin{proposition} \label{prop:upper_bound}
For all $b\geqslant 2$, we have $\ell(b) \leqslant (b-1)\beta(b)$.
\end{proposition}

\begin{proof}
Without loss of generality, let $S\subset [0,b-1]$ be any set of $b-1$ digits (containing $0$), and let $A = \{x+ j \Delta : j \in [0,\ell(b)-1]\}$ be an arithmetic progression in $\mathcal{K}(S,b)$ of maximal length, in which $\Delta > 0$ is taken minimally over all arithmetic progressions of length $\ell(b)$.

Let $\Delta = d_K b^K + \ldots + d_1 b + d_0$ denote the base $b$ expansion of $\Delta$, where $K$ is chosen such that $d_K \neq 0$.  For notational convenience, let $\Delta_k:= d_k b^k + \ldots +d_1b + d_0$ for each $k \geqslant 0$. (Note that $\Delta_k = \Delta$ for $k \geqslant K$.) We may assume without loss of generality that $d_0 \neq 0$, else by removing the rightmost digit from all elements of $A$ one constructs an arithmetic progression contained in $\mathcal{K}(S,b)$ of common difference $\Delta/b$, contradicting our minimality assumption on $\Delta$. (This is the same device as we used in the proof of Proposition \ref{prime prop}).

Our proof of Proposition~\ref{prop:upper_bound} rests on the following claim, whose peculiar statement arises naturally from an inductive argument.
\begin{claim}
Consider the following statements:
\begin{itemize}
\item[\emph{C}$1$:] $\ell(b)\leqslant (b-1)\beta(b)$;
\item[\emph{C}$2$\emph{(}k\emph{)}:] there exist coprime integers $\lambda_k,\mu_k \in [1,b-1]$ satisfying\\ $\lambda_k \Delta_k = \mu_k b^{k+1}$.
\end{itemize}
Then either \emph{C1} holds or \emph{C2(}k\emph{)} holds for all $k \geqslant 0$.
\end{claim}

This claim immediately settles the theorem, since the statement C2($k$) cannot possibly hold for all $k\geqslant 0$. Indeed, we have $\lambda_k \Delta_k < b \Delta$, while $\mu_k b^{k+1}$ grows in $k$ without bound.
\end{proof}

\begin{proof}[Proof of Claim]
We prove this claim by induction, showing that for every $k\geqslant 0$, either C1 holds or C2($k^\prime$) holds for all $k^\prime\leqslant k$. For the base case $k=0$, note that $\Delta_k = d_0$.  If $(d_0,b)=1$, then $d_0$ generates the additive group $\mathbb{Z}/b \mathbb{Z}$ and the elements $\{x + j \Delta : j \in [0,b-1]\}$ have $b$ distinct units digits.  Thus $\ell(b) \leqslant (b-1) \leqslant (b-1)\beta(b)$, so C1 holds.

Otherwise, $(d_0,b)>1$, which implies that there exists $\lambda \in [1,b-1]$ for which $\lambda d_0 \equiv 0 \!\! \mod b$.  Thus $\lambda d_0 = \mu b$ for some $\mu$, and we may assume that $(\lambda,\mu)=1$ by dividing through by common factors.  This concludes the base case.

Proceeding to the inductive step, let $k\geqslant 1$ and assume that the inductive hypothesis C2($k^\prime$) holds for all smaller $k^\prime$. In particular, $\Delta_{k-1} = (\mu_{k-1}/\lambda_{k-1}) b^k$ for some coprime integers $\lambda_{k-1},\mu_{k-1}\in [1,b-1]$, and hence $\Delta_k = d_k b^k + (\mu_{k-1}/\lambda_{k-1}) b^k$.

Let $\lambda_k$ denote the order of $\Delta_k/b^{k+1}$ in the additive group $\mathbb{R}/\mathbb{Z}$, and let $\mu_k$ denote the integer $\lambda_k (\Delta_k/b^{k+1})$. We see that $(\lambda_k,\mu_k)=1$, as one could divide through by any common factors of $\lambda_k$ and $\mu_k$ to contradict the fact that $\lambda_k$ is the order of $\Delta_k/b^{k+1}$ in $\mathbb{R}/\mathbb{Z}$. Now, if $\lambda_k < b$, then $\mu_k < b$ as well, since $\Delta_k/b_{k+1}<1$ for any $k$.  In this case, $\lambda_k$ and $\mu_k$ satisfy the conditions listed in C2($k$). Therefore C2($k^\prime$) holds for all $k^\prime \leqslant k$.

It remains to address the case $\lambda_k \geqslant b$. By usual facts about finite subgroups of $\mathbb{R}/\mathbb{Z}$, we note that the orbit of $\Delta_k/b^{k+1}$ in $\mathbb{R}/\mathbb{Z}$ is exactly the set of fractions with denominator dividing $\lambda_k$.  In particular, the set of values
\[T=\left\{\frac{x}{b^{k+1}} + \frac{\Delta_k j}{b^{k+1}} \!\! \mod 1 : j \in [0,\lambda_k -1]\right\}\]
are equally spaced, with gaps of size $1/\lambda_k$.  Since $\lambda_k \geqslant b$, for any integer $d \in [0,b-1]$ at least one member of $T$ lies in the half-open interval $[\frac{d}{b},\frac{d+1}{b})$. In other words, at least one member of the progression $x + \Delta_k[0,\lambda_k-1]$ has $b^{k}$ digit equal to $d$.

This information immediately implies that $x+\Delta[0,\lambda_k-1]$ is not contained in any proper Kempner set $\mathcal{K}(S,b)$, and hence $\ell(b) \leqslant \lambda_k -1$.  However, more can be said with a slight refinement to our analysis.  Equal spacing implies that at least $\lfloor \lambda_k/b \rfloor$ members of $T$ lie in the interval $[\frac{d}{b},\frac{d+1}{b})$. We are left with the stronger bound $\ell(b) \leqslant \lambda_k - \lfloor \lambda_k/b\rfloor$.

We now establish an upper bound on the function $\lambda_k - \lfloor \lambda_k/b\rfloor$, given the known constraints on $\lambda_k$.  For starters, the inductive hypothesis implies that $\lambda_{k-1} \mid \mu_{k-1} b^{k}$, hence $\lambda_{k-1} \mid b^{k}$ (since $\lambda_{k-1}$ and $\mu_{k-1}$ are coprime).  Since $\lambda_{k-1} < b$ and $\lambda_{k-1}$ divides a power of $b$, this implies that $\lambda_{k-1} \leqslant \beta(b)$.  Secondly, the inductive hypothesis allows us to write
\[\frac{\Delta_k}{b^{k+1}} = \frac{d_k \lambda_{k-1} + \mu_{k-1}}{b \lambda_{k-1}},\]
which implies that $b\lambda_{k-1} (\Delta_k/b^{k+1}) \equiv 0 \!\! \mod 1$.  This implies that $b \lambda_{k-1}$ is a multiple of the order of $(\Delta_k/b^{k+1}) \!\!\mod 1$, ie. $\lambda_k \mid b \lambda_{k-1}$.  We conclude that $\lambda_k \leqslant b \lambda_{k-1} \leqslant b\beta(b)$.

The function $\lambda \mapsto \lambda - \lfloor \lambda/b \rfloor$ is non-decreasing as $\lambda$ increases over integers, hence
\[\ell(b) \leqslant \lambda_k - \left\lfloor \frac{\lambda_k}{b}\right\rfloor \leqslant b \beta(b) - \left\lfloor \frac{b \beta(b)}{b}\right\rfloor =b \beta(b) - \beta(b)= (b-1)\beta(b),\]
which implies that C1 holds. This completes the inductive step, and so completes the proof of Theorem \ref{thm:main theorem}.
\end{proof}

\section{Asymptotic Analysis}

In this section we analyse the function $\beta(b)$, with the ultimate goal of proving Theorem \ref{thm: ell nearly always maximal epsilon free}. We begin with the following simple observation.

\begin{proposition} \label{prop:betabounds1}
We have
\[\liminf_{n \to \infty} \frac{\beta(n)}{n} =0 \quad \text{and} \quad \limsup_{n \to \infty} \frac{\beta(n)}{n} =1.\]
\end{proposition}

\begin{proof}
The first claim follows from the observation that $\beta(p) = 1$ for all primes $p$.  For the second, we note that $\beta(2^k+2)=2^k$ for all $k>1$.
\end{proof}

It is clear from this proposition that the behaviour of $\beta(n)$ is erratic as $n$ varies. However, its calculation may be understood as a certain integer programming problem, as illustrated by the following example.

\begin{example} \label{example:beta24}
In this example, we calculate $\beta(24)$ using techniques from mixed integer programming.  We may write $\beta(24)=2^a\cdot 3^b$, with $a,b \in \mathbb{N}$.  It follows that $a \log 2 + b \log 3 < \log 24$, and $(a,b)$ may be visualized as a lattice point in the following figure (Figure \ref{fig1}). The equation of the line is $f(x) = \log_3 24-x\log_3 2 $.

\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{plot1}
\caption{Lattice points $(a,b)$ corresponding to $\beta(24)=2^a\cdot3^b$.}
\label{fig1}
\end{figure}
Let us restrict our attention to the set $S$ of lattice points of the form $(a,b)$, in which $b$ is taken maximally for fixed $a$.  If $(a,b) \in S$, the vertical distance from $(a,b)$ to the diagonal in Figure \ref{fig1} is then given by $\{\log_3 24 - a\log_3 2\}$. We also note that $a\log 2 + b \log 3$ is maximized among the lattice points below the line when $(a,b) \in S$ and $\{\log_3 24 - a \log_3 2\}$ is minimized (as a function of $a$). In our example, minimization occurs at $(a,b)=(1,2)$, and so we obtain $\beta(24)=2^1 \cdot 3^2=18$.
\end{example}

The technique of Example \ref{example:beta24} generalizes easily: if $n$ has $k$ prime divisors $p_1,\ldots,p_k$, we may associate to $n$ a set of lattice points in $\mathbb{Z}^k$, namely \[ \{ (a_1,\cdots,a_k) \in \mathbb{Z}_{\geqslant 0}^k : a_1\log p_1 + \cdots + a_k \log p_k < \log n\}.\] The lattice point $(a_1,\ldots, a_k)$ that minimizes distance to the the hyperplane
\[x_1 \log p_1 + \ldots x_k \log p_k = \log n\]
determines $\beta(n)$ by the formula $\beta(n)= \prod_{i=1}^k p_i^{a_i}$.  \\

Combining this idea with well-known equidistribution results gives the following.

\begin{lemma} \label{thm:beta_asymp_along_AP}
We have $\beta(n) \sim n$ as $n \to \infty$ within $N\mathbb{Z}$ if and only if $N$ is not a prime power.
\end{lemma}

\begin{proof}
If $N=p^k$ is a prime power, then $N\mathbb{Z}$ contains the subsequence $\{p^{kn}\}_{n \geqslant 1}$.  Since $\beta(p^{kn})=p^{kn-1}$, we cannot have $\beta(n) \sim n$ within $N\mathbb{Z}$.

Otherwise, let $p$ and $q$ be distinct primes dividing $N$, and fix a positive constant $\varepsilon$. As $\log_q p$ is irrational, the sequence $(\{u_n\})_{n=0}^\infty$ given by $u_n := n\cdot\log_q p$ is equidistributed mod $1$ (by the Equidistribution Theorem: see Proposition 21.1 of \cite{IwKo04}, say). In particular, there exists a positive parameter $L_\varepsilon$ such that $l>L_\varepsilon$ implies that the sequence $(\{ u_n\})_{n=0}^l$ contains at least one element in each interval mod $1$ of length $\varepsilon$.

Now let $m$ be a natural number and let $l = \lfloor \log_p m \rfloor$. From the above remarks, there exists a positive parameter $M_\varepsilon$ such that, for each $m>M_\varepsilon$, the shifted sequence $(\{\log_q m - u_n \})_{n=0}^l$ contains some element in the interval $(0,\varepsilon)$. In other words there exists $n_0$ at most $l$ (but dependent on $l$) such that
\[0 < \{\log_q m - n_0 \cdot \log_q p\}<\varepsilon.\] Also note that $\log_q m - n_0 \cdot \log_q p $ is positive.

Now, assume $pq \mid m$ and consider $(a,b):=(n_0,\lfloor \log_q m - n_0 \cdot \log_q p \rfloor )$. We have $\beta(m) \geqslant p^a \cdot q^b$ by construction. So
\[\beta(m)\geqslant p^a \cdot q^b = q^{\log_q m - \{\log_q m - n_0 \cdot \log_q p \}} > q^{\log_q m - \varepsilon}=m \cdot q^{-\varepsilon}.\]
Thus $q^{-\varepsilon} < \beta(m)/m < 1$, for all $m$ satisfying $m>M_\varepsilon$ and $pq \mid m$.  Since $\varepsilon$ was arbitrary, and $q$ fixed, it follows that $\beta(m) \sim m$ within $pq\mathbb{Z}$, and hence within $N\mathbb{Z}$.
\end{proof}

By considering $N=6$, for example, we obtain a set of density $1/6$ (namely, $6\mathbb{Z}$) on which $\ell(b) \sim b^2$ as $b$ tends to infinity within that set. Any finite union of such sets $N_i\mathbb{Z}$, where $N_i$ has two distinct prime factors $p_i$ and $q_i$, will also have this property, and one may show with relative ease that such a union may be arranged to have natural density arbitrarily close to $1$.

However, by quantifying estimates made in the previous lemma, we can do slightly better, and show the existence of a set with the desired property that has density $1$, thereby proving Theorem \ref{thm: ell nearly always maximal epsilon free}.

\begin{proof}[Proof of Theorem \ref{thm: ell nearly always maximal epsilon free}]
Let $f(N)$ be a function that satisfies $f(N)  \to \infty$ as $N \to \infty$ (to be further specified later). For integers $j \geqslant 0$, let $D_j$ denote the set of $n \in (2^{j-1},2^j]$ such that $n$ has at least two distinct prime factors $p,q \leqslant f(2^{j-1})$.
Let \[D:= \bigcup_{j\geqslant 0} D_j.\]
The set $D$ is our candidate set for use in Theorem \ref{thm: ell nearly always maximal epsilon free}.

\begin{lemma} If $f$ grows slowly enough, the set $D$ has natural density $1$.
\end{lemma}

\begin{proof} We begin by fixing $j \geqslant 0$ and bounding the size of $D_j$ from below.  For convenience, we write $N$ for $2^{j-1}$.

To produce this lower bound, we find an upper bound for $(N,2N]\setminus D_j$. Indeed, by a standard application of a small sieve (e.g. the Selberg sieve, in particular Theorem 9.3.10 of \cite{Mu08}), one may show that the number of $n \in (N,2N]$ without any prime factor $p $ less than $f(N)$ is
\[O\bigg( N \prod_{p < f(N)} \left(1-\frac{1}{p} \right)\bigg),\]
provided $f(N)$ grows slowly enough.  By Mertens' Third Theorem, this quantity is $O(N/\log f(N))$.

By using a union bound and the sieve above, we bound the number of $n \in (N,2N]$ with exactly one prime factor $p < f(N)$ by
\[O\Bigg( \sum_{p < f(N)} \frac{N}{p}  \prod_{\substack{q<f(N) \\q \neq p}} \left(1-\frac{1}{q}\right)\!\Bigg).\]
This quantity is $O(N \log\log f(N)/\log f(N))$ (again by Mertens' theorems), and we conclude by exclusion that
\[\lvert D_j \rvert = N\left(1 - O \left(\frac{\log \log f(N)}{\log f(N)}\right)\right).\]

This already establishes that $D$ has full upper Banach density.  To show that $D$ has \emph{natural} density $1$, we fix $\varepsilon > 0$ and note that, since $f(N) \to \infty$ as $j \to \infty$, there exists $j_0(\varepsilon)$ such that $\lvert D_j \rvert \geqslant 2^{j-1}(1-\varepsilon)$ for all $j \geqslant j_0(\varepsilon)$.  In particular,
\begin{align*}
\sum_{\substack{n \leqslant X \\ n \in D}} 1 &\geqslant \sum_{j_0(\varepsilon) \leqslant j \leqslant \lceil \log_2 X \rceil} \vert D_j \vert - \sum_{X<n \leqslant 2^{\lceil \log_2 X \rceil}} 1. \\
&\geqslant (1-\varepsilon) \left(2^{\lceil \log_2 X \rceil} - 2^{j_0(\varepsilon)-1}\right) + X - 2^{\lceil \log_2 X \rceil}.
\end{align*}
Simplifying, we see that
\[ \liminf_{X \to \infty} \frac{\vert D \cap [1,X]\vert}{X} \geqslant \liminf_{X \to \infty} \frac{X - \varepsilon 2^{\lceil \log_2 X \rceil} - 2^{j_0(\varepsilon)}}{X} \geqslant 1 -2\varepsilon,\]
which implies that $D$ has natural density $1$, since $\varepsilon$ was arbitrary.
\end{proof}

Secondly, we prove that $\beta(n)$ is asymptotically large within $D$.

\begin{lemma} \label{second_lemma}
If $f$ grows slowly enough, then $\beta(n) \sim n$ as $n \to \infty$ within $D$.
\end{lemma}

\begin{proof} Our proof presents a more quantitative adaptation of the argument used in Lemma~\ref{thm:beta_asymp_along_AP}.  Let $\varepsilon > 0$, and fix $n \in D$.  By the definition of $D$, there exist distinct primes $p,q < f(n)$ for which $p,q \mid n$.  We will show that, provided $n$ is large enough in terms of $\varepsilon$, there exist non-negative integers $a$ and $b$ for which
\[e^{\varepsilon} \geqslant \frac{n}{p^a q^b} > 1.\]
Since $p^a q^b \leqslant \beta(n) < n$, and $\varepsilon$ is arbitrary, this will complete the proof.

Taking logarithms, it suffices to find non-negative integers $a$ and $b$ for which
\[\frac{\varepsilon}{\log q} \geqslant \log_q n - a \log_q p - b > 0.\]
Setting $L = \lfloor \log_p n \rfloor$, it will be enough to prove that the sequence of fractional parts $\{ \{a \log_q p\} : a \in [1,L]\}$ contains an element in every interval modulo $1$ of length $\varepsilon/\log q$.  Since $p,q \leqslant f(n)$, we reduce our theorem to the following claim:

\begin{claim} Let $L'=\lfloor \log n/\log f(n) \rfloor$.  Then $S=\{ \{a \log_q p\} : a \in [1,L']\}$ contains an element in every interval modulo $1$ of length $\varepsilon/\log f(n)$, provided $f(n)$ grows slowly enough.
\end{claim}

The proof of this claim follows from the Erd\H{o}s-Tur\'an inequality (Corollary 1.1 of \cite{Mo94}). Indeed, for any interval $I$ modulo $1$ of length $\varepsilon/\log f(n)$, we have
\begin{align} \label{eq:erdos_turan_bound}
\left\vert \vert S\cap I\vert - \frac{\varepsilon L'}{\log f(n)} \right\vert \ll \frac{L'}{K+1} + \sum_{k \leqslant K} \frac{1}{k} \bigg\vert \sum_{a=1}^{L'} e^{2\pi i a k\log_q p} \bigg\vert
\end{align}
for any integer $K \geqslant 1$. It suffices to show that we may choose a $K$ such that the right-hand side in~\eqref{eq:erdos_turan_bound} is $o(L'/\log f(n))$ as $n \to \infty$.

Choosing $K = \lfloor \log^2 f(n)\rfloor $ ensures that $L'/(K+1) = o(L'/\log f(n))$.  As for the second term in~\eqref{eq:erdos_turan_bound}, bounding the sum over $a$ as a geometric series gives
\[\sum_{k \leqslant K} \frac{1}{k} \bigg\vert \sum_{a=1}^{L'} e^{2\pi i a k\log_q p} \bigg\vert \leqslant G(K, p,q)\]
for some function $G$ that is independent of $L^\prime$. We may assume without loss of generality that $G$ is increasing in each variable. Then $$G(K,p,q) \ll G( \log^2 f(n), f(n), f(n) ),$$ so it suffices to show that
\begin{equation}
\label{growth function}
G\left(\log^2 f(n), f(n), f(n)\right) = o\left(\frac{L'}{\log f(n)}\right).
\end{equation}
Recalling the definition of $L'$, this is equivalent to showing
\[ G\left(\log^2 f(n), f(n), f(n)\right) \cdot \log^2 f(n)= o\left(\log n \right).\]
Yet $G$ is simply some absolute function, so if $f$ grows slowly enough then (\ref{growth function}) will hold. (If one so wished, one could quantify this growth condition using Baker's result \cite{Ba68} on linear forms of logarithms of primes). This proves the claim, and hence the lemma.
\end{proof}
Combining Lemma~\ref{second_lemma} with Theorem~\ref{thm:main theorem} yields Theorem \ref{thm: ell nearly always maximal epsilon free}.
\end{proof}
\vspace{5 mm}
\bibliographystyle{plain}

Number Theory (math.NT); Combinatorics (math.CO)


Proof of the combinatorial nullstellensatz over integral domains in the spirit of Kouba

Abstract: It is shown that by eliminating duality theory of vector spaces from a recent proof of Kouba (O. Kouba, A duality based proof of the Combinatorial Nullstellensatz. Electron. J. Combin. 16 (2009), #N9) one obtains a direct proof of the nonvanishing-version of Alon's Combinatorial Nullstellensatz for polynomials over an arbitrary integral domain. The proof relies on Cramer's rule and Vandermonde's determinant to explicitly describe a map used by Kouba in terms of cofactors of a certain matrix. That the Combinatorial Nullstellensatz is true over integral domains is a well-known fact which is already contained in Alon's work and emphasized in recent articles of Michalek and Schauz; the sole purpose of the present note is to point out that not only is it not necessary to invoke duality of vector spaces, but by not doing so one easily obtains a more general result.

\section{Introduction}
The Combinatorial Nullstellensatz is a very useful theorem (see ~\cite{AlonNss})
about multivariate polynomials over an integral domain which bears some resemblance to the
classical Nullstellensatz of Hilbert.

\begin{theorem}[Alon, {C}ombinatorial {N}ullstellensatz (ideal-containment-version), Theorem 1.1 in ~\cite{AlonNss}]\label{thm:idealNss}
Let $K$ be a field, $R\subseteq K$ a subring,  $f\in R[x_1,\dotsc, x_n]$, $S_1,\dotsc, S_n$ arbitrary nonempty subsets of $K$,
and $g_i:=\prod_{s\in S_i}(x_i-s)$ for every $1\leq i \leq n$. If $f(s_1,\dotsc, s_n)=0$
for every $(s_1,\dotsc, s_n)\in S_1\times\dotsm\times S_n$, then there exist polynomials $h_i\in R[x_1,\dotsc, x_n]$ with the property
that $\deg(h_i)\leq \deg(f) - \deg(g_i)$ for every $1\leq i \leq n$, and $f=\sum_{i=1}^n h_i g_i$.
\end{theorem}
\begin{theorem}[Alon, {C}ombinatorial {N}ullstellensatz (nonvanishing-version), Theorem 1.2 in ~\cite{AlonNss}]\label{thm:nonvanishingNss}
Let $K$ be a field, $R\subseteq K$ a subring, and $f\in R[x_1,\dotsc, x_n]$.
Let $c\cdot x_1^{d_1}\dotsm x_n^{d_n}$ be a term in $f$ with $c\neq 0$ whose degree $d_1+\dotsm+d_n$ is
maximum among all degrees of terms in $f$. Then every product $S_1\times\dotsm\times S_n$, where each $S_i$ is an arbitrary finite
subset of $R$ satisfying $|S_i|=d_i+1$, contains at least one point $(s_1,\dotsc, s_n)$ with $f(s_1,\dotsc,s_n)\neq 0$.
\end{theorem}

Three comments are in order. First, talking about subrings of a field is equivalent to talking about integral domains: every
subring of a field clearly is an integral domain, and, conversely, every integral domain $R$ is (isomorphic to) a subring
of its field of fractions $\mathrm{Quot}(R)$. Second, strictly speaking, rings are mentioned in ~\cite{AlonNss} only in
Theorem \ref{thm:idealNss}, but Alon's proof in ~\cite{AlonNss} of Theorem \ref{thm:nonvanishingNss} is valid for polynomials over
integral domains as well. Third, it is intended that the $S_i$ are allowed to be subsets of $K$ in Theorem ~\ref{thm:idealNss} but required
to be subsets of $R$ in Theorem ~\ref{thm:nonvanishingNss}, since this is the slightly stronger formulation: if Theorem ~\ref{thm:nonvanishingNss}
is true as it is formulated here, then by invoking it with $R=K$ and by viewing an $f\in R[x_1,\dotsc,x_n]$, $R$ being a subring of $K$, as a
polynomial in $K[x_1,\dotsc,x_n]$, it is true as well with the $S_i$ being allowed to be arbitrary subsets of $K$.

In ~\cite{AlonNss}, Theorem ~\ref{thm:nonvanishingNss} was deduced from Theorem \ref{thm:idealNss}.
In ~\cite{Kouba}, Kouba gave a beautifully simple and direct proof of the
nonvanishing-version of the Combinatorial Nullstellensatz, bypassing the use of the ideal-containment-version.
Kouba's argument was restricted to the case of polynomials over a field and at one step applied a suitably
chosen linear form on the vector space $K[x_1,\dotsc, x_n]$ to the given polynomial $f$ in Theorem ~\ref{thm:nonvanishingNss}.

However, for Kouba's idea to work, it is not necessary to have recourse to duality theory
of vector spaces and in the following section it will be shown how to make Kouba's idea work without it,
thus obtaining a direct proof of the full Theorem ~\ref{thm:nonvanishingNss}.

Finally, two relevant recent articles ought to be mentioned. A very short direct proof
of Theorem ~\ref{thm:nonvanishingNss} was given by Micha\l{}ek in ~\cite{Michalek} who explicitly
remarks that the proof works for integral domains as well. Moreover, the differences
 $\bigr\{s-s':\; \{s,s'\}\in \genfrac{(}{)}{0pt}{}{S_k}{2} \bigl\}$ in the proof below play a similar role in
Micha\l{}ek's proof. In ~\cite{Schauz}, Schauz obtained far-reaching generalizations and sharpenings
of Theorem ~\ref{thm:nonvanishingNss}, expressly working with integral domains and generalizations
thereof throughout the paper.

\section{Proof of Theorem  ~\ref{thm:nonvanishingNss}}
The proof of the Theorem ~\ref{thm:nonvanishingNss} will be based on the following simple lemma.
\begin{lemma}\label{lem:vandermonde} Let $R$ be an integral domain. Let $S=\{s_1,\dotsc,s_m\}\subseteq R$ be an arbitrary
finite subset. Then there exist elements $\lambda_1^{(S)},\dotsc, \lambda_m^{(S)}$ of $R$ such that
\begin{gather} \lambda_1^{(S)} \cdot (1, s_1, s_1^2,\dotsc, s_1^{m-1}) + \dotsm + \lambda_m^{(S)} \cdot (1,s_m,s_m^2,\dotsc, s_m^{m-1}) \notag\\
= (0,0,0,\dotsc,0,\prod_{1\leq i < j \leq m} (s_i-s_j)).
\end{gather}
\end{lemma}
\begin{proof} Let $[m]:=\{1,\dotsc, m\}$. Define $b$ to be the right-hand side of the claimed equation,
taken as a column vector, and let $A=(a_{ij})_{(i,j)\in [m]^2}$ be the Vandermonde matrix defined by  $a_{ij}:=s_{j}^{i-1}$.
Then the statement of the lemma is equivalent to the existence of a solution $\lambda^{(S)}\in R^m$ of the system of linear equations
$A \lambda^{(S)} = b.$ By the well-known formula for the determinant of a
Vandermonde matrix (see ~\cite{LangAlgebra}, Ch. XIII, \S 4, example after Prop. 4.10), $\det(A)=\prod_{1\leq i < j \leq m} (s_i-s_j)$.

Since $S$ is a set, all factors of this product are nonzero, and since $R$ has
no zero divisors, the determinant is therefore nonzero as well. Now
let $\alpha_{ij}$ be the cofactors of $A$, i.e. $\alpha_{ij}:=(-1)^{i+j} \det(A^{(ij)})$,
where $A^{(ij)}$ is the $(m-1)\times (m-1)$ matrix
obtained from $A$ by deleting the $i$-th row and the $j$-th column (see ~\cite{BirkhoffMacLane}, Ch. IX, \S 3, before Lemma 1).
By Cramer's rule (see Ch. IX, \S 3, Corollary 2 of Theorem 6 in ~\cite{BirkhoffMacLane} or Theorem 4.4 in ~\cite{LangAlgebra}), for
every $j\in [m]$,
\[  \det(A) \cdot \lambda_j^{(S)} = \sum_{i=1}^m \alpha_{ij} b_i.\]
Using $b_m=\det(A)$, $b_i=0$ for every $1\leq i < m$, and the commutativity of an integral domain, this reduces to
\[ \det(A) \cdot \bigl( \lambda_j^{(S)} - \alpha_{mj}\bigr) = 0.\]
Hence, since $\det(A)\neq 0$ and $R$ has no zero divisors, if follows that
the cofactors  $\lambda_j^{(S)}=\alpha_{mj}\in R$ provide explicit elements
with the desired property.
\end{proof}
Using this lemma, Kouba's argument may now be carried out without change in the setting of integral domains.
\begin{proof}[Proof of Theorem ~ \ref{thm:nonvanishingNss}] Let $R$ be an arbitrary integral domain and $f\in R[x_1,\dotsc, x_n]$ be
an arbitrary polynomial. Let $d_1,\dotsc, d_n\in \mathbb{N}_{\geq 0}$ be the exponents of a term $c\cdot  x_1^{d_1}\dotsm x_{n}^{d_n}$
with $c\neq 0$ which has maximum degree in $f$. For each $k\in [n]$, choose an arbitrary finite
subset  $S_k\subseteq R$ and apply Lemma ~\ref{lem:vandermonde} with $S=S_k$ and $m=|S|=d_k+1$ to obtain a family of
elements $(\lambda_{s_k}^{(S_k)})_{s_k\in S_k}$ of $R$ (where in order to avoid double indices the coefficients $\lambda$
are now being indexed by the elements of $S_k$ directly, not by an enumeration of each $S_k$) with the property that
\begin{align}
\sum_{s_k\in S_k} \lambda_{s_k}^{(S_k)} \cdot s_{k}^\ell & = 0\quad \text{ for every $\ell\in \{0,\dotsc, d_k-1\}$}, \label{eq:smallExponent}\\
\sum_{s_k\in S_k} \lambda_{s_k}^{(S_k)} \cdot s_{k}^{d_k} & = \prod_{\{s,s'\} \in \genfrac{(}{)}{0pt}{}{S_k}{2}} (s-s') =: r_k \in R\backslash\{ 0 \}\label{eq:matchingExponents}.
\end{align}

Using the coefficient families $(\lambda_{s_k}^{(S_k)})_{s_k\in S_k}$, define, \`a la Kouba, the map
\begin{align}
  \Phi:\quad & R[x_1,\dotsc, x_n]  \longrightarrow R \notag\\
 g &\longmapsto \sum_{(s_{1},\dotsc,s_{n})\in S_1\times \dotsm \times S_n} \lambda_{s_1}^{(S_1)}\dotsm\lambda_{s_n}^{(S_n)} \cdot g(s_{1},\dotsc,s_{n}).
\label{def:koubaMap}
\end{align}
Due to the commutativity of an integral domain, $\Phi$ is an $R$-linear form on the $R$-module $R[x_1,\dotsc, x_n]$, hence
its value $\Phi(f)$ on a polynomial $f$ can be evaluated termwise as
\begin{align}
\Phi(f) = \sum_{c\cdot t\text{ a term in $f$}} c\cdot \Phi(t).
\end{align}
If $t = c\cdot x_1^{d_1'}\dotsm x_n^{d_n'}$ is an arbitrary term in $R[x_1,\dotsc,x_n]$, then
\begin{align}
\Phi(t) = c\cdot \Phi (x_1^{d_1'}\dotsm x_n^{d_n'})
& = c \cdot\sum_{(s_{1},\dotsc,s_{n})\in S_1\times \dotsm \times S_n} \lambda_{s_1}^{(S_1)}\dotsm\lambda_{s_n}^{(S_n)} \cdot  s_{1}^{d_1'} \dotsm s_{n}^{d_n'} \notag\\
& = c \cdot \sum_{s_{1}\in S_1}\dotsm \sum_{s_{n} \in S_n} \lambda_{s_1}^{(S_1)}\dotsm\lambda_{s_n}^{(S_n)} \cdot s_{1}^{d_1'} \dotsm s_{n}^{d_n'} \notag\\
& = c \cdot \prod_{k=1}^n\biggl ( \sum_{s_k \in S_k} \lambda_{s_k}^{(S_k)} s_k^{d_k'},\biggr )\label{eq:productExpansion}
\end{align}
where in the last step again use has been made of the commutativity of an integral domain. By ~\eqref{eq:productExpansion}
and ~\eqref{eq:smallExponent} it follows that for every term $t$, if there is at least one exponent $d_i'$ with $d_i'<d_i$,
then $\Phi(t)=0$. Moreover, by the choice of the term $c\cdot x_1^{d_1}\dotsm x_{n}^{d_n}$, every
term $c'\cdot x_1^{d_1'}\dotsm x_{n}^{d_n'}$ of $f$ which is different from the term $c\cdot x_1^{d_1}\dotsm x_{n}^{d_n}$ must,
even if it has itself maximum degree in $f$, contain at least one exponent $d_i'$ with $d_i'<d_i$. Therefore
\begin{align}
& \sum_{(s_{1},\dotsc,s_{n})\in S_1\times \dotsm \times S_n} \lambda_{s_1}^{(S_1)}\dotsm\lambda_{s_n}^{(S_n)} \cdot f(s_{1},\dotsc,s_{n})
\eqBy{\eqref{def:koubaMap}}
\Phi(f) \eqBy{\eqref{eq:smallExponent},\eqref{eq:productExpansion}}
 c\cdot \Phi(x_1^{d_1}\dotsm x_{n}^{d_n} ) = \notag\\
&  \eqBy{\eqref{eq:matchingExponents},\eqref{eq:productExpansion}}
c\cdot \prod_{k=1}^n \prod_{\{s,s'\} \in \genfrac{(}{)}{0pt}{}{S_k}{2}} (s-s') = c\cdot \prod_{k=1}^n r_k \neq 0,
\end{align}
since $R$ has no zero divisors. Obviously this implies that there exists at least one point $(s_1,\dotsc, s_n)\in S_1\times\dotsm \times S_n$ where
$f$ does not vanish.
\end{proof}

\section{Concluding question}
Is there any interesting use for the fact that even in the
case of integral domains the coefficients of Kouba's map can be explicitly
expressed in terms of cofactors of the matrices $(s^{i-1}_j)$?

\section*{Acknowledgement} The author is very grateful to the department M9 of
Technische Universit\"{a}t M\"{u}nchen for excellent working conditions.

\bibliographystyle{amsplain}


Perfect matchings and derangements on graphs

Abstract: We show that each perfect matching in a bipartite graph $G$ intersects at least half of the perfect matchings in $G$. This result has equivalent formulations in terms of the permanent of the adjacency matrix of a graph, and in terms of derangements and permutations on graphs. We give several related results and open questions.

\section{Introduction}

Our main result concerns perfect matchings in bipartite graphs.
\begin{theorem}\label{th:matchingInBipartiteGraph}
	Let $G$ be a bipartite graph having a perfect matching $M$.
	Then $M$ has non-empty intersection with at least half of the perfect matchings in $G$.
\end{theorem}

The value of $1/2$ in this conclusion can't be improved, since even cycles have two perfect matchings, which are disjoint.  Moreover, the hypothesis that $G$ be bipartite is necessary (e.g., $K_4$ has three perfect matchings, which are disjoint). In fact, it turns out that for general graphs, the behavior is quite different.
\begin{theorem}\label{th:matchingInGeneral}
Let $G$ be a graph on $2n$ vertices having a perfect matching $M$.  Then $M$ has non-empty intersection with at least $1/(2^{n-1}+1)$ of the perfect matchings in $G$.  Moreover, if $n$ is even there is a $3$-regular graph on $2n$ vertices having $2^{n/2} + 1$ perfect matchings, one of which is disjoint from all the others.
\end{theorem}

This work was originally motivated as a study of derangements and permutations on graphs, as introduced by Clark \cite{clark2013graph}, and this approach leads to several related questions.
Let $G=(E,V)$ be a directed, loopless graph.
A derangement on $G$ is a bijection $\sigma:V \rightarrow V$ such that $(v,\sigma(v)) \in E$ for all $v \in V$.
A permutation on $G$ is a bijection $\sigma:V \rightarrow V$ such that either $(v, \sigma(v)) \in E$ or $v = \sigma(v)$ for all $v \in V$.

For any directed graph $G$, denote by $(d/p)_G$ the ratio of the number of derangements on $G$ to the number of permutations on $G$.
We also consider derangements and permutations on undirected graphs, by treating them as directed graphs for which $(u,v)$ is an edge if and only if $(v,u)$ is an edge.
From these definitions, it is easy to see that $(d/p)_{K_n}$ is the probability that a uniformly random permutation on $[n]$ is a derangement.
A classic application of inclusion-exclusion shows that
$$\lim_{n \rightarrow \infty}(d/p)_{K_n} = 1/e.$$

Many graphs do not admit any derangements, and hence $(d/p)$ may be as small as $0$.
In the other direction, if $C$ is a directed cycle, then there is one derangement and two permutations on $C$, and hence $(d/p)_C = 1/2$.
Theorem \ref{th:matchingInBipartiteGraph} is equivalent to the claim that $(d/p)$ is never larger than $1/2$.

\begin{restatable}{theorem}{ratioHalf}\label{thm:ratioHalf}
If $G$ is a loopless directed graph, then
$$(d/p)_G \leq 1/2,$$
with equality if and only if $G$ is a directed cycle.
\end{restatable}

Let us see that the claim that $(d/p)_G \leq 1/2$ in Theorem \ref{thm:ratioHalf} is equivalent to Theorem \ref{th:matchingInBipartiteGraph}.
Given a directed graph $G$, we construct a bipartite graph $G'$ as follows.
For each vertex $v \in V(G)$, we have a left vertex $v_l$ and a right vertex $v_r$ in $V(G')$.
We have $\{u_l, v_r\} \in E(G')$ if and only if either $(u,v) \in E(G)$ or $u =v$.
Then, each permutation on $G$ corresponds to a perfect matching in $G'$, and a derangement on $G$ corresponds to a perfect matching in $G'$ that does not use any edge of the form $\{v_l, v_r\}$.
Hence, Theorem \ref{thm:ratioHalf} is equivalent to the claim that the matching $\{ \{v_l, v_r\} : v \in V(G)\}$ in $G'$ intersects at least half of the perfect matchings in $G'$.
We can obtain the full statement of Theorem \ref{th:matchingInBipartiteGraph} by applying a permutation to the labeling of the right vertices of $G'$.

The formulation in terms of derangements and permutations on graphs leads to several other natural questions.
In particular, we investigate the ratio $(d/p)$ for restricted families of graphs.

In the case that $G$ is regular and very dense, it turns out that $(d/p)_G$ is always close to $1/e$, as it is for complete graphs.

\begin{theorem}\label{thm:veryDense}
	Let $\mathcal{G} = \{G_2, G_3, \ldots\}$ be an infinite family of directed graphs, so that $G_n$ is $k_n$-regular on $n$ vertices.
	Suppose that
	$k_n = n - o(n/\log(n))$.
	Then,
	$$\lim_{n \rightarrow \infty} (d/p)_{G_n} = 1/e.$$
\end{theorem}

By Theorem \ref{thm:ratioHalf}, $(d/p) = 1/2$ is attained only for directed cycles.
A natural question is whether it is possible for $(d/p)$ to be nearly $1/2$ for dense graphs.
It turns out that there are graphs having positive edge density and $(d/p)$ arbitrarily close to $1/2$.
\begin{theorem}\label{thm:blowupExample}
	For any $\varepsilon > 0$, there is a constant $c_\varepsilon > 0$, an infinite set $I$ of positive integers, and a family of graphs $\{G_n : n \in I\}$ such that $|V(G_n)| = n$, $|E(G_n)| \geq c_\varepsilon n^2$, and $\lim_{n \rightarrow \infty} (d/p)_{G_n}$ exists and is strictly larger than $1/2 - \varepsilon$.
\end{theorem}

We are also interested in how large $(d/p)_G$ can be for an undirected graph $G$.
In Section \ref{sec:constructions}, we show that $(d/p)_{K_{n,n}} > (d/p)_{K_{2n}}$.
However, in contrast to the case for directed graphs, this is essentially the only example we have found of an undirected graph $G$ with $(d/p)_G > (d/p)_{K_n}$.
We propose the following conjecture on the matter.

\begin{conjecture}\label{conj:undirected}
	Let $G$ be an undirected graph on $n$ vertices.
	If $n$ is even, then
	$$(d/p)_G \leq (d/p)_{K_{n/2,n/2}},$$
	with equality only for $K_{n/2,n/2}$.
\end{conjecture}

In the case that $n$ is odd, we don't know of any graphs $G$ on $n$ vertices with $(d/p)_G > (d/p)_{K_n}$; in particular, we don't know of any way to add a vertex to $K_{n,n}$ without substantially decreasing the ratio $d/p$.

The following theorem provides some evidence for Conjecture \ref{conj:undirected}.

\begin{restatable}{theorem}{undirectedBipartite}\label{thm:undirectedBipartite}
	Let $G$ be a bipartite graph.
	Then,
	$$(d/p)_G \leq \frac{1}{\sum_{k=0}^{n} k!^{-2}},$$
	with equality if and only if $G$ is a complete bipartite graph.
\end{restatable}

\begin{comment}
If $G$ is an unbalanced bipartite graph, then there are no derangements on $G$ and $(d/p)_G = 0$.
The proof of Theorem \ref{thm:undirectedBipartite} is in Section \ref{sec:undirectedBipartite}.

The proof of this theorem is in Section \ref{sec:arbitrary}.
In Section \ref{sec:constructions} we describe families of dense graphs with $(d/p)_G > 1/2 - \varepsilon$ for any $\varepsilon > 0$.

We also consider upper bounds on $(d/p)_G$ for restricted families of graphs.
For example, in the case that $G$ is regular and very dense, we show that $(d/p)_G$ is close to $1/e$, as is the case for complete graphs.

\begin{theorem}\label{thm:veryDense}
Let $\mathcal{G} = \{G_2, G_3, \ldots\}$ be an infinite family of directed graphs, so that $G_n$ is $k_n$-regular on $n$ vertices.
Suppose that
$k_n = n - o(n/\log(n))$.
Then,
$$\lim_{n \rightarrow \infty} (d/p)_{G_n} = 1/e.$$
\end{theorem}
The proof of this theorem is in Section \ref{sec:veryDense}.

A more interesting case is undirected graphs.
In Section \ref{sec:constructions}, we show that $(d/p)_{K_{n,n}} > (d/p)_{K_{2n}}$.
However, in contrast to the case for directed graphs, this is essentially the only example we have found with $(d/p)_G > (d/p)_{K_n}$.
We propose the following conjecture on the matter.

\begin{conjecture}\label{conj:undirected}
Let $G$ be an undirected graph on $n$ vertices.
If $n$ is even, then
$$(d/p)_G \leq (d/p)_{K_{n/2,n/2}},$$
with equality only for the complete bipartite graph.
\end{conjecture}

In the case that $n$ is odd, we don't know of any graphs $G$ with $(d/p)_G > (d/p)_{K_n}$; in particular, we don't know of any way to add a vertex to $K_{n,n}$ without substantially decreasing the ratio $d/p$.

The following theorem provides some evidence for Conjecture \ref{conj:undirected}.

\begin{restatable}{theorem}{undirectedBipartite}\label{thm:undirectedBipartite}
Let $G$ be an undirected, balanced bipartite graph.
Then,
$$(d/p)_G \leq \frac{1}{\sum_{k=0}^{n} k!^{-2}},$$
with equality if and only if $G$ is a complete bipartite graph.
\end{restatable}

Clearly, if $G$ is an unbalanced bipartite graph, then there are no derangements on $G$ and $(d/p)_G = 0$.
The proof of Theorem \ref{thm:undirectedBipartite} is in Section \ref{sec:undirectedBipartite}.

\end{comment}

\begin{comment}
\subsection{Equivalent formulations}

The questions about derangements and permutations on graphs studied here can be restated as questions about the permanents of matrices, or about perfect matchings.
In particular, the proofs in Sections \ref{sec:veryDense} and \ref{sec:undirectedBipartite} depend on the following reformulation in terms of the permanents of matrices.

The permanent of an $n \times n$ matrix $A = [a_{ij}]$ is
$$\per(A) = \sum_\sigma a_{1 \sigma(1)} a_{2 \sigma(2)} \ldots a_{n \sigma(n)},$$
where the sum runs over all permutations of $[n]$.
If $A$ is the adjacency matrix of a  directed graph $G$, and $\sigma$ is a fixed permutation, then
$\prod_i a_{i \sigma(i)} = 1$
if and only if $(i,\sigma(i)) \in G$ for each $i \in [n]$, and $\prod_i a_{i \sigma(i)} =0$ otherwise.
Hence, $\prod_i a_{i \sigma(i)} = 1$ if and only if $\sigma$ is a derangement on $G$, and so the permanent of $A$ is equal to the number of derangements on $G$.
Similarly, the permanent of $A+I$, where $I$ is the identity matrix, is the number of permutations on $G$.

\begin{observation}\label{obs:deragementPermanent}
For a directed, loopless graph $G$ with adjacency matrix $A$,
$$(d/p)_G = \frac{\per(A)}{\per(A + I)}.$$
\end{observation}

Using this observation, we can restate Theorem \ref{thm:ratioHalf} in terms of permanents of $(0,1)$-matrices.

\begin{corollary}
Let $A$ be an $n \times n$, $(0,1)$-matrix such that $a_{ii} = 0$ for each $i \in [n]$.
Then,
$$\frac{\per(A)}{\per(A + I)} \leq \frac{1}{2}.$$
\end{corollary}

It is a well-known fact that the number of perfect matchings on a balanced bipartite graph is equal to the permanent of its biadjacency matrix, and we also relate graph derangements and permutations to perfect matchings.

Given a directed, loopless graph $G$ on vertex set $[n]$, construct a bipartite graph $G'$ on $[n] \sqcup [n]$ so that $(i,j) \in G'$ if and only if $(i,j) \in G$.
Then, a derangement on $G$ is exactly a perfect matching in $G'$.
Since $G$ is loopless, there are no edges $(i,i) \in G'$, and permutations on $G$ correspond to perfect matchings in the graph $G' \cup D$, where $D = \{(i,i):i \in [n]\}$.
From this, the following observation is immediate.
We denote by $\match(G)$ the number of perfect matchings in $G$.

\begin{observation}
Let $G$, $G'$, and $D$ be as in the previous paragraph.
Then,
$$(d/p)_G = \frac{\match(G')}{\match(G' \cup D)}.$$
\end{observation}

Note that we can permute the labels of the right vertices of $G'$ without affecting the number of perfect matchings.
Hence, we have the following corollary of Theorem \ref{thm:ratioHalf}.

\begin{corollary}
Let $G$ be a bipartite graph, and let $M$ be a perfect matching in the complement of $G$ that respects a $2$-coloring of $G$.
Then,
$$\frac{\match(G)}{\match(G \cup M)} \leq \frac{1}{2}.$$
\end{corollary}

If $G$ is an undirected bipartite graph, then the graph $G'$ obtained by the above construction is the disjoint union of two copies of $G$.
Hence, in this case, $\match(G') = \match(G)^2.$
This leads to the following observation.

\begin{observation}
If $G$ is an undirected bipartite graph, then the number of derangements on $G$ is equal to the square of the number of perfect matchings in $G$.
\end{observation}

\end{comment}

In the case of random graphs and digraphs, we show that the numbers of derangements and permutations are tightly concentrated about their means.  This can be derived either from the arguments of Frieze and Jerrum \cite{frieze1995analysis} on the permanents of random matrices or from the more general framework of Janson \cite{janson1994numbers} who proved limit distribution laws for a wide range of subgraph counts.

For a probability $q$, we use $G_{n,q}$ (resp.\ $DG_{n,q}$) to denote the Erd\H{o}s--R\'enyi random graph (resp.\ digraph) on $n$ vertices where each edge (resp.\ arc) is included independently with probability $q$.  It turns out that a great deal can be said about the ratio $(d/p)$ for these random structures (following \cite{janson1994numbers}); however, for both brevity and accessibility we'll restrict ourselves to the following.

\begin{proposition}\label{th:randomRatios}
For each $\delta > 0$, there is a sequence $\varepsilon_n \to 0$ satisfying the following.  If $q = q_n \in (\delta, 1]$, then with probability tending to $1$ as $n \to \infty$,
\begin{eqnarray*}
e^{-1/q} (1 - \varepsilon_n) \leq &(d/p)_{G_{n,q}}& \leq e^{-1/q} (1 + \varepsilon_n), \qquad \text{and}\\
e^{-1/q} (1 - \varepsilon_n) \leq &(d/p)_{DG_{n,q}}& \leq e^{-1/q} (1 + \varepsilon_n).
\end{eqnarray*}
\end{proposition}
Thus a large random (di)graph with edge density $q$ will have $(d/p) \sim e^{-1/q}$.  Setting $q=1/2$ shows that for large $n$, the vast majority of graphs and digraphs have $(d/p)$ tending to $e^{-2}$. Taking $q \to 1$, we obtain a randomized analog of Theorem \ref{thm:veryDense}.  Moreover, the behavior for random graphs provides some (mild) additional evidence for Conjecture \ref{conj:undirected}.

\subsection{Prior work}

Derangements and permutations on graphs were introduced by Clark, \cite{clark2013graph}, who considered mainly the cycle structure of graph derangements.

Penrice \cite{penrice1991derangements} (using a slightly different terminology) investigated the number of derangements on $n$-partite graphs with $t$ vertices in each part, for $t$ fixed and $n$ large.
His result is a special case of Theorem \ref{thm:veryDense}, and his proof is based on the same ideas used in the proof of Theorem \ref{thm:veryDense}.

The literature on perfect matchings in bipartite graphs is extensive. For a general background on this, see the textbook of Lov\'asz and Plummer \cite{lovasz2009matching}.

\begin{comment}
Other restricted families of permutations have been investigated, but these topics are not related to our notion of derangements and permutations on graphs in any simple way.
The question of determining the number of permutations that avoid particular patterns has been very fruitful, e.g. \cite{simion1985restricted}.
Geometric permutations are those that can be realized as a line transversal of convex sets, \cite{katchalski1985geometric}.
\end{comment}

\subsection{Organization of the paper}

The construction for Theorem \ref{thm:blowupExample} is in Section \ref{sec:constructions}.
The complete bipartite graph is a special case of this construction.
Section \ref{sec:veryDense} contains the proof of Theorem \ref{thm:veryDense}.
Section \ref{sec:undirectedBipartite} contains the proof of Theorem \ref{thm:undirectedBipartite}.
Theorem \ref{thm:ratioHalf} is proved in Section \ref{sec:arbitrary}, which also includes the statement and proof of a result on Hamilton cycles in directed graphs (Corollary \ref{thm:hamilton}). In Section \ref{sec:matchingsInGeneralGraphs} we prove Theorem \ref{th:matchingInGeneral}, and we discuss random graphs and digraphs in Section \ref{sec:randomGraphs}.
Some open problems are listed in Section \ref{sec:openProblems}.

\section{Constructions}\label{sec:constructions}

In this section, we compute $(d/p)$ for blowups of directed graphs.
These provide the examples described in Theorem \ref{thm:blowupExample}.
A special case is the complete, balanced, undirected bipartite graph that plays an important role in Conjecture \ref{conj:undirected} and Theorem \ref{thm:undirectedBipartite}.

Let $D_{k,l}$, for $k \geq 1$ and $l \geq 2$, be a graph on vertices $v_{ij}$ for $i \in [k]$ and $j \in [l]$, such that $(v_{ij}, v_{lm}) \in D_{k,l}$ if and only if $m = j+1 \mod l$.
Note that $D_{1,n}$ is the directed cycle on $n$ vertices, and $D_{n,2}$ is the undirected complete bipartite graph on $[n] \sqcup [n]$.
Figure \ref{fig:D25} shows $D_{2,5}$.

\begin{figure}[h]
\begin{center}
\includegraphics[scale=1]{D25}
\end{center}
\caption{$D_{2,5}$} \label{fig:D25}
\end{figure}

\begin{proposition}\label{thm:construction}
The number of derangements on $D_{k,l}$ is $(k!)^l$, and the number of permutations on $D_{k,l}$ is
$$  \sum_{i=0}^k \left( \binom{k}{i} (k-i)! \right)^l.$$
Consequently,
$$ (d/p)_{D_{k,l}} = \left( \sum_{i=0}^k \frac{1}{(i!)^l} \right)^{-1}.$$
\end{proposition}

\begin{proof}
The graph $D_{k,l}$ is organized into $l$ parts, with $k$ vertices in each part.

In any derangement on $D_{k,l}$, each vertex in part $j$ has a single out-neighbor in part $j+1 \mod l$, and no two vertices have the same out-neighbor.
The claim on the number of derangements follows immediately.

If $P$ is a permutation on $D_{k,l}$, the number of fixed points of $P$ in each part of $D_{k,l}$ must be equal.
Hence, to count the number of permutations with $m$ fixed points, it is enough to count the number of ways to choose $m/l$ fixed points in each part, and multiply by the number of derangements on the remaining elements.
This is the formula given above.
\end{proof}

Since
$e = \lim_{n \rightarrow \infty} \sum_{i=0}^n \frac{1}{i!}$
and $K_{n,n} = D_{n,2}$,
it follows from Proposition \ref{thm:construction} that $\lim_{n \rightarrow \infty} (d/p)_{K_{n,n}} > 1/e$.
For small values of $n$, it is easy to calculate that $(d/p)_{K_{n,n}} > (d/p)_{K_{2n}}$.
Hence, $(d/p)_{K_{n,n}} > (d/p)_{K_{2n}}$ for all $n>1$, consistent with Conjecture \ref{conj:undirected}.

In light of Theorem \ref{thm:ratioHalf}, it is natural to wonder if it is possible for $(d/p)_G$ to be very close to $1/2$ if $G$ is not a directed cycle.
Choosing $l$ to be a large constant shows that this is the case.
In particular, Theorem \ref{thm:blowupExample} follows from Proposition \ref{thm:construction} by taking $G_n = D_{n/l,l}$ for a suitably chosen constant $l$ depending on $\varepsilon$.

\section{Very dense graphs}\label{sec:veryDense}

In this section, we prove Theorem \ref{thm:veryDense}.
The proof is based on two standard bounds on the permanents of matrices, the Minc-Br\'egman inequality (proved by Br\'egman in \cite{bregman1973some}) and van der Waerden conjecture (proved independently by Egorychev in \cite{egorychev1981solution} and by Falikman in \cite{falikman1981proof}).

Recall that the permanent of an $n \times n$ matrix $A = [a_{ij}]$ is
$$\per(A) = \sum_\sigma a_{1 \sigma(1)} a_{2 \sigma(2)} \ldots a_{n \sigma(n)},$$
where the sum runs over all permutations of $[n]$.
If $A$ is the adjacency matrix of a  directed graph $G$, and $\sigma$ is a fixed permutation, then
$\prod_i a_{i \sigma(i)} = 1$
if and only if $(i,\sigma(i)) \in G$ for each $i \in [n]$, and $\prod_i a_{i \sigma(i)} =0$ otherwise.
Hence, $\prod_i a_{i \sigma(i)} = 1$ if and only if $\sigma$ is a derangement on $G$, and so the permanent of $A$ is equal to the number of derangements on $G$.
Similarly, the permanent of $A+I$, where $I$ is the identity matrix, is the number of permutations on $G$.

Using the connection between derangements and permanents, Theorem \ref{thm:veryDense} follows as an immediate corollary to the following, stronger, theorem.

\begin{theorem}\label{thm:denseGraphsPermanentVersion}
Let $I$ be an infinite set of positive integers, and let $\{A_n: n \in I\}$ and $\{B_n: n \in I\}$ be families of $n \times n$ matrices with entries in $\{0,1\}$.
Suppose that the sum of entries in each row and each column of $A_n$ is $k_n$, and that the sum of entries in each row and each column of $B_n$ is $k_{n}+1$.
Further, suppose that
$k_n = n - o(n/\log(n))$.
Then,
$$\lim_{n \rightarrow \infty} \frac{Per(A_n)}{Per(B_n)} = 1/e.$$
\end{theorem}
\begin{proof}[Proof of Theorem \ref{thm:denseGraphsPermanentVersion}]
We use two standard estimates on the permanent of a matrix.
First, the Minc-Br\'egman inequality \cite{bregman1973some} is that, if $A$ is a $(0,1)$-matrix with row sums $k$, then
$$\per(A) \leq k!^{n/k},$$
with equality attained only by block-diagonal matrices.
Second, the van der Waerden Conjecture, proved independently in \cite{falikman1981proof,egorychev1981solution}, is that, if $A$ is a doubly stochastic matrix, then
$\per(A) \geq n! / n^n$,
with equality attained only by $\frac{1}{n}J$, where $J$ is the all-ones matrix.
An immediate corollary to this is that, for a matrix $A$ with row and column sums equal to $k$, we have $$\per(A) \geq n! (k / n)^n.$$
Notice the upper and lower bounds meet for $k=n$.

What remains is calculation using Stirling's approximation.
In what follows, $f(n) \sim g(n)$ means $\lim_{n \rightarrow \infty} (f(n)/g(n)) = 1$, and we denote $k=k_n$.

First, we show that $\lim_{n \rightarrow \infty} \per(A_n) / \per(B_n) \leq 1/e$.
\begin{align*}
\per(A_n)/ \per(B_n) &\leq \frac{k!^{n/k} n^n}{n!(k+1)^n}, \\
&\sim \frac{\sqrt{2 \pi k}^{n/k}}{\sqrt{2 \pi n}} \frac{ k^n}{ (k+1)^n}, \\
&\leq (2 \pi n)^{(n-k)/2k} \frac{ k^n}{ (k+1)^n}, \\
&= (2 \pi n)^{o(1/\log n)} \frac{k^n}{(k+1)^n}, \\
&\sim 1/e.
\end{align*}
In the last line, we use that $(k/(k+1))^n \sim 1/e$ for any $k = (1-o(1))n$, and $n^{1/\log n}$ is a constant so $(2 \pi n)^{o(1/\log n)} \sim 1$.

Next, we show that $\lim_{n \rightarrow \infty} \per(A_n) / \per(B_n) \geq 1/e$.
\begin{align*}
\per(A_n)/ \per(B_n) &\geq \frac{n!k^n}{(k+1)!^{n/(k+1)} n^n}, \\
&\sim \frac{\sqrt{2 \pi n}}{\sqrt{2 \pi (k+1)}^{n/(k+1)}} \frac{ k^n}{ (k+1)^n}, \\
&\geq \frac{\sqrt{2 \pi n}}{\sqrt{2 \pi n}^{n/(k+1)} - o(\sqrt{n}^{n/(k+1)})}  \frac{ k^n}{ (k+1)^n} \\
&\sim \frac{1}{(2 \pi n)^{o(1/\log n)}} (1/e), \\
&\sim 1/e.
\end{align*}
\end{proof}

\section{Undirected bipartite graphs}\label{sec:undirectedBipartite}

In this section, we prove Theorem \ref{thm:undirectedBipartite}.
As in Section \ref{sec:veryDense}, we depend on the connection between derangements on graphs and permanents of matrices.

In what follows, for any $n \times n$ matrix $M$ and sets $S,S' \subset [n]$, we denote by $M(S,S')$ the sub-matrix of $M$ consisting of rows in $S$ and columns in $S'$, and denote by $M(\overline{S}, \overline{S'})$ the sub-matrix of $M$ with rows in $S$ and columns in $S'$ deleted.
We denote by $M(\overline{i}, \overline{j})$ the sub-matrix of $M$ obtained by deleting only row $i$ and column $j$.

For any graph $G$, we denote by $p_G$ the number of permutations on $G$, and by $d_G$ the number of derangements on $G$.

First, we need the following lemma on the permanent of an arbitrary matrix.

\begin{lemma}\label{thm:subpermanentFormula}
Let $M$ be an $n \times n$ matrix, and let $0 \leq k \leq n$.
Then,
$$\binom{n}{k} \per(M) = \sum_{S, S' \in \binom{[n]}{k}} \per(M(S,S')) \per(M(\overline{S},\overline{S'})).$$
\end{lemma}

\begin{proof}
Let $S \in \binom{[n]}{k}$.
For any $S' \in \binom{[n]}{k}$, let $\Sigma_{S'}$ be the set of permutations of $[n]$ such that $\sigma(i) \in S'$ for all $i \in S$.
For each permutation $\sigma$ of $[n]$, there is a unique set $S' \in \binom{[n]}{k}$ such that $\sigma(i) \in S'$ for all $i \in S$, and hence the sets $\Sigma_{S'}$ partition the set of all permutations.

\begin{align*}
\per(M) &= \sum_{\sigma} \prod_i m_{i \sigma(i)}, \\
&= \sum_{S' \in \binom{[n]}{k}} \sum_{\sigma \in \Sigma_{S'}}\prod_{i \in S}m_{i \sigma(i)} \prod_{i \in \overline{S}} m_{i \sigma(i)}.
\end{align*}

Let $\Sigma_{S'}^1$ be the set of bijections between $S$ and $S'$, and let $\Sigma_{S'}^2$ be the set of bijections between $\overline{S}$ and $\overline{S'}$.
Each $\sigma \in \Sigma_{S'}$ corresponds to exactly one pair of functions $\sigma_1 \in \Sigma_{S'}^1$ and $\sigma_2 \in \Sigma_{S'}^2$, so that $\sigma(i) = \sigma_1(i)$ for $i \in S$ and $\sigma(j) = \sigma_2(j)$ for $j \in \overline{S}$.
Hence,

\begin{align*}
\per(M) &= \sum_{S' \in \binom{[n]}{k}}\left( \sum_{\sigma \in \Sigma_{S'}^1}\prod_{i \in S}m_{i \sigma(i)} \right) \left(\sum_{\sigma \in \Sigma_{S'}^2}\prod_{i \in \overline{S}} m_{i \sigma(i)} \right),\\
&= \sum_{S' \in \binom{[n]}{k}} \per(M(S,S')) \per(M(\overline{S}, \overline{S'})).
\end{align*}
\end{proof}

We will need to break the permutations up by their fixed points.

\begin{lemma}\label{thm:permutationSum}
If $G$ is a directed, loopless graph on $[n]$ with adjacency matrix $M$, then
$$p_G = \sum_{S \subseteq [n]} \per(M(S,S)).$$
If $G$ is an undirected bipartite graph on $[n] \sqcup [n]$ with biadjacency matrix $M$, then
$$p_G = \sum_{S, S' \subseteq [n]} \per(M(S,S'))^2.$$
\end{lemma}

\begin{proof}
Each term on the right side of the equality counts the number of permutations on $G$ with the fixed points $\overline{S}$.
In the case of a bipartite graph, the fixed points occur in pairs; $\overline{S}$ is the set of fixed points among the left vertices, and $\overline{S'}$ is the set of fixed points among the right vertices.
\end{proof}

We're now ready to prove the theorem.
For convenience, we recall it here.

\undirectedBipartite*

\begin{proof}
Let $M$ be the biadjacency matrix of $G$.
Applying Lemma \ref{thm:subpermanentFormula}, we have, for each $k$ in the range $0 \leq k \leq n$, that
\begin{align*}
d_G &= \per(M)^2,\\
&= \binom{n}{k}^{-2} \left (\sum_{S,S' \in \binom{[n]}{k}} \per(M(S,S')) \per(M(\overline{S},\overline{S'})) \right)^2.\\
\end{align*}

Note that $\per(M(S,S'))\leq k!$, with equality holding for all $S,S'$ if and only if $G=K_{n,n}$.
Hence,
$$d_G \leq k!^2 \binom{n}{k}^{-2} \left (\sum_{S,S' \in \binom{[n]}{k}} \per(M(\overline{S},\overline{S'})) \right)^2.$$
By the Cauchy-Schwarz inequality,
$$\left (\sum_{S,S' \in \binom{[n]}{k}} \per(M(\overline{S},\overline{S'})) \right)^2 \leq \sum_{S,S' \in \binom{[n]}{k}} \per(M(\overline{S},\overline{S'}))^2 \sum_{S,S' \in \binom{[n]}{k}} 1.$$
Note that this inequality is tight if $G=K_{n,n}$.
Substituting back into the expression for $d_G$, we get
\begin{equation}\label{eq:d_G} d_G \leq k!^2 \sum_{S,S' \in \binom{[n]}{k}} \per(M(\overline{S},\overline{S'}))^2.\end{equation}

On the other hand, we have by Lemma \ref{thm:permutationSum} that
\begin{equation}\label{eq:p_G}
p_G = \sum_{k=0}^n \sum_{S, S' \in \binom{[n]}{k}} \per(M(\overline{S}, \overline{S'}))^2.
\end{equation}

Combining (\ref{eq:d_G}) and (\ref{eq:p_G}), we have
$$\frac{p_G}{d_G} \geq \sum_{k=0}^n k!^{-2},$$
with equality if and only if $G=K_{n,n}$.
\end{proof}

\section{Arbitrary directed graphs}\label{sec:arbitrary}

In this section, we prove Theorem \ref{thm:ratioHalf}.
Let us recall the statement of the theorem.

\ratioHalf*

The basic idea of the proof is to construct an injection from derangements to non-derangement permutations.

The injection that we construct is based on the cycle structure of the derangement.
As a graph, any permutation is the union of directed cycles and isolated vertices.
In particular, if $\pi(u) = w$ in a permutation $\pi$, then $uw$ is an edge in the corresponding graph.
If $\pi(u) = u$, then $u$ is an isolated vertex.
Derangements are those permutations with no isolated vertices.

Given a derangement $D$, the plan is to map $D$ to a permutation that shares all but one of the cycles of $D$.
The cycle $C$ that we break is the one that contains a specified vertex $v$.
The injection depends on the choice of $v$.
The image of $C$ will normally be a smaller cycle that contains $v$, together with at least one fixed point.
In some special cases, the image of $C$ may be a collection of fixed points, with no cycle.
Given the image of $D$, it is easy to recover all of the cycles in $D$, except for $C$.
It is easy to obtain the set of vertices in $C$, but harder to recover the order of these vertices in $C$.

Handling the cycle that contains the special vertex $v$ is the main difficulty of the proof, and we encapsulate it in the following Lemma.
\begin{lemma}\label{th:HamiltonMap}
Let $G$ be a directed, loopless graph, and let $v \in V(G)$.
Let $\mathcal{H}$ be the set of Hamilton cycles on $G$.
Let $\mathcal{G}$ be the set of permutations on $G$ with at least one fixed point and at most one cycle, such that $v$ is a vertex of the cycle if it exists.
Then, there is an injection $f_v$ from $\mathcal{H}$ to $\mathcal{G}$.
In addition, assuming that $G$ is not a directed cycle, there is a choice of $v$ for which the identity is not in the image of $f_v$.
\end{lemma}

Before proving Lemma \ref{th:HamiltonMap}, we show how it implies Theorem \ref{thm:ratioHalf}.

\begin{proof}[Proof of Theorem \ref{thm:ratioHalf}]
It is an easy observation that $(d/p)_G = 1/2$ if $G$ is a directed cycle.
Assume that $G$ is not a directed cycle.

We describe a family of injections $F_v$ from derangements on $G$ to non-derangement permutations on $G$, one injection for each vertex $v \in V(G)$.
This family of injections has the property there exists at least one $v$ for which the identity permutation is not in the image of $F_v$.
Hence, the total number of permutations is at least twice the number of derangements, plus one for the identity permutation.

For each derangement $D$ on $G$, let $F_v(D)$ be the union of all cycles of $D$ that do not contain $v$, together with the image of the cycle $C$ that contains $v$ under the function described in Lemma \ref{th:HamiltonMap} applied to the subgraph of $G$ induced by the vertices of $C$.

For the derangements that are Hamilton cycles, the map $F_v$ is exactly the map $f_v$ described in Lemma \ref{th:HamiltonMap}.
By Lemma \ref{th:HamiltonMap}, there is a choice of $v$ so that the identity permutation is not in the image of $f_v$.
For derangements that are not Hamilton cycles, each cycle that does not contain $v$ will be mapped to itself, and so the these derangements cannot map to the identity.
Hence, there is a choice of $v$ for which the identity is not in the image of $F_v$.

Given Lemma \ref{th:HamiltonMap}, it is easy to see that each permutation $P$ in the image of $F_v$ has a unique preimage $D$.
Indeed, the preimage of each cycle in $P$ that doesn't contain $v$ is the same cycle.
The preimage of the remaining vertices is their preimage under the map $f_v$ defined in Lemma \ref{th:HamiltonMap}, which is injective.
Hence, $F_v$ is injective, which is sufficient to prove Theorem \ref{thm:ratioHalf}.
\end{proof}

It remains to prove Lemma \ref{th:HamiltonMap}.

\begin{proof}[Proof of Lemma \ref{th:HamiltonMap}]
For any permutation $P$, we denote by $\fix(P)$ the set of fixed points of $P$.
The identity permutation is the unique permutation on $G$ such that $\fix(P) = V(G)$.

Let $v_0 = v$ and let $C=(v_0,v_1,v_2, \ldots,v_{n-1},v_0) \subseteq G$ be a Hamilton cycle on $G$.

Let $(v_i,v_j) \in G$ be a chord of $C$.
Note that $(v_i,v_j)$ completes a cycle $C_{ij}$ with edges from $C$, and there is a nonempty set $L_{ij}$ of vertices in $G$ that are not contained in $C_{ij}$.
Further, knowing $C$, it is easy to identify $i,j$ from either $C_{ij}$ or $L_{ij}$.

If $v_0$ is a vertex of $C_{ij}$, then we say that $(v_i,v_j)$ is a {\em forward chord} of $C$.

If there are no forward chords with respect to $C$, then $C$ is the only Hamilton cycle of $G$.
Indeed, suppose that $(v_0=u_0,u_1,u_2,\ldots,u_{n-1},u_0) \neq C$ is a Hamilton cycle of $G$.
Suppose that $(v_0, v_1, \ldots, v_i) = (u_0, u_1, \ldots, u_i)$, and $v_{i+1} \neq u_{i+1}$.
Then, $(u_i, u_{i+1})=(v_i, v_k)$ is a forward chord of $C$.
Indeed, since $k > i+1$, the sequence $(v_0, v_1, \ldots, v_i, u_{i+1} = v_k, v_{k+1}, \ldots, v_{n-1}, v_0=u_0)$ is a cycle that contains $v_0$.

We define a partial order on forward chords as follows.
Let $(v_i,v_j) \neq (v_k,v_l)$ be forward chords for $C$.
Then, $(v_i,v_j) \prec (v_k,v_l)$ if and only if $L_{ij} \subset L_{kl}$.
This relation inherits the property of being a partial order from the Boolean lattice.
We say that a forward chord $(v_i,v_j)$ is {\em minimal} if there is no forward chord $(v_k,v_l) \prec (v_i,v_j)$.
We say that the {\em first} minimal forward chord is a minimal forward chord $(v_i,v_j)$ such that $i$ is as small as possible.
Since there is at most one minimal forward chord starting at any vertex, the first minimal forward chord is unique.
See Figure \ref{fig:forwardChords}.

\begin{SCfigure}[][h]
\caption{The first minimal forward chord for this cycle is $v_1v_4$. The chord $v_7v_2$ is not forward, $v_1v_5$ is forward but not minimal, and $v_3v_6$ is forward and minimal but not first.}\label{fig:forwardChords}
\includegraphics[width=.6 \textwidth]{forward_chords_2}
\end{SCfigure}

We now describe how to map $C$ to a permutation.
If there are no forward chords with respect to $C$, we map the single Hamilton cycle of $G$ to the permutation consisting only of fixed points.
Otherwise, let $(v_s,v_t)$ be the first minimal forward chord.
We map $C$ to the permutation $P$ consisting of the cycle $C_{st}$ and the fixed points $\fix(P) = L_{st}$.

In order to show that the map we've described is injective, it will suffice to show that we can recover $C$ if we know $P$ and $v_0$.
To do this, we need to recover the identity of $v_s$ and $v_t$, and to find the order of $\fix(P)$ in $C$.

\begin{claim}
The first vertex in $C_{st}$ that has an edge into $\fix(P)$ is $v_s$, and $v_s$ has exactly one edge into $\fix(P)$.
\end{claim}
\begin{proof}
Suppose, for contradiction, that there is an edge $(v_i,v_j)$ with $i<s$ and $v_j \in \fix(P)$.
Then, either $(v_i,v_j)$ is minimal, or there is a minimal forward chord $(v_k, v_l) \prec (v_i,v_j)$.
If $(v_i,v_j)$ is minimal, then $(v_s,v_t)$ cannot be the first minimal forward chord, and we reach a contradiction.
If $(v_k, v_l) \prec (v_i,v_j)$, then either $k < s$ or $k \geq s$.
If $k < s$, then $(v_s, v_t)$ is not first, and we reach a contradiction.
If $k \geq s$, then $(v_s,v_t)$ is not minimal, and we reach a contradiction.

We still need to show that $v_s$ has only one edge into $\fix(P)$.
Suppose that there is an edge $(v_s,v_j) \in G$ with $j \neq s+1$ and $v_j \in \fix(P)$.
Then $(v_s,v_j)$ is a forward chord of $C$ with $(v_s,v_j) \prec (v_s,v_t)$, contradicting the choice of $(v_s,v_t)$ in the construction.
\end{proof}

Using this claim, we can identify $v_s$ and $v_t$, and we can identify $v_{s+1} \in \fix(P)$.
To do this, we simply start at $v_0$ and follow edges of $C_{st}$ until we find a vertex that has an edge into $\fix(P)$.
The vertex with an edge into $\fix(P)$ is $v_s$, the vertex in $\fix(P)$ that has an edge from $v_s$ is $v_{s+1}$, and the vertex that follows $v_s$ in $C_{st}$ is $v_t$.

Having identified $v_{s+1}$, we claim that we can determine the order of $\fix(P)$ in $C$.
Indeed, there are no forward chords in $\fix(P)$, since any such forward chord would precede $(v_s,v_t)$ in our partial order on forward chords, contradicting the minimality of $(v_s,v_t)$.
Hence, there is exactly one edge from any set $\{v_{s+1}, v_{s+2}, \ldots, v_{k}\}$ into $\{v_{k+1}, v_{k+2}, \ldots, v_{t-1}\}$.
Using this fact in an easy inductive argument, we can identify the order $\fix(P)$ in $C$.

It only remains to show that, under the assumption that $G$ is not a directed cycle, there is a choice of $v=v_0$ for which the identity permutation is not in the image of $f_v$.
It is already established that the permutation consisting of fixed points is only in the image of $f$ if there is exactly one Hamilton cycle $C$ on $G$.
If there is a chord $u,w$ of $C$, then $f_u(C)$ will include the cycle formed by $(u,w)$ together with edges of $C$, and hence the permutation consisting of fixed points will not be in the image of $f_u$. This completes the proof of Lemma \ref{th:HamiltonMap}.
\end{proof}

The proof of the main theorem is done.
Here is one other interesting consequence of Lemma \ref{th:HamiltonMap}.

\begin{corollary}\label{thm:hamilton}
For any directed graph $G=(E,V)$ that is not a directed cycle, there is a vertex $v \in V$ such that the number of cycles in $G$ that contain $v$ is at least twice the number of Hamilton cycles in $G$.
\end{corollary}

Indeed, for an appropriate choice of $v$, Lemma \ref{th:HamiltonMap} gives an explicit injection from the set of Hamilton cycles that contain $v$ to cycles that are not Hamilton.

If $G$ is a directed cycle together with an additional edge, then there are two cycles in $G$, one of which is Hamilton.
In this case, the conclusion of Corollary \ref{thm:hamilton} does not hold for those vertices not in the second cycle of $G$, and cannot be improved for those vertices that are in the second cycle of $G$.
The $2$-blowup of a directed cycle, discussed in Section \ref{sec:constructions}, gives a more interesting example for which the conclusion of Corollary \ref{thm:hamilton} is tight.
\section{Matchings in general graphs}\label{sec:matchingsInGeneralGraphs}
Let us now proceed to the proof of Theorem \ref{th:matchingInGeneral}.

\begin{proof}[Proof of Theorem \ref{th:matchingInGeneral}]
Let $G$ be a graph and $M=\{v_1u_1,v_2u_2,\ldots, v_nu_n\}$ be a perfect matching in $G$. By assigning $v_i,u_i$ one each to sets $L$ and $R$ for all $i$ we obtain $2^{n-1}$ different bipartitions of the vertex set. Let us denote by $G_1,\ldots, G_{2^{n-1}}$ the bipartite graphs obtained by only retaining the edges of $G$ between $L$ and $R$ for each of these bipartitions.

Note that $M$ is a perfect matching in each of the $G_i$ by construction. Let $a_i$ denote the number of perfect matchings of $G_i$ which intersect $M$ and $b_i$ the number of perfect matchings of $G_i$ that do not. By Theorem \ref{th:matchingInBipartiteGraph} we know $a_i \ge b_i$.

Furthermore, if $M'$ is any perfect matching of $G$ then $M \cup M'$ is bipartite, which means $M'$ is contained in at least one graph $G_i$. This implies that the number of perfect matchings in $G$ which don't intersect $M$ is upper bounded by $b_1+\cdots+b_n\le a_1+a_2+\cdots+a_n.$

On the other hand every perfect matching $M'$ of $G$ intersecting $M$ appears in at most $2^{n-1}$ of the $G_i$, so there are at least $(a_1+\cdots+a_n)/2^{n-1}$ such matchings. In particular, this is at least $1/2^{n-1}$ times the number of perfect matchings in $G$ which don't intersect $M$. This means that the proportion of perfect matchings which intersect $M$ is at least $1/(2^{n-1}+1)$ of the total number of perfect matchings as claimed.

\ignore{Let $G$ be any graph on $2n$ vertices and $M$ a perfect matching in $G$.  By selecting one vertex from each edge of $M$, there are $2^{n-1}$ ways to partition the vertices of $G$ into sets $\{L, R\}$ such that each edge of $M$ meets $L$ exactly once.  For each such bipartition, let $G[L,R]$ denote the bipartite subgraph of $G$ obtained by retaining only the edges that meet both $L$ and $R$.

Note that if $M'$ is any perfect matching of $G$, then $M \cup M'$ is bipartite and thus there exists a bipartition for which $M' \in G[L,R]$.  Using this fact followed by Theorem \ref{th:matchingInBipartiteGraph}, we obtain
\begin{eqnarray*}
|\{M' : M \cap M' = \emptyset\}| &\leq& \sum_{\{L,R\}} |\{M' :  M \cap M' = \emptyset \text{ and } M' \subseteq G[L,R]\}|\\
 &\leq& \sum_{\{L,R\}} |\{M' :  M \cap M' \neq \emptyset \text{ and } M' \subseteq G[L,R]\}|\\
  &\leq& 2^{n-1} |\{M' : M \cap M' \neq \emptyset\}|,
\end{eqnarray*}
which establishes the lower bound.}

\hrulefill

Our construction is the graph $H$ defined on $\{v_1,\ldots, v_{2n},$ $u_1,\ldots,u_{2n}\}$ as follows. For each $i=1,\ldots, n$ we put all the edges between $\{v_{2i-1},v_{2i}\}$ and $\{u_{2i-1},u_{2i}\}$ and make $v_{2i-1}v_{2i}$ and $u_{2i}u_{2i+1}$ edges (with $u_{2n+1}=u_1$)

\begin{figure}[h]
    \centering
    \begin{tikzpicture}[scale=0.6][line cap=round,line join=round]

	\defPt{-1}{-3}{u1}
	\defPt{1}{-3}{u2}
	\defPt{-1}{-5}{v1}
	\defPt{1}{-5}{v2}

	\defPt{3}{-1}{u3}
	\defPt{3}{1}{u4}
	\defPt{5}{-1}{v3}
	\defPt{5}{1}{v4}

	\defPt{1}{3}{u5}
	\defPt{-1}{3}{u6}
	\defPt{1}{5}{v5}
	\defPt{-1}{5}{v6}

	\defPt{-3}{1}{u7}
	\defPt{-3}{-1}{u8}
	\defPt{-5}{1}{v7}
	\defPt{-5}{-1}{v8}

	\def 3 {3}
	\def 0.8 {0.8}
	\pgfmathsetmacro{\p}{0.8*3}

	\draw[line width=2pt] (u1) -- (v1) -- (u2) -- (v2) -- (u1);
	\draw[line width=2pt] (u3) -- (v3) -- (u4) -- (v4) -- (u3);
	\draw[line width=2pt] (u5) -- (v5) -- (u6) -- (v6) -- (u5);
	\draw[line width=2pt] (u7) -- (v7) -- (u8) -- (v8) -- (u7);

	\draw[line width=2pt,red] (v1) -- (v2);
	\draw[line width=2pt,red] (v3) -- (v4);
	\draw[line width=2pt,red] (v5) -- (v6);
	\draw[line width=2pt,red] (v7) -- (v8);

	\draw[line width=2pt,red] (u2) -- (u3);
	\draw[line width=2pt,red] (u4) -- (u5);
	\draw[line width=2pt,red] (u6) -- (u7);
	\draw[line width=2pt,red] (u8) -- (u1);

	\foreach \i in {1,...,8}
	{
		\draw (u\i) circle[radius = .08][fill = black];
		\node[] at ($0.85*(u\i)$) {$u_{\i}$};
		\draw (v\i) circle[radius = .08][fill = black];
	    \node[] at ($1.1*(v\i)$) {$v_{\i}$};
	}

	\end{tikzpicture}
    \caption{The construction in Theorem \ref{th:matchingInGeneral} for $n=4$. The red edges form $M_0$.}
    \label{fig:matchingExample}
\end{figure}

Let $M_0$ be the perfect matching in $G$ given by $\{v_1v_2,\ldots, v_{2n-1}v_{2n}\}$ and $\{u_2u_3,u_4u_5,\ldots, u_{2n}u_1\}$. Notice that if for each $i$ we choose either $v_{2i-1}u_{2i-1}$ and $v_{2i}u_{2i}$ or $v_{2i-1}u_{2i}$ and $v_{2i}u_{2i-1}$ we get a perfect matching in $G$, so there are $2^n$ perfect matchings disjoint from $M_0$.  And in fact $H$ has no other perfect matchings, since (perhaps after some thought) it is clear that any perfect matching containing an edge of $M_0$ must coincide with $M_0$.
\end{proof}

The argument for our lower bound could perhaps be improved in two ways.  First, note that every perfect matching $M'$ appears in $2^{c-1}$ bipartitions $G[L,R]$, where $c$ is the number of components of $M \cup M'$.  For matchings disjoint with $M$, we used the crude lower bound of $1$ and for the others an upper bound of $2^{n-1}$.  Although this may feel like giving up quite a lot, these were actually tight in our construction $H$.  The second possible area for improvement would be to remove the slack incurred in our application of Theorem \ref{th:matchingInBipartiteGraph}.

\section{Random (di)graphs}\label{sec:randomGraphs}
Here, we outline the proof of Proposition \ref{th:randomRatios}.  Our approach for this is a routine second-moment method in the spirit of Janson's \cite{janson1994numbers}, where the main idea is to first condition on the number of edges (resp.\ arcs).  We direct the readers to \cite{alon2004probabilistic} for a general text on probabilistic combinatorics and to the papers \cite{janson1994numbers} and \cite{frieze1995analysis} for details of the argument we outline below.

\begin{proof}
We first outline the proof for the directed graph case, discussing modifications needed for the graph case at the end.  Following the ideas in \cite{janson1994numbers, frieze1995analysis}, let $DG = DG_{n,m}$ denote a uniformly random digraph on $n$ vertices having exactly $m$ arcs.  Let $X$ denote the number of derangements of $DG$ and let $Y$ denote the number of permutations.  Note for a digraph $H$ on $[n]$ having $t$ arcs, the probability that $H$ is contained in $DG$ depends only on $t$ and is given by
\[
\mathbb{P}(H \subseteq DG) =f(t) := {n(n-1) - t \choose m-t} {n(n-1) \choose m}^{-1}.
\]
For $1 \leq t \leq 2n$ (and $\varepsilon n^2 /2 \leq m \leq n^2$), this is given by
\[
\mathbb{P}(H \subseteq DG) =f(t) = \left(\dfrac{m}{n(n-1)} \right) ^{t} \exp \left\{ \dfrac{-t^2}{2} \left(\dfrac{1}{m} - \dfrac{1}{n(n-1)} \right) + \mathcal{O}(1/n) \right\}.
\]
When $t=n$, this gives the probability that a given derangement is contained in $DG$.  Let $Der(n)$ denote the number of derangements of the set $[n]$, and define $\gamma = m / [n(n-1)]$.  Using that $n! /e-1 \leq Der(n) \leq n! /e+1$, we have
\begin{eqnarray*}
\mathbb{E}[X] &=& f(n) Der(n) = \gamma^n \exp \left[ \left(\dfrac{-n^2}{2m} + \dfrac{n}{2(n-1)} \right) + \mathcal{O}(1/n) \right] Der(n)\\
&=& \gamma ^n \exp \left[ \dfrac{-1}{2\gamma} + \dfrac{1}{2} + \mathcal{O}(1/n) \right]Der(n) = n! \gamma ^n \exp \left[\dfrac{-1}{2\gamma} - \dfrac{1}{2} + \mathcal{O}(1/n) \right]
\end{eqnarray*}
as the expected number of derangements of $DG_{n,m}$.

Similarly, if $\sigma$ is a permutation of $[n]$ with $k$ fixed points, then the probability that $\sigma$ is a permutation of $DG$ is $f(n-k)$.  Therefore, the expected number of permutations of $DG$ is given by
\begin{eqnarray*}
\mathbb{E}[Y] &=& \sum_{k = 0} ^{n} f(n-k) {n \choose k} Der(n-k)\\
&=& n! \gamma^n \exp\left[\dfrac{-1}{2\gamma} - \dfrac{1}{2} + \mathcal{O}(1/n)\right]\\
& & \qquad \qquad \times \sum_{k=0} ^{n} \dfrac{(1/\gamma)^{k}}{k!} \exp\left[\dfrac{2kn - k^2}{2} \left(\dfrac{1}{m} - \dfrac{1}{n(n-1)} \right) \right]\\
&=& n! \gamma^n \exp\left[\dfrac{1}{2\gamma} - \dfrac{1}{2} + \mathcal{O}(\log(n)/n)\right],
\end{eqnarray*}
where in the last line, we estimate the sum by the Taylor series for $e^{1/\gamma}$.  The slightly enlarged (suboptimal) error term comes from a very crude bound estimating the sum based on whether or not $(1/\gamma)^k / k! \leq 1/n$.

After this, to finish the directed graph case we need only estimate the variances of $X$ and $Y$.  Routine computations almost identical to those in \cite{frieze1995analysis} show that $\mathbb{E}[X^2] = \mathbb{E}[X]^2 (1 + o(1))$ and $\mathbb{E}[Y^2] = \mathbb{E}[Y]^2 (1 + o(1))$.  Therefore, by Chebyshev's inequality, with high probability $X/Y = (1 \pm o(1)) \mathbb{E}[X] / \mathbb{E}[Y] = (1 \pm o(1)) e^{-1/\gamma}.$  The proof concludes by the standard coupling of $DG_{n,q}$ and $DG_{n,m}$ using the fact that $\gamma = q + o(1)$ with high probability (since the number of arcs of $DG_{n,q}$ is well concentrated).  See \cite{janson1994numbers, frieze1995analysis} for full details of this method.

The graph case is almost identical but with $\gamma = 2m / n^2$.  In the directed graph case, a guiding heuristic in computing moments is that two random derangements should share approximately as many edges as two random permutations.  Whereas in the graph case, the heuristic is that for a random permutation, the number of fixed points and the number of cycles of length 2 should be approximately independent.
\end{proof}

\section{Open problems}\label{sec:openProblems}

Finally, we mention a few open problems, mostly inspired by studying derangements and permutations on graphs.

\begin{enumerate}
	\item Theorem \ref{th:matchingInGeneral} shows that in general, a perfect matching may intersect with only an exponentially small proportion of all perfect matchings, but there is a sizable gap between our construction and the general lower bound.  What is the correct base for the exponent?
	\item Let $S = \{(d/p)_G \ : \ \text{$G$ is a digraph}\}$ be the set of values arising as a ratio $(d/p)$.  We have shown that $S \subseteq [0,1/2]$ and that $S$ is dense in $[0,1/e]$ (by taking the appropriate Erd\H{o}s--Renyi graphs).  Is $S$ dense in $[0,1/2]$?  If so, is $S$ equal to $[0,1/2] \cap \mathbb{Q}$?
	\item What can be said about $(d/p)$ for regular directed graphs with degree greater than $n/2$, but much less than $n$?
\end{enumerate}

\bibliographystyle{plain}


The OEIS: A Fingerprint File for Mathematics

Abstract: An introduction to the On-Line Encyclopedia of Integer Sequences (or OEIS,this https URL) for graduate students in mathematics

\section{The OEIS}\label{SecI}
The {\em On-Line Encyclopedia of Integer Sequences} or {\em OEIS} \cite{OEIS} is a free website (\url{https://oeis.org}) containing information about 350,000 number sequences. You will probably first encounter it when trying to identify a sequence that has come up in your work. If your sequence is recognized, the response will  tell you the first 100 or sometimes  10,000 terms, give a definition, properties, formulas, references, links, computer programs, etc., as appropriate. If it is not recognized, the system will invite you to submit it if you think it is of general interest, so that the next person who looks it up will find it - and be grateful to you.

Ron Graham called the OEIS a ``fingerprint file for mathematics''. It has also been described as, ``pound for pound, one of the most useful mathematics sites on the web''. If you have been struggling with a sequence, and the OEIS tells you what it is, you will understand why it is so popular.  Of course, if it tells you that your problem was solved forty years ago, you may be unhappy, but it is better to find out now rather than later. The database has been around, in one form or another, for 57 years, so if your sequence is not yet included, there is a moderate chance it is new (of course this is not a proof).

\section{The OEIS as a source of problems}\label{Sec2Prob}
The entries are constantly being updated.
Every day we get a hundred or so submissions of new sequences, and another hundred
comments on existing entries (new formulas, references, additional terms, etc.).

The new sequences  are often sent in by non-mathematicians,
and are a great source of problems to work on. You can see the current submissions at \url{https://oeis.org/draft}.
Often enough you will see a sequence that is so interesting you want to drop everything else and work on it.
Well, go ahead!  Many research papers have been born in this way. The ``Yellowstone Permutation''
\seqnum{A098550}
is one of my favorite examples: it was quite a challenge to prove that it {\em is}
a permutation of the positive integers, and the entry has a link to a paper \cite{Yellow}  that a group of us wrote
analysing it.

Some of the things you might work on after seeing an interesting sequence on the drafts stack are:
\begin{itemize}
\item Is the sequence well-defined?
\item Does it contain infinitely many terms?
\item How fast does it grow? The ``graph'' button in every entry is helpful here.
\item Is there a formula or generating function?
\item Or you may see a conjecture or question  that you think you can answer.
\item How would you program it to generate more terms?
\end{itemize}
Studying the ``drafts''  stack is an endless source of fun (and sleepless nights).

\section{The OEIS as a reference work}\label{SecRef}
Even when you know what the sequence is, you may still look it up, to find out what is presently known about it.
We try to make sure the sequences are well-supplied with references, especially any recent articles.
The coverage is broad: besides the obvious fields like combinatorics, graph theory,
group theory, number theory, computer science, recreational mathematics, there are
large numbers of sequences from physics and chemistry.

This makes the OEIS extremely useful as a reference work.
Earlier this year a senior group theorist told us he had been working on a problem for 20 years, but when he looked it up in the OEIS he found a reference that he was not aware of.

Another great resource are the computer programs. An important sequence will have programs to generate it in C, Java, MAGMA, Maple, Mathematica, PARI, Python, Sage, etc. This is very helpful for numerical investigations.

\section{Submitting your sequence or comment}\label{Sec2Sub}
If you have an interesting number sequence that is not in the OEIS, you should definitely submit it.
Having a sequence in the OEIS is something you can be proud of.
You will be joining an enterprise that has been running
for almost 60 years, and to which over 12,000 people have already contributed.
Contributions come from almost every country, and we have been called one of the most successful
international collaborations.

You must register before you can contribute, using your real name,
the name you would use in a scientific publication
 (see \href{https://oeis.org/wiki/Special:RequestAccount}{Request Account}).
  The OEIS is not a ``social media''. One of
 the reasons for  the success of the database is that we have high standards, all contributions are
 refereed by the editors, and accuracy is of primary importance.
 See \href{https://oeis.org/wiki/Overview_of_the_contribution_process}{here} for more about the submission process.
 The OEIS Wiki also has a page showing examples of
\href{https://oeis.org/wiki/Examples_of_what_not_to_submit}{What not to submit}!

\section{The OEIS Wiki}\label{SecW}
The OEIS Wiki (\url{https://oeis.org/wiki}) has a great deal of useful information for  users, especially in the ``Information'' section. There is a general index to the sequences, a style sheet, a Q\&A page, an FAQ page, pages called
\href{https://oeis.org/wiki/How_to_add_a_comment,_more_terms,_or_a_b-file_(short_version)}{How to add a comment, more terms, or a b-file, ...},
\href{https://oeis.org/wiki/Instructions_For_General_Users}{Instructions for general users},
\href{https://oeis.org/wiki/The_multi-faceted_reach_of_the_OEIS}{The multi-faceted reach of the OEIS}, and so on.

\section{Citations of the OEIS}\label{SecCite}
An especially important part of the OEIS Wiki is the section
 (see \url{https://oeis.org/wiki/Works_Citing_OEIS}) that lists citations of the OEIS in
the literature or on the web. There are now about 10,000 citations, which often say things like ``This theorem would not have been discovered
without the help of the OEIS''.

You can help keep these pages up-to-date. If you come across a paper that mentions a number sequence,
check if the sequence is in the OEIS, add it if it isn't, and make sure the entry has a reference to the paper.
If the context seems new, consider adding a comment saying ``Arises in the spectral analysis of cobweb singularities,
see  A. Spider et al. (2021)."  If you come across an article that references the OEIS, make sure the paper
is listed in the ``Works  Citing the OEIS'' pages on the Wiki.  And if you happen to see a comment that ``This sequence is not in the OEIS", then add it at once.

When you write a paper yourself, using information from the OEIS, don't forget to mention us in your references list,
typically by saying

The OEIS Foundation Inc., Entry A123456. Published electronically at https://oeis.org, 2021,

\noindent
and also mention it in any relevant OEIS entries.
Many authors ``forget'' to do this, but it will help your career by drawing attention to your paper.

\section{``Link Rot''}\label{SecL}

Don't get me started! The OEIS serves as a guide to the literature on a huge number of subjects,
and we have hundreds of thousands of links. And every day many of these links break.
System administrators feel they are not doing their job if they don't change all their URLs every
couple of years. Or, as happened last year, a major university will decide to delete all the faculty  home pages, with no warning. That broke several hundred of our links.
Pages on individual's web sites are the most fragile of all.

If you are a frequent user of the OEIS you will often run into this problem. You can help by locating a replacement
URL if the site has simply moved, or by adding a new link to a copy of the missing page on the wonderful Wayback Machine, run by the Internet Archive \cite{WBM}.  A better solution is to ask the author of the page
for permission to put a local copy of the page on the OEIS server. We have a strong reputation, and hope to be around for a long time. Almost everyone we have asked has agreed.
But it is a time-consuming business, and you could help.

\section{Other topics}\label{SecOT}

\vspace*{+.2in}
\noindent{\bf ``Superseeker''.} This is a program that runs on our server, and tries very hard to identify a sequence.
It runs several programs that try to guess a formula or recurrence (including the powerful
Salvy-Zimmermann program  {\em gfun} \cite{gfun}). It also transforms
the sequence in a hundred ways and looks up the results in the OEIS,  hoping for a match.
To use it, send an email
to  \href{mailto:superseeker@oeis.org}{\tt superseeker@oeis.org}.
with a blank subject, containing a single line of the form

   lookup 0 1 3 7 11 15 23 35 43 47

\noindent
(with no commas).
 Since this uses many resources on our server, please use it sparingly.

   One of my current goals is to strengthen Superseeker. If you are interested in helping, please contact me.

   \vspace*{+.2in}
   \noindent{\bf The Sequence Fans Mailing List.}  Any registered user of the OEIS can join, and
   messages go out to a few hundred fellow sequence-lovers.  This can be even more powerful than Superseeker if you are really desperate to identify a sequence. There is a link on the OEIS Wiki.

    \vspace*{+.4in}
   \noindent{\bf Triangles and arrays of numbers.}
   The OEIS also includes triangles and arrays of numbers. Triangles are read by rows. Pascal's triangle
   becomes \seqnum{A007318}: $1, ~1, 1, ~1, 2, 1,$ $1, 3, 3, 1, ~1, 4, 6, 4, 1,$ $1, 5, 10, 10, 5, 1, \ldots$.
   Arrays are read by antidiagonals. The table of Nim-sums $m \oplus n$ \cite{BON},
$$
\begin{array}{ccccccc}
0 & 1 & 2 & 3 & 4 & 5 & \ldots \\
1 & 0 & 3 & 2 & 5 & 4 & \ldots  \\
2 & 3 & 0 & 1 & 6 & 7 & \ldots  \\
3 & 2 & 1 & 0 & 7 & 6 & \ldots  \\
4 & 5 & 6 & 7 & 0 & 1 & \ldots  \\
. & . & . & . & . & . & \ldots  \\
\end{array}
$$
becomes \seqnum{A003987}, $0, ~1, 1,~ 2, 0, 2,$ $ 3, 3, 3, 3, $ $ 4, 2, 0, 2, 4, \ldots$.

\vspace{0.2in}

The OEIS aims for a broad coverage of integer sequences arising in science, especially in mathematics (of course including several versions of the famous subway stops sequence, since they have been published on tests;  but not the number of pages in the $n$th issue of these {\em Notices} since 1954, because no one has mentioned it before). Our motto is accuracy and completeness, combined with good judgment.
We have a great many contributors, a great many entries, and we hope you will join us at \url{https:oeis.org}.

History and Overview (math.HO); Combinatorics (math.CO)