\section{Introduction}\label{sec:intro} \subsection{Markoff numbers and the uniqueness conjecture} A \emph{Markoff triple} is a solution $(a,b,c)$ in positive integers of the Markoff equation \begin{equation}\label{eq:markoff} a^2+b^2+c^2=3abc , \end{equation} and a \emph{Markoff number} is a coordinate of a Markoff triple, or equivalently, by the tree structure recalled below, the largest coordinate of some Markoff triple. The first few Markoff numbers are $1,2,5,13,29,34,89,169,194,233,433,610,985$. Markoff introduced the equation in his work on indefinite binary quadratic forms \cites{Markoff1879,Markoff1880}. Below $3$, which is its first accumulation point, the Markoff spectrum of these forms consists exactly of the numbers $\sqrt{9-4/m^2}$ with $m$ a Markoff number, and so does the Lagrange spectrum of Diophantine approximation of irrational numbers. The forms attaining these values are parametrized by the Markoff triples. The Markoff equation is preserved by the permutations of the coordinates and by the \emph{Vieta involution} $(a,b,c)\mapsto(a,b,3ab-c)$, which replaces $c$ by the other root of \eqref{eq:markoff} viewed as a quadratic equation in $c$. Every Markoff triple arises from $(1,1,1)$ by these moves. The sorted triples $a\le b\le c$ other than $(1,1,1)$ and $(1,1,2)$ form a binary tree rooted at $(1,2,5)$, in which each triple $(a,b,c)$ has the two children $(a,c,3ac-b)$ and $(b,c,3bc-a)$; see Cassels~\cite{Cassels}*{Chapter II} or Aigner~\cite{Aigner}. Frobenius~\cite{Frobenius} asked in 1913 whether a Markoff triple is determined by its largest coordinate. \begin{quote} \textbf{Uniqueness conjecture.} If $(a,b,c)$ and $(a',b',c)$ are Markoff triples with $a\le b\le c$ and $a'\le b'\le c$, then $(a,b)=(a',b')$. \end{quote} A Markoff number $c$ for which the conclusion holds is called \emph{unique}. The conjecture has been verified numerically for all Markoff numbers below $10^{105}$ (Borosh~\cite{Borosh}; see \cite{Aigner} for the history), and it is known for Markoff numbers of special arithmetic shapes: Button proved uniqueness when $c$ is a prime~\cite{Button}, and Schmutz~\cite{Schmutz} and Button~\cite{Button2001} when $c$ is a prime power. Lang and Tan~\cite{LangTan} gave a short geometric proof of the prime power case, and Srinivasan~\cite{Srinivasan} an elementary proof when $c$ is an odd prime power or twice an odd prime power. Baragar~\cite{Baragar} proved uniqueness when $c$, $3c-2$ or $3c+2$ is a prime, twice a prime or four times a prime, and Zhang~\cite{Zhang} when $3c+2$ or $3c-2$ is a prime power, four times a prime power or eight times a prime power. Srinivasan also gave, for odd $c$, a sufficient condition in terms of ambiguous classes of forms of discriminant $9c^2-4$. All these results establish uniqueness under arithmetic conditions on the factorization of $c$ or of $9c^2-4=(3c-2)(3c+2)$. Bourgain, Gamburd and Sarnak \cites{BGS,BGS2} showed that almost all Markoff numbers, counted with multiplicity, are composite. More precisely, for every $\nu$, the proportion of sorted Markoff triples $(a,b,c)$ with $c\le X$ for which $c$ has at most $\nu$ distinct prime factors tends to $0$ as $X\to\infty$ \cite{BGS2}*{Theorem 19}. The Markoff numbers are sparse. Zagier~\cite{Zagier} proved that the number of sorted Markoff triples with largest coordinate at most $X$ is \[ C_0\,\log^2(3X)+O\bigl(\log X\,(\log\log X)^2\bigr),\qquad C_0=0.1807\ldots . \] The uniqueness conjecture would imply that the number of Markoff numbers up to $X$ equals this count of triples for every $X$. In this paper we prove the asymptotic consequence: the two counting functions have the same leading asymptotic. \subsection{The main result} For $X\ge1$ let \begin{align*} T(X)&=\#\{(a,b,c)\in\bZ_{>0}^3:\ a\le b\le c\le X,\ a^2+b^2+c^2=3abc\},\\ D(X)&=\#\{c\le X:\ c\text{ is a Markoff number}\},\\ D_2(X)&=\#\{c\le X:\ c\text{ is the largest coordinate of at least two sorted Markoff triples}\}. \end{align*} Thus $T(X)\ge D(X)$, with equality for all $X$ if and only if the uniqueness conjecture holds, and $D_2(X)$ counts the non-unique Markoff numbers up to $X$. \begin{theorem}\label{thm:main} As $X\to\infty$, \[ T(X)-D(X)=o\bigl(\log^2X\bigr) \qquad\text{and consequently}\qquad \frac{D_2(X)}{D(X)}\longrightarrow0 . \] \end{theorem} In words: the proportion of non-unique Markoff numbers among all Markoff numbers up to $X$ tends to zero, and the number of Markoff numbers up to $X$ is asymptotic to $C_0\log^2(3X)$ with Zagier's constant $C_0$. The proof gives no rate of decay for $D_2(X)/D(X)$; the uniqueness conjecture is the statement that $D_2(X)=0$ for all $X$. By Theorem~\ref{thm:main}, $T(X)\sim D(X)$, so the theorem of Bourgain, Gamburd and Sarnak quoted above holds also for Markoff numbers counted without multiplicity: for every $\nu$, the Markoff numbers with at most $\nu$ distinct prime factors form a set of density zero among all Markoff numbers. This applies in particular to the prime powers and twice prime powers covered by the criteria of Button, Schmutz and Srinivasan. \subsection{The geometric picture}\label{sec:intro-geometry} The proof uses the interpretation of Markoff numbers through hyperbolic geometry, which goes back to Cohn~\cites{Cohn1955,Cohn1971} and was developed by Series~\cite{Series}. Let $\Gamma'$ be the commutator subgroup of $\PSL_2(\bZ)$. It is free of rank two and of index six, and the quotient $\mathbb T=\bH/\Gamma'$ of the upper half-plane is a once-punctured torus, the \emph{modular torus} with a hyperbolic metric. Its fundamental group is the free group $F_2$, and a primitive element of $F_2$ (a member of some free basis) determines, up to conjugacy and inversion, a simple closed geodesic on $\mathbb T$~\cite{MR}*{Facts 2.2, 2.3 and Lemmas 2.4, 2.5} and a primitive\footnote{A vector of $\bZ^2$ is \emph{primitive} if it is nonzero and its coordinates are coprime, that is, if it belongs to a basis of $\bZ^2$. The vector determined by a primitive element of $F_2$ is its homology class, which is primitive because the abelianization $F_2\to H_1(\mathbb T,\bZ)$ maps free bases to bases.} vector $v=(p,q)\in\bZ^2$ of the homology group $H_1(\mathbb T,\bZ)\cong\bZ^2$, defined up to sign. Cohn observed that the traces of the hyperbolic elements of $\Gamma'$ representing simple closed geodesics are exactly the numbers $3m$ with $m$ a Markoff number, and that the simple closed geodesics represented by the two elements of a free basis and by their product have traces $(3a,3b,3c)$ with $(a,b,c)$ a Markoff triple. In \S\ref{sec:dictionary} we make this dictionary precise in the form we need. We write $m(v)$ for the Markoff number attached to a primitive vector $v$, the \emph{label} of $v$, so that the corresponding geodesic has length \begin{equation}\label{eq:length} N(v)=2\arcosh\bigl(3m(v)/2\bigr). \end{equation} Let $\sect=\{(p,q)\in\bR^2:\ 0\le2p\le q\}$, the closed sector of vectors of slope $p/q$ between $0$ and $1/2$. The isometry group of $\mathbb T$ acts on $H_1(\mathbb T,\bZ)\cong\bZ^2$, and hence linearly on $\bR^2$, through a dihedral group $\cK$ of order twelve (\S\ref{sec:rigidity}). The sector $\sect$ is a fundamental domain for the action on $\bR^2$, and every $\cK$-orbit of primitive vectors meets $\sect$ in exactly one vector. The sorted Markoff triples correspond bijectively to the primitive vectors of $\sect$, and under this bijection the largest coordinate of a triple is the label of the vector (Lemma~\ref{lem:dictionary}). Consequently, the uniqueness conjecture is equivalent to the statement that two simple closed geodesics of the modular torus of the same length differ by an isometry. Theorem~\ref{thm:main} says that the number of simple closed geodesics of length $\le L$, counted modulo isometry, exceeds the number of distinct lengths $\le L$ by only $o(L^2)$. In particular, the exceptional lengths, those attained by two geodesics that are related by no isometry, form a set of density zero among all lengths. McShane and Rivin~\cites{MR,MRcr} proved that the length function $v\mapsto N(v)$ on primitive vectors extends to a norm $N$ on $\bR^2$, the \emph{stable norm} of $\mathbb T$, whose unit ball $\ball$ is strictly convex. The number of primitive vectors $v$ with $N(v)\le L$, that is, of primitive lattice points in $L\ball$, is then asymptotic to $\area(\ball)L^2/\zeta(2)$ \cite{MR}*{Theorem 0.1 and \S5}; the constant comes from M\"obius inversion, as in the proof of Lemma~\ref{lem:dictionary}(d). Hence the number of simple closed geodesics of length at most $L$, each corresponding to a pair $\pm v$, is asymptotic to $\area(\ball)L^2/(2\zeta(2))$. In this language Theorem~\ref{thm:main} says that, among the primitive vectors $v\in\sect$ with $N(v)\le L$, whose number is asymptotic to a constant times $L^2$, all but $o(L^2)$ have a norm $N(v)$ shared by no other primitive vector of $\sect$. The boundary of $\ball$ has a corner at every rational direction, with exterior angle decaying exponentially in the height $\max(|p|,|q|)$ of the primitive vector $(p,q)$ in that direction \cite{MRcr}*{Theorem 2.1}; Proposition~\ref{prop:turn}(a) below computes the corner exactly. At every irrational direction the boundary is differentiable \cites{SorrentinoVeselov,DLN}. The local geometry at irrational directions was recently analyzed by Doan, Li and Nguyen \cite{DLN}, who also used estimates on the turning of the normal of $\partial\ball$ to show that at most $C(\log\log 3m)^2$ simple closed geodesics have length $2\arcosh(3m/2)$; hence each Markoff number $m$ is the largest coordinate of at most $C(\log\log 3m)^2$ sorted triples. We use an estimate of the same nature, Proposition~\ref{prop:turn}, to confine all but $o(L^2)$ of the pairs of lattice points of norm at most $L$ at which $N$ takes equal values, outside a sparse set of directions, to the graphs of $(\log L)^{O(1)}$ rational linear maps (Stage 1 in \S\ref{sec:intro-strategy}). \subsection{Strategy of the proof}\label{sec:intro-strategy} Throughout, $L$ is a large length; in Stages 1 and 3 below, all lattice points $v$ considered lie in the sector $\sect$ and satisfy $N(v)\le L$. A \emph{collision pair} is an ordered pair $(v,w)$ of distinct primitive vectors in $\sect$ with $N(v)=N(w)\le L$. Theorem~\ref{thm:main} follows (\S\ref{sec:proof-main}) once we show that for every $\varepsilon>0$ and all large $L$, the primitive vectors of $\sect$ with $N\le L$ can be partitioned into at most $\varepsilon L^2$ \emph{deleted} vectors and a set of \emph{retained} vectors among which there are at most $\varepsilon L^2$ collision pairs. The deleted set is determined by the geometry of the unit ball alone: it consists of the lattice points on finitely many rays and in a sparse set of angular sectors. The argument has three stages. \subsubsection*{Stage 1: collision pairs lie on rational graphs} Let $u,v$ be \emph{Farey neighbours}, that is, primitive vectors with $|\det(u,v)|=1$. The vectors $u$, $v$ and $u+v$ carry the three labels of a Markoff triple, and the Vieta involution of the triple becomes the recurrence \begin{equation}\label{eq:intro-recurrence} m(u+v)+m(u-v)=3\,m(u)\,m(v). \end{equation} In \S\ref{sec:geometry} we exploit this recurrence to describe the boundary of $\ball$ between two consecutive rays of the \emph{Farey fan of level $H$}, the set of rays from the origin through the primitive vectors of height $\max(|p|,|q|)\le H$. On each open sector of this fan the supporting lines of $\ball$ vary by at most $Ce^{-\kappa H}$, while at the rays themselves $\partial\ball$ has corners of exterior angle at least $ce^{-CH}$ (Proposition~\ref{prop:turn}). The decay comes from the label of the \emph{mediant} $u+v$ of the two boundary vectors $u,v$ of such a sector. Substituting $m(u)$ and $m(v)$ for the first two variables of the Markoff equation \eqref{eq:markoff} leaves a quadratic equation in the third. Its roots are $m(u+v)$ and, by the recurrence \eqref{eq:intro-recurrence}, $m(u-v)$, and the mediant carries the \emph{larger} one. By the length formula \eqref{eq:length}, $3m(w)=2\cosh(N(w)/2)$ for every primitive vector $w$, so the formula for the larger root gives \[ 3m(u+v)=2\cosh\bigl((N(u)+N(v))/2\bigr)+O\bigl(e^{-(N(u)+N(v))/2}\bigr). \] Hence $N(u+v)=N(u)+N(v)+O(e^{-N(u)-N(v)})$: up to an exponentially small error, the norm is additive across the sector. This near additivity is what makes $\partial\ball$ nearly flat there. Fix a pair of sectors $\Sigma,\Sigma'$ of the fan of level $H\asymp\log L$. Let $\lambda,\lambda'$ be supporting functionals of $N$ at points of $\Sigma,\Sigma'$, that is, linear forms $\le N$ that agree with $N$ at these points (\S\ref{sec:supports}), and let $\ell=(\lambda,-\lambda')$ be the corresponding linear form on $\bR^4$. For a collision pair $(v,w)\in\Sigma\times\Sigma'$, its \emph{collision vector} $(v,w)\in\bZ^4$ satisfies $|\ell(v,w)|\le CLe^{-\kappa H}$, an exponentially small quantity. Four linearly independent collision vectors in $\Sigma\times\Sigma'$ would have an integer determinant of absolute value at least $1$, whereas expanding the determinant along $\ell$ bounds it by $CL^4e^{-\kappa H}<1$ once the constant in $H\asymp\log L$ is large. If instead the collision vectors span a hyperplane $W\subset\bR^4$, then its primitive integral normal $(\alpha,\beta)\in\bZ^2\times\bZ^2$ has size $O(L^3)$, and since $\ell$ is nearly zero on $W$, this normal is nearly parallel to $\ell$. Hence the supporting functionals of $N$ at points of $\Sigma'$ are nearly parallel to the integral form $\beta$. To rule this out, we excise beforehand the sectors containing the contact points of the integral forms of size $O(L^3)$, the points of $\partial\ball$ at which such a form attains its maximum on $\ball$. These contact points lie on $O(\log^2L)$ rays (Lemma~\ref{lem:contacts}). In each remaining sector, the corners of $\partial\ball$ at the two boundary rays keep the supporting functionals away from every such form, by an angle that is exponentially small but larger than the one forced by $W$ once $\Sigma,\Sigma'$ are taken from a finer fan than the excised sectors (Lemma~\ref{lem:excision}). The outcome (Lemma~\ref{lem:ranktwo}) is that, after deleting $O(L^2/A_0)$ lattice points for a large parameter $A_0$, the collision vectors of the remaining collision pairs in every sector pair span a subspace of $\bR^4$ of dimension at most two, so that, apart from negligible degenerate cases, they satisfy $w=Gv$ for a single matrix $G=G_{\Sigma,\Sigma'}\in\GL_2(\bQ)$. We call $\{(v,Gv)\}$ the \emph{graph} of $G$, and we measure the complexity of $G$ by the index $I(G)$, the maximum of the indices in $\bZ^2$ of the lattice $\bZ^2\cap G^{-1}\bZ^2$ and of its image under $G$, and by its entry height $h(G)$, the largest absolute value of its entries. Two elementary lemmas (Lemmas~\ref{lem:indices} and \ref{lem:height}) show that graphs of index larger than $(\log L)^5$, or of entry height larger than $10(1+|\det G|)$, carry only $o_{A_0}(L^2)$ collision pairs in total. \subsubsection*{Stage 2: a fixed rational map produces few equalities} Stage 1 leaves a family of rational matrices $G\notin\cK$ with $I(G)\le(\log L)^5$ and $h(G)\le10(1+|\det G|)$, and it remains to count the primitive $v$ with $Gv$ primitive and $N(Gv)=N(v)\le L$ on each graph. For a single fixed $G$ we prove in \S\ref{sec:fixed} that there are only $o_G(L^2)$ such $v$ (Proposition~\ref{prop:fixed}). This is the arithmetic heart of the paper, and it is where the specific structure of the Markoff equation enters. The equation $N(Gv)=N(v)$ is equivalent to $m(Gv)=m(v)$ by the length formula \eqref{eq:length}. We work on the set \[ \cX=\{(a,b,c)\in(\bZ_3^\times)^3:\ a^2+b^2+c^2=3abc\} \] of $3$-adic unit points of the Markoff surface, on which $\GL_2(\bZ)\cong\operatorname{Out}(F_2)$, the extended mapping class group of the torus, acts by the Vieta involutions and the coordinate permutations (the \emph{Nielsen moves}, defined in \S\ref{sec:fixed}). The label $m(v)$ of a primitive vector $v$ is the value at the base point $o=(1,1,1)$ of a trace polynomial $Q_v$ with integer coefficients, and the action satisfies $Q_v(P\ast\gamma)=Q_{\gamma v}(P)$ for $\gamma\in\SL_2(\bZ)$. For $h$ in the finite-index subgroup $H_G=\SL_2(\bZ)\cap G^{-1}\SL_2(\bZ)G$, both $h$ and $GhG^{-1}$ are integral, and for $v,Gv\in\bZ^2_\prim$ the equality $m(hv)=m(Ghv)$ is the vanishing of the single polynomial \[ F(P,P')=Q_v(P)-Q_{Gv}(P')\qquad\text{at the point}\qquad (o\ast h,\,o\ast GhG^{-1})\in\cX^2 . \] The set of such points, as $h$ ranges over a coset of the finite-index subgroup $J$ of $H_G$ that acts trivially on $\cX^2$ modulo $9$ (\S\ref{sec:proof-fixed}), has a compact closure $Y\subset\cX^2$. It carries the $J$-invariant probability measure $\mu_Y$ that is the limit of the uniform measures on the reductions of $Y$ modulo $3^n$, whose elements we call \emph{states}. The key point is a zero-one law: $\mu_Y(F=0)$ is either $0$ or $1$ (Lemma~\ref{lem:zeroone}). It rests on $p$-adic analytic interpolation in the sense of Poonen~\cite{Poonen}. Since $J$ acts trivially on $\cX^2$ modulo $9$, for each $g\in J$ the iterates $g^n$ extend to a $\bZ_3$-action $t\mapsto g^t$ given by a single restricted power series in $t$, that is, one with coefficients in $\bZ_3$ tending to $0$ (\S\ref{sec:3adic} and Lemma~\ref{lem:interpolation}). By Strassmann's theorem, along each orbit of this action $F$ either vanishes identically or has finitely many zeros, and the ergodicity of $\mu_Y$ turns this into the dichotomy. The alternative $\mu_Y(F=0)=1$ means $N(Gv')=N(v')$ for all $v'$ in the corresponding orbit of $v$, whose directions are dense, so $G$ would be a linear isometry of the norm $N$. A rigidity lemma (Lemma~\ref{lem:rigidity}), based on the explicit size of the corners of $\ball$, shows that the only rational isometries of $N$ are the twelve elements of $\cK$. Hence $\mu_Y(F=0)=0$. Finally, to pass from measure zero on $Y$ to the count of lattice points of norm at most $L$, we use the asymptotic count, due to Burrin, Nevo, R\"uhr and Weiss~\cite{BNRW}, of the points of an orbit $Uv$ of a finite-index subgroup $U\le\SL_2(\bZ)$ in the dilates $L\ball$. Its leading coefficient, which we obtain from their argument (Theorem~\ref{thm:cuspcount}), is proportional to the \emph{cusp width} $[\Stab_{\SL_2(\bZ)}(v):\Stab_U(v)]$ divided by the index $[\SL_2(\bZ):U]$. The $J$-orbit of $v$ decomposes into sub-orbits indexed by the cycles of the parabolic stabilizer of $v$ on the finite set of states of $Y$ modulo $3^n$, and the leading coefficient of a sub-orbit is proportional to the length of its cycle. The equalities occur only in the sub-orbits whose cycles consist of states with $F\equiv0\pmod{3^n}$, and summing over these cycles gives the proportion $\mu_Y(F\equiv0\bmod3^n)$, which tends to zero. The count is applied to conjugates of the stabilizers of states modulo $3^n$, which need not be congruence subgroups, so it is needed for arbitrary subgroups of finite index. \subsubsection*{Stage 3: summation over the graphs} Proposition~\ref{prop:fixed} has no uniformity in $G$, whereas Stage 1 produces up to $(\log L)^{O(1)}$ graphs. Section~\ref{sec:sum} resolves this by sorting the graphs into dyadic bands $2^j