\section{Introduction and summary} \label{sec:intro} \subsection{A transition with two descriptions} Anti-de Sitter space (AdS) acts as a box. Light rays reach its boundary and return in a finite time, so that a gas of gravitons inside it comes to thermal equilibrium. Hawking and Page studied this equilibrium in 1983 \cite{HawkingPage}. At low temperature the dominant configuration is a gas of particles in thermal AdS, with a free energy of order one. There is a second solution of Einstein's equations with the same boundary conditions, a black hole at the centre of the space. In AdS$_5$ with radius $R$, black holes exist only above a minimum temperature $T_{\min}=\sqrt2/\pi R$ \cite{WittenThermal}. Above it there are two. The small one has negative specific heat and is unstable. The large one is stable, and at \begin{equation} T_{\rm HP}=\frac{3}{2\pi R} \label{eq:THP} \end{equation} its free energy drops below that of the gas. Above $T_{\rm HP}$ the black hole dominates. The free energy changes from order one to order $1/G_N$, where $G_N$ is Newton's constant, and the transition is first order. Fifteen years later Witten interpreted the transition in gauge theory \cite{WittenThermal}. Through the AdS/CFT correspondence \cite{Maldacena,GKP,WittenHolography}, gravity in AdS$_5\times S^5$ is $\cN=4$ super Yang--Mills theory with gauge group $SU(N)$ on the boundary $S^3\times\mathbb{R}$, at large $N$ and large 't Hooft coupling $\lambda=g_{\rm YM}^2N$. Since $1/G_N\sim N^2$, the Hawking--Page transition is a jump of the free energy from $O(1)$ to $O(N^2)$. This is deconfinement. The order parameter is the Polyakov loop, the holonomy of the gauge field around the thermal circle. It vanishes in thermal AdS, where the thermal circle is not contractible, and it is non-zero in each black-hole saddle, where the circle shrinks smoothly at the horizon. On $S^3$ its phase is averaged over, so that its expectation value vanishes in both phases and it is its magnitude that distinguishes them \cite{WittenThermal,AMMPV1}. A deconfinement transition in a conformal theory on a compact space may seem surprising. There is no dynamical scale to set the temperature, and there are no asymptotic states to confine. The origin of the transition is Gauss's law, which on a compact space requires all states to be gauge singlets. At large $N$ that constraint alone is enough to produce a sharp transition, and it does so even at zero coupling. \subsection{Historical background} The ideas that meet in this problem have three separate origins. The first is the physics of hadrons. In 1965 Hagedorn observed that the number of hadronic resonances grows exponentially with their mass, and concluded that hadronic matter has a highest temperature \cite{Hagedorn}. Ten years later Cabibbo and Parisi read the same growth as the sign of a phase transition, above which quarks are liberated \cite{CabibboParisi}. Polyakov and Susskind then showed that a gauge theory does deconfine when it is heated, and that the order parameter is the holonomy of the gauge field around the thermal circle \cite{PolyakovLoop,SusskindLattice}. The potential for this holonomy was computed at one loop \cite{GPY,Weiss}, and Svetitsky and Yaffe used its symmetry under the centre of the gauge group to classify the possible transitions \cite{SvetitskyYaffe}. The limit of many colours introduced by 't Hooft \cite{tHooft} makes the distinction between the phases sharp. Thorn pointed out that the free energy is of order one in the confined phase and of order $N^2$ in the deconfined phase, and asked whether the confined phase has a highest temperature \cite{Thorn}. Skagerstam imposed the singlet constraint on free quarks and gluons by an integral over the gauge group, which is the device used throughout this paper \cite{Skagerstam}. In the same years Gross and Witten, and Wadia, found that integrals over a unitary matrix at large $N$ have a third-order transition at which the density of eigenvalues develops a gap \cite{GrossWitten,Wadia}. Lattice simulations later established that the transition of pure $SU(N)$ gauge theory in infinite volume is first order for $N\ge3$, with a latent heat of order $N^2$ \cite{LTW,LTW2}. The second origin is the thermodynamics of black holes. Bekenstein and Hawking gave the black hole an entropy and a temperature \cite{Bekenstein,HawkingRadiation}. Gibbons and Hawking showed how to obtain both from a Euclidean path integral in which the black hole is a saddle point \cite{GibbonsHawking}. In flat space the canonical ensemble does not exist, because the specific heat of a Schwarzschild black hole is negative. Hawking and Page showed that a negative cosmological constant removes this difficulty \cite{HawkingPage}. The third origin is string theory, which has a Hagedorn temperature of its own. Sathiapalan, Kogan, and Atick and Witten traced it to a mode of the string that winds the thermal circle and becomes massless there \cite{Sathiapalan,Kogan,AtickWitten}. Atick and Witten argued further that the interactions of this mode make the transition first order, and that the free energy above it is of genus zero, which is the analogue of order $N^2$. Susskind, and Horowitz and Polchinski, proposed that a highly excited string and a black hole are one object in two regimes, and that each turns into the other when the horizon is of string size \cite{SusskindSpeculations,HorowitzPolchinski}. For type II strings a later analysis of the self-gravitating string finds an obstruction to connecting it with the black hole as a classical solution \cite{CMW}. The three strands were joined by the AdS/CFT correspondence \cite{Maldacena,GKP,WittenHolography,MAGOO}. One sign of the connection had appeared earlier. The entropy of the black three-brane is $3/4$ of the entropy of free $\cN=4$ fields \cite{GKPeet}, and the first corrections at strong and at weak coupling move the two values towards each other \cite{GKT,FotopoulosTaylor}. The comparison was extended to the theory on a sphere in \cite{BCM}. Witten's identification of the Hawking--Page transition with deconfinement on $S^3$ \cite{WittenThermal} then raised the question of what the transition becomes at weak coupling. From the leading $\alpha'$ correction, Gao and Li and then Caldarelli and Klemm argued that it disappears below a critical coupling \cite{GaoLi,CaldarelliKlemm}, whereas Sundborg found a similar transition at zero coupling \cite{Sundborg}. \subsection{The same transition in the free theory} That Gauss's law alone produces a transition was found by Hallin and Persson for quarks in $1+1$ dimensions \cite{HallinPersson}, understood in general by Sundborg \cite{Sundborg} and developed in detail by Aharony, Marsano, Minwalla, Papadodimas and Van Raamsdonk \cite{AMMPV1}, whom we call AMMPV. Consider $\lambda=0$. The singlet states on $S^3$ are traces of products of the elementary fields and their derivatives. The number of single-trace states grows exponentially with energy, like the states of a string, and so the theory has a Hagedorn temperature \cite{Hagedorn}. On a sphere of unit radius it is \begin{equation} T_H^{(0)}=\frac{1}{\ln(7+4\sqrt3)}=0.37966\ldots \label{eq:TH0} \end{equation} Below $T_H^{(0)}$ the free energy is of order one. Above it the free energy is of order $N^2$. The Polyakov loop jumps from zero to a finite value. All of this occurs in a theory of free fields, and it resembles the transition at \eqref{eq:THP}. Sundborg had noted that the free transition resembles a Hawking--Page transition in a string theory of vanishing tension \cite{Sundborg}. AMMPV proposed that the free transition and the Hawking--Page transition could be the two ends of one line of transitions in the $(\lambda,T)$ plane. At weak coupling the line is a Hagedorn transition of a string of vanishing tension. At strong coupling it is the formation of a black hole. The free theory is, however, a degenerate starting point. At $\lambda=0$ the effective potential for the Polyakov loop is exactly flat at the transition, and the order parameter jumps because nothing opposes it. Any interaction, however weak, lifts the degeneracy. Which way it is lifted decides the character of the transition. \subsection{The question} Let $U$ be the holonomy of the gauge field around the thermal circle and $u_n=\tr\, U^n/N$ its moments. At large $N$ the partition function on $S^3\times S^1$ is an integral over the single unitary matrix $U$, weighted by an effective action $S_{\rm eff}[U]$ obtained by integrating out everything else. Near the transition only $u_1$ is light, and after the other moments have been integrated out the action takes the Landau form \begin{equation} \frac{S_{\rm eff}}{N^2}=m_1^2(T,\lambda)\,|u_1|^2+b(\lambda)\,|u_1|^4+\ldots \label{eq:landau-intro} \end{equation} The mass $m_1^2$ is positive at low temperature and vanishes at the Hagedorn temperature $T_H(\lambda)$. The quartic coefficient $b$ vanishes in the free theory and starts at order $\lambda^2$. AMMPV showed that its sign decides between the two phase diagrams of figure~\ref{fig:phase}. \begin{figure}[t] \centering \includegraphics[width=0.98\textwidth]{figs/phase.pdf} \caption{The two candidate phase diagrams of $\cN=4$ super Yang--Mills theory on $S^3$ at large $N$, after AMMPV \cite{AMMPV1}. Left, $b<0$: a single line of first-order transitions runs from the free theory to the Hawking--Page point, with the Hagedorn line $T_H(\lambda)$ above it as the limit of metastability of the confined phase. Right, $b>0$: at weak coupling there is a second-order transition at $T_H$ followed by a third-order transition, and the two lines must merge at some finite coupling to reach the single first-order transition of gravity. Both pictures are schematic. This paper shows that the left one is correct at small $\lambda$.} \label{fig:phase} \end{figure} If $b<0$, the potential \eqref{eq:landau-intro} develops a second minimum away from the origin before $m_1^2$ reaches zero. There is one first-order transition, slightly below $T_H$. The Hagedorn temperature survives as the temperature at which the confined phase, already metastable, becomes locally unstable. This is the pattern of the Hawking--Page transition. If $b>0$, the confined phase remains the only minimum until $m_1^2$ changes sign. Then $u_1$ grows continuously from zero. This is a second-order transition at $T_H$. At a slightly higher temperature the eigenvalue distribution of $U$ develops a gap, which is a third-order transition of the kind found by Gross and Witten and by Wadia \cite{GrossWitten,Wadia}. Classical gravity has no counterpart of either. If $b$ were positive, the phase diagram would in the simplest scenario reorganise at intermediate coupling, through a tricritical point \cite{AMMPV1}. The question is therefore the sign of $b$ in $\cN=4$ super Yang--Mills theory. This paper determines it. \subsection{Why it has been open} AMMPV posed the question in 2003 and announced the computation \cite{AMMPV1}. They noted that $b$ is fixed by a set of two-loop and three-loop vacuum diagrams on $S^3\times S^1$. In 2005 the same authors carried the computation out for pure Yang--Mills theory \cite{AMMPV2}. Fourteen three-loop diagrams, each a sum over spherical harmonics and all but one with a logarithmic divergence of its own, combine with their counterterms to $b=-5.7\times10^{-4}\lambda^2$ in their conventions. The transition of pure Yang--Mills theory on a small sphere is first order. The authors wrote that they planned to do $\cN=4$ next, and remarked that they had no independent way to verify their number. A later two-loop calculation by three of them tested the formalism and the regularisation against results on $\mathbb{R}^4$, though not the three-loop number itself \cite{AMV}. The $\cN=4$ computation did not appear. It is considerably larger. There are six scalars and four fermions as well as the gauge field, with Yukawa couplings and quartic scalar couplings, and in Coulomb gauge every one of them carries colour charge and feeds the instantaneous Coulomb interaction. The number of diagrams, species assignments and colour orderings is larger by more than a factor of ten. Other examples accumulated in the meantime. The plane-wave matrix model has a deconfinement transition of the same kind \cite{FSS,Semenoff,SVV}, and it has $b<0$ in perturbation theory \cite{HRSY}, although a lattice study at $N=8$ and $12$ finds that the transition appears to be continuous at the weakest couplings \cite{JhaJosephSchaich}. Gauge theory in $0+1$ dimensions on a circle with heavy adjoint scalars also has $b<0$ \cite{AMMPVW}. Pure Yang--Mills theory in $2+1$ dimensions on a small $S^2$, however, was reported to have $b>0$ \cite{PSV}. AMMPV had already stressed that there is no sign theorem \cite{AMMPV2}. In their pure-glue result the manifestly negative part of $b$ is hundreds of times smaller than the part that could have had either sign. The answer for $\cN=4$ could therefore not be anticipated. One further example lies within the $\cN=4$ theory itself. The theory has supersymmetric black holes in AdS$_5$, which preserve one sixteenth of the supersymmetry \cite{GutowskiReall1,GutowskiReall2,CCLP,KLR}. Their entropy is reproduced by a supersymmetric partition function with complex chemical potentials \cite{CCMM} and accounted for by the superconformal index \cite{CKKN,BeniniMilan}, which counts only protected states and does not depend on the coupling \cite{Romelsberger,KMMR}. In the supersymmetric ensemble these black holes compete with a gas of gravitons, and there is a Hawking--Page transition between the two. The phases of the index at large $N$ were studied in \cite{CKKN2,CaboBizetMurthy}. The index is again a matrix integral over the holonomy, but its effective action is complex. Because of destructive interference the mode $u_1$ does not condense at the point where it first becomes tachyonic. Deconfinement is delayed, and it is of first order, already at zero coupling. The deconfinement line found in this way agrees closely with the one found in gravity \cite{CGKT}. The protected sector thus has a first-order transition at every coupling. This does not settle the question for the thermal partition function. The generic states that dominate the canonical ensemble do not contribute to the index, and the mechanism is a different one. For the thermal partition function the effective action is real, and the order of the transition rests on the sign of $b$. The matrix model for the holonomy was developed in several other directions. Its behaviour close to the transition, where the corrections in $1/N$ become large, was analysed in \cite{Liu,AGLW}. It was used as an effective description of the black holes of AdS$_5$, including those with R-charge and the small black hole as it approaches the string scale \cite{AGLW,BasuWadia,ABMW}, and it was rewritten in terms of free fermions \cite{DuttaGopakumar}. Matter in the fundamental representation was included in \cite{Schnitzer}, related models were applied to deconfinement in QCD \cite{DLP}, and gauge theories on circles and tori were treated in \cite{AMMPVW,AMMW}. The two-loop partition function on $S^3$ was obtained for pure Yang--Mills theory in \cite{AMV} and with general adjoint matter in \cite{MusselYacoby}. The gauge-theory description of the unstable saddle, which is the small black hole, has been pursued in \cite{HKN,Yaffe2018,HanadaMaltz,Berenstein,HIW,HJPW}. Much more is known about the other coefficient in \eqref{eq:landau-intro}. The shift of $m_1^2$, and with it the Hagedorn temperature, was found at one loop by Spradlin and Volovich \cite{SpradlinVolovich}, \begin{equation} T_H=T_H^{(0)}\Big(1+\frac{\lambda}{8\pi^2}+\ldots\Big), \label{eq:SV-intro} \end{equation} by an argument that replaces thermal Feynman diagrams by the one-loop dilatation operator of the theory on $\mathbb{R}^4$ \cite{BeisertComplete}. Two loops were reached in the $su(2)$ sector \cite{GNS}. Further progress came from integrability. The Hagedorn temperature is a property of the planar spectrum, the planar spectrum of $\cN=4$ is integrable \cite{MinahanZarembo,BeisertStaudacher,IntReview}, and Harmark and Wilhelm obtained $T_H(\lambda)$ to two loops \cite{HW1}, to three loops and numerically at finite coupling \cite{HW2}, and to seven loops \cite{HW3}. None of this determines $b$, for a structural reason. The mass term $m_1^2|u_1|^2$ counts single-trace states, and it is governed by the planar dilatation operator. The quartic term $|u_1|^4$ is a product of four traces. It is governed by the parts of the dilatation operator that split and join traces, at two loops, on the full set of fields. As far as we know, those parts have been given only for two complex scalars \cite{BKS} and, as a conjecture, for the $su(1,1|2)$ sector \cite{Zwiebel}. They lie outside the reach of integrability. \subsection{Summary of the paper} We compute $b$ from first principles. The method is Hamiltonian, not diagrammatic, and it is organised so that almost every number is obtained in two independent ways. The one exception, the high-order tail of one series, is recorded in section~\ref{sec:independent}. \emph{The free theory} (section~\ref{sec:free}). We review how Gauss's law turns free fields on $S^3$ into a unitary matrix model, $S_{\rm eff}=N^2\sum_n (1-z_n(x))|u_n|^2/n$ with $x=e^{-1/T}$, and how the Hagedorn temperature \eqref{eq:TH0} arises as the point where the coefficient of $|u_1|^2$ vanishes. \emph{The Landau analysis} (section~\ref{sec:landau}). With a quartic term the matrix model can be solved near the transition. For $b<0$ the first-order transition is at $m_1^2=|b|/4$, where $u_1$ jumps from $0$ to $\half$. An unstable saddle exists for $0