\documentclass[11pt,reqno]{amsart} \usepackage[letterpaper,margin=1.25in]{geometry} \usepackage{amsmath,amssymb,amsthm} \usepackage{booktabs} \usepackage{xcolor} \usepackage[backref]{hyperref} \usepackage{aliascnt} \usepackage{cleveref} % One shared counter. Each environment has its own counter aliased to it, as with % \newtheorem{lemma}[theorem]{Lemma} TeX Live 2025 makes cleveref print "Theorem" for every lemma. \newtheorem{theorem}{Theorem}[section] \newcommand{\sharedtheorem}[2]{\newaliascnt{#1}{theorem}\newtheorem{#1}[#1]{#2}\aliascntresetthe{#1}} \sharedtheorem{lemma}{Lemma} \sharedtheorem{proposition}{Proposition} \sharedtheorem{corollary}{Corollary} \theoremstyle{definition} \sharedtheorem{remark}{Remark} \sharedtheorem{definition}{Definition} \numberwithin{equation}{section} \newcommand{\Q}{\mathbb{Q}} \newcommand{\Z}{\mathbb{Z}} \newcommand{\R}{\mathbb{R}} \newcommand{\C}{\mathbb{C}} \newcommand{\F}{\mathbb{F}} \newcommand{\PP}{\mathbb{P}} \newcommand{\Qbar}{\overline{\Q}} \newcommand{\OO}{\mathcal{O}} \newcommand{\HH}{\mathcal{H}} \newcommand{\Nor}{\mathcal{N}} \newcommand{\ff}{\mathfrak{f}} \newcommand{\fp}{\mathfrak{p}} \newcommand{\eps}{\varepsilon} \newcommand{\diamondop}[1]{\langle #1 \rangle} \def\torz#1{\mathbb Z /#1 \mathbb Z} \newcommand{\cm}{\mathrm{CM}} \newcommand{\ncm}{\mathrm{nCM}} \newcommand{\cyc}{\mathrm{cyc}} \DeclareMathOperator{\Gal}{Gal} \DeclareMathOperator{\GL}{GL} \DeclareMathOperator{\SL}{SL} \DeclareMathOperator{\PSL}{PSL} \DeclareMathOperator{\End}{End} \DeclareMathOperator{\Aut}{Aut} \DeclareMathOperator{\Hom}{Hom} \DeclareMathOperator{\Frob}{Frob} \DeclareMathOperator{\Pic}{Pic} \DeclareMathOperator{\gon}{gon} \DeclareMathOperator{\tr}{tr} \DeclareMathOperator{\mult}{mult} \DeclareMathOperator{\Stab}{Stab} % Open items for the author; remove before submission. \newcommand{\todo}[1]{{\color{red}[TODO: #1]}} % The revision of the code repository that the paper refers to. \newcommand{\reporev}{67347db775834f730e1a76d44ae727c994e5a5fc} \newcommand{\githubbare}[1]{\href{https://github.com/F-Najman/automorphisms_XDelta/blob/\reporev/code/#1}{\path{#1}}} % The revision of the Lean formalization that the paper refers to. \newcommand{\leanrev}{1f4c27ec11da475383f69e6f82e2837a0cb54fd0} \title[Automorphisms of $X_\Delta(N)$]{Automorphisms of the modular curves $X_\Delta(N)$} \author{Filip Najman} \address{University of Zagreb Faculty of Science, Department of Mathematics, Bijeni\v{c}ka Cesta 30, 10000 Zagreb, Croatia} \email{fnajman@math.hr} \keywords{modular curves, automorphism groups, intermediate modular curves} \subjclass[2020]{11G18, 11F11, 14H37} \thanks{The author was supported by the Croatian Science Foundation under the project no.\ IP-2022-10-5008, by the project ``Implementation of cutting-edge research and its application as part of the Scientific Center of Excellence for Quantum and Complex Systems, and Representations of Lie Algebras'', PK.1.1.10.0004, co-financed by the European Union through the European Regional Development Fund -- Competitiveness and Cohesion Programme 2021--2027, and by the European Union -- NextGenerationEU through the National Recovery and Resilience Plan 2021--2026, via an institutional grant of the University of Zagreb Faculty of Science, IK IA 1.1.3, Impact4Math.} \begin{document} \begin{abstract} We show that every automorphism of a modular curve $X_\Delta(N)$ of genus at least $2$, where $\Gamma_1(N)\subseteq \Gamma_\Delta(N)\subseteq \Gamma_0(N)$, is induced by the normalizer of $\Gamma_\Delta(N)$ in $\PSL_2(\R)$, except for five curves, namely $X_0(37)$, $X_0(63)$, $X_0(108)$, a curve of level $37$ found by Jeon, Kim and Schweizer, and a curve of level $63$ whose non-modular automorphisms had, to our knowledge, not been noticed before. In particular every automorphism of $X_1(N)$ normalizes the group of diamond operators, as claimed for square-free $N$ in an unpublished preprint of Momose. The proof combines a twisted Hecke relation, which comes from the Galois action on the Tate module of the Jacobian, with a uniform bound for the dimension of the CM part of the Jacobian and with computations for finitely many levels. \end{abstract} \maketitle \section{Introduction} Let $N$ be a positive integer. The modular curve $X_0(N)$ has a group of automorphisms coming from the action on the upper half-plane $\HH$ of the normalizer of $\Gamma_0(N)$ in $\PSL_2(\R)$. We will call such automorphisms \textit{modular}. Ogg \cite{Ogg77} proved that for square-free $N$ with $g(X_0(N))\geq 2$ all the automorphisms of $X_0(N)$ are modular, except for $N=37$. Kenku and Momose \cite[Theorem 2.17]{KM88} extended this to all $N$ with $g(X_0(N))\geq 2$, except for $N=37$ and possibly $N=63$. Elkies \cite{Elkies90} showed that $N=63$ is indeed an exception, as $\Aut(X_0(63))\simeq S_4\times \torz{2}$ contains the modular automorphisms as a subgroup of index $2$. Harrison \cite{Harrison} found an error in the argument of \cite{KM88} for $N=108$ and showed that the modular automorphisms of $X_0(108)$ also form a subgroup of index $2$ of $\Aut(X_0(108))$. Hence all the automorphisms of $X_0(N)$ are modular if $g(X_0(N))\geq 2$ and $N\notin\{37,63,108\}$. The automorphism groups of the quotients of $X_0(N)$ by groups of Atkin-Lehner involutions have recently been studied by Bars and Dalal \cite{BD25,BD26}. Let $\Delta$ be a subgroup of $(\Z/N\Z)^\times$ containing $-1$, and let $X_\Delta(N)$ be the modular curve attached to the group $\Gamma_\Delta(N)$ of matrices in $\Gamma_0(N)$ whose lower right entry reduces to an element of $\Delta$ modulo $N$. These curves are intermediate between $X_1(N)=X_{\{\pm1\}}(N)$ and $X_0(N)=X_{(\Z/N\Z)^\times}(N)$, and their modular automorphisms, defined in the same way, include the diamond operators. Ishii and Momose \cite{IshiiMomose91} determined the hyperelliptic curves $X_\Delta(N)$, except for the curve $X_{\{\pm1,\pm8\}}(21)$, which Jeon and Kim \cite[Theorem 2.3 and Remark 2.4]{JK07} showed to be hyperelliptic (see also \cite[Theorem 3.6]{JKS20} and \cite[Remark 3.16]{Bars13}). Jeon \cite[Theorem 3.1]{Jeon15} showed that all the automorphisms of the hyperelliptic curves $X_1(13)$, $X_1(16)$ and $X_1(18)$ are modular (see also \cite{IshiiMomose91}). In an unpublished preprint \cite{MomoseX1}, Momose claimed that for square-free $N$ all the automorphisms of $X_\Delta(N)$ are modular. Kamienny \cite[Theorem 1]{Kamienny03} showed that for primes $p>311$ the automorphism group of every curve $X_\Delta(p)$ of genus at least $2$ is generated by the diamond operators and the lifts of the Atkin-Lehner involution, so all the automorphisms of $X_\Delta(p)$ are modular (see also \cite[proof of Theorem 3.13]{DLM26}). Kim and Koo \cite{KimKoo00} and Lang \cite{Lang01} determined the normalizer of $\Gamma_1(N)$ in $\PSL_2(\R)$, and Zemel \cite[Corollary 2.6]{Zemel17} gave a criterion for an element of $\PSL_2(\R)$ to normalize $\Gamma_\Delta(N)$ for all $N$ and $\Delta$ (see also \cite{IJK17}). While determining the bielliptic curves $X_\Delta(N)$, Jeon, Kim and Schweizer \cite[Lemma 4.2 and Theorem 4.4]{JKS20} found a curve $X_\Delta(37)$ with non-modular automorphisms, contradicting the claim of \cite{MomoseX1}. Bars \cite[Theorem 3.13 and Remark 3.15]{Bars13} surveys these results and points out that Momose's work needs a revision. However, even for the curves $X_1(N)$ it was unknown whether all the automorphisms are modular for non-square-free $N$ other than $16$ and $18$, and for square-free $N\neq 13$ the only argument in the literature is the one of \cite{MomoseX1}, which contains errors (see \Cref{rem:momose}). In this paper we determine all the curves $X_\Delta(N)$ of genus at least $2$ that have non-modular automorphisms. Our main result is the following theorem. \begin{theorem}\label{main_theorem} Let $N$ be a positive integer and let $\Delta$ be a subgroup of $(\Z/N\Z)^\times$ containing $-1$ such that $g(X_\Delta(N))\geq 2$. Then every automorphism of $X_\Delta(N)$ (over $\Qbar$) is modular, except for the following $5$ curves: $$X_0(37),\quad X_0(63),\quad X_0(108),\quad X_{\Delta_{37}}(37),\quad X_{\Delta_{63}}(63).$$ Here $\Delta_{37}=\diamondop{\pm 8}$ is the subgroup of index $3$ of $(\Z/37\Z)^\times$, and $\Delta_{63}$ is the kernel of the even quadratic character of $(\Z/63\Z)^\times$ of conductor $21$. The curve $X_{\Delta_{63}}(63)$ has genus $9$ and $96$ automorphisms, of which $48$ are modular. \end{theorem} Combining \Cref{main_theorem} with the description of the normalizer of $\Gamma_1(N)$ from \cite{KimKoo00,Lang01}, we obtain the following corollary. We denote by $w_Q$, for $Q\parallel N$, the Atkin-Lehner operators on $X_1(N)$ (which are well defined up to diamond operators), and by $\omega(N)$ the number of prime divisors of $N$. \begin{corollary}\label{cor:X1} Let $N=13$ or $N\geq 16$ (these are the $N$ with $g(X_1(N))\geq 2$). Then $$\Aut(X_1(N)_{\Qbar})=\diamondop{\diamondop{d},\ w_Q : d\in (\Z/N\Z)^\times,\ Q\parallel N},$$ a group of order $2^{\omega(N)}\varphi(N)/2$. In particular every automorphism of $X_1(N)$ normalizes the group of diamond operators, and hence induces an automorphism of $X_0(N)$. \end{corollary} For square-free $N$, \Cref{main_theorem} is the statement claimed in \cite{MomoseX1}, corrected by the single exception found in \cite{JKS20}. \begin{corollary}\label{cor:sqfree} Let $N$ be square-free and suppose that $g(X_\Delta(N))\geq 2$. Then every automorphism of $X_\Delta(N)$ is modular, unless $N=37$ and $\Delta=(\Z/37\Z)^\times$ or $\Delta=\Delta_{37}$. \end{corollary} The curve $X_{\Delta_{63}}(63)$ is an étale double cover of $X_0(63)$ to which all the $48$ automorphisms of $X_0(63)$, including the non-modular ones found by Elkies, lift (see \Cref{sec:63}), just as all the automorphisms of $X_0(37)$ lift to $X_{\Delta_{37}}(37)$. To the best of our knowledge this has not been noticed before. By \Cref{main_theorem}, the non-modular automorphisms of $X_0(63)$ and $X_0(108)$ lift to no other curves $X_\Delta(63)$ and $X_\Delta(108)$ (see \Cref{rem:lift}). In \Cref{sec:order} we make Zemel's description of the normalizer of $\Gamma_\Delta(N)$ explicit and compute its index (\Cref{thm:normalizer}), which together with \Cref{main_theorem} gives $\#\Aut(X_\Delta(N)_{\Qbar})$ for every curve $X_\Delta(N)$ of genus at least $2$ (\Cref{cor:aut}). For example, if $4\nmid N$, $9\nmid N$ and, for every prime $p$ with $p^2\mid N$, some element of $\Delta$ is not $\pm1$ modulo $p$, then apart from the curves of \Cref{main_theorem}, $\#\Aut(X_\Delta(N)_{\Qbar})$ is $[(\Z/N\Z)^\times:\Delta]$ times the number of $Q\parallel N$ such that the Atkin-Lehner operator $w_Q$ normalizes $\Gamma_\Delta(N)$ (\Cref{cor:order}, see also \cite[Lemma 1.3]{JKS20}). In general the normalizer of $\Gamma_\Delta(N)$ need not be contained in the normalizer of $\Gamma_0(N)$, and in \Cref{table:order} we list the $28$ curves with $N\leq 200$ and $g(X_\Delta(N))\geq 2$ for which it is not. Our approach differs from the ones of \cite{Ogg77,KM88,MomoseX1}, which rely on the reduction of the modular curve modulo primes $p$ dividing $N$ and on the geometry of its special fiber, as described by Deligne and Rapoport. This works well for primes $p$ that divide $N$ exactly once, but the special fibers become much more complicated when $p^2\mid N$. We instead use only primes of good reduction and the arithmetic of the Jacobian $J_\Delta(N)$ of $X_\Delta(N)$, as Dose, Lido and Mercuri did for the modular curves attached to Cartan subgroups \cite{DLM22} and, more recently, for general modular curves \cite{DLM26}. Let $u$ be an automorphism of $X_\Delta(N)_{\Qbar}$. In \Cref{sec:tate} we study the action of $u$ on the Tate module of $J_\Delta(N)$ and show that on the part $J_\Delta(N)^\ncm$ of $J_\Delta(N)$ without complex multiplication (CM), $u$ satisfies the relations $$T_\ell\circ u=u^{\sigma_\ell}\circ T_\ell \quad\text{and}\quad \diamondop{d}\circ u\circ\diamondop{d}^{-1}=u^{\sigma_{d^2}},$$ where $T_\ell$ is the Hecke operator at a prime $\ell\nmid N$ and $\sigma_a$ is (any lift to $\Gal(\Qbar/\Q)$ of) the automorphism $\zeta_N\mapsto \zeta_N^a$ of $\Q(\zeta_N)$. If the CM part of $J_\Delta(N)$ has dimension less than $(g(X_\Delta(N))-1)/2$, then $u$ is defined over $\Q(\zeta_N)$, the second relation holds on all of $J_\Delta(N)$, and together with the Eichler-Shimura relation it gives the first one on all of $J_\Delta(N)$. In \Cref{sec:corr} we show that, under suitable conditions, this equality of endomorphisms is an equality of correspondences on $X_\Delta(N)$. We do this either by computing an intersection number on $X_\Delta(N)\times X_\Delta(N)$ or by using Abramovich's lower bound for the gonality of modular curves \cite{Abramovich96}. In \Cref{sec:elliptic} we use the equality of correspondences to show that $u$ maps cusps to cusps and elliptic points to elliptic points of the same order, by comparing the multiplicities of points in the divisors $T_\ell^n(P)$. It follows that $u$ lifts to an automorphism of $\HH$ normalizing $\Gamma_\Delta(N)$, i.e. that $u$ is modular. The main difficulty is the condition on the CM part of $J_\Delta(N)$. In \Cref{sec:cm} we count CM newforms using Hecke characters of imaginary quadratic fields, and obtain an upper bound for the dimension of the CM part of $S_2(N,\chi)$ that depends only on the local components of $\chi$. From it we obtain a uniform bound, which proves the condition for all $\Delta$ and all $N\geq 2$ outside an explicit finite set of $2\,370\,285$ integers. Evaluating the first bound at these integers leaves $58$ levels $N>200$, the largest being $6912$, which we deal with using the bound for each $\Delta$ separately and, where this is not enough, modular symbols. The proof of \Cref{main_theorem} for $N>200$ is completed in \Cref{sec:large}. Unfortunately, none of our criteria apply to $87$ of the $1449$ curves $X_\Delta(N)$ of genus at least $2$ with $N\leq 200$, as for small levels the CM part of the Jacobian can be too large and the gonality too small. For the $37$ curves $X_0(N)$ among them we use the results of \cite{Ogg77,KM88,Elkies90,Harrison}, and the remaining $50$ curves are treated in \Cref{sec:small,sec:63}, by computing the automorphism group of an explicit model, over $\Q$ or over a finite field, or by descent to a quotient curve whose automorphisms are known. For $N>200$ our argument does not use \cite{KM88,Harrison}, so it gives an independent proof of their results for $N>200$. Our methods are perhaps most similar to those of Dose, Lido and Mercuri \cite{DLM22}, who proved that for $n$ large enough all the automorphisms of the modular curves attached to Cartan subgroups of $\GL_2(\Z/n\Z)$, and to certain subgroups of their normalizers, are modular, by an argument with the same structure as ours. However, they assume that the group defining the modular curve contains the scalar matrices, which for $X_\Delta(N)$ is the case only if $\Delta=(\Z/N\Z)^\times$. Otherwise the diamond operators need not commute with $u$, and $u$ need not be defined over a compositum of quadratic fields (already the modular automorphisms of $X_1(N)$ are not). We deal with this using the twisted Hecke relation, which holds on $J_\Delta(N)^\ncm$ without any a priori control of the field of definition of $u$. While finishing this paper, we became aware of the recent preprint \cite{DLM26}, in which Dose, Lido and Mercuri extend the methods of \cite{DLM22} to the modular curves $X_H$ attached to all the subgroups $H$ of $\GL_2(\Z/n\Z)$ that contain $-1$ and have surjective determinant. They obtain independently an analogue of \Cref{prop:tate} b) \cite[Theorem 2.15]{DLM26}, and their criterion \cite[Theorem 3.12]{DLM26} is the analogue of \Cref{thm:criterion} with condition c) of \Cref{prop:corr}. With it they prove that all the automorphisms of the curves $X_H$ of prime level $p>311$ are modular \cite[Theorem 3.13]{DLM26}. For composite levels their results are computational: they compute the modular automorphisms of the curves $X_H$ of level at most $39$, and their criterion holds for $63.69\%$ of the curves $X_H$ of level at most $70$ and genus at least $2$, but for none of genus less than $10$ \cite[Section 5]{DLM26}. They conjecture that all the automorphisms of $X_H$ are modular if its genus is large enough \cite[Conjecture 1.1]{DLM26}. \Cref{main_theorem} proves this for the curves $X_\Delta(N)$, with the optimal bound $g(X_\Delta(N))\geq 11$, as $g(X_0(108))=10$. The main new ingredients compared to \cite{DLM22,DLM26} are the bound for the CM part of $S_2(N,\chi)$ for all $\chi$, which proves \eqref{CM} outside an explicit finite set of levels, and conditions a) and b) of \Cref{prop:corr}, which replace the gonality bound by an intersection number and hold for many curves of small level. Together with the computations for the remaining curves, this allows us to deal with all the curves $X_\Delta(N)$, and not only with those of large level. A disadvantage of our approach is its reliance on computations, both for the CM bound and for the curves of small level. All the code used in the paper, together with its logs, can be found at \begin{center} \url{https://github.com/F-Najman/automorphisms_XDelta} \end{center} This paper refers to its revision \href{https://github.com/F-Najman/automorphisms_XDelta/tree/\reporev}{\texttt{67347db}}, whose README lists the code and the logs of each computation. All of our computations were performed on the \textit{Mordell} server at the Department of Mathematics, University of Zagreb with an AMD EPYC 9175F CPU (16 cores, 32 threads) and 384 GB of RAM, using Magma V2.29-4 \cite{magma}, SageMath 10.7, Python 3.11 and gcc 15.2. \Cref{prop:normalizer}, \Cref{thm:normalizer}, the statements of \Cref{cor:order} about the normalizer of $\Gamma_\Delta(N)$ and its index, and the description of the normalizer of $\Gamma_1(N)$ from \cite{KimKoo00,Lang01} used in \Cref{cor:X1} have been formalized in Lean 4 with Mathlib, with all the definitions and statements fixed before the proofs were written. The formalization can be found at \begin{center} \url{https://github.com/F-Najman/normalizer-lean} \end{center} This paper refers to its revision \href{https://github.com/F-Najman/normalizer-lean/tree/\leanrev}{\texttt{1f4c27e}} (see \cite{NormalizerLean} and \Cref{sec:order}). \subsection*{AI disclosure and comments} Anthropic's Claude Opus 5.5 produced almost all of the mathematical content of the first versions of the proofs, carried out the computations, wrote the draft of the present manuscript, organized the code repository and wrote the corresponding Lean formalizations. %\section*{Acknowledgements} %\todo{acknowledgements.} \section{Conventions and notation}\label{sec:notation} Throughout the paper $N$ is a positive integer and $\Delta$ is a subgroup of $(\Z/N\Z)^\times$ containing $-1$. Let $$\Gamma_\Delta(N)=\left\{\begin{pmatrix} a&b\\ c&d\end{pmatrix}\in \Gamma_0(N) : d \bmod N\in \Delta\right\}.$$ Then $\pm\Gamma_1(N)\subseteq\Gamma_\Delta(N)\subseteq\Gamma_0(N)$. Let $X_\Delta(N)$ be the modular curve $\Gamma_\Delta(N)\backslash \HH^*$, where $\HH^*=\HH\cup\PP^1(\Q)$. The curve $X_\Delta(N)$ has a model over $\Q$ whose non-cuspidal points correspond to isomorphism classes of pairs $(E,s)$, where $E$ is an elliptic curve and $s$ is the $\Delta$-orbit of a point of order $N$ on $E$. We write $g_\Delta$ for the genus of $X_\Delta(N)$, $J_\Delta(N)$ for its Jacobian and $$i_\Delta=[(\Z/N\Z)^\times:\Delta]$$ for the degree of the natural map $X_\Delta(N)\rightarrow X_0(N)$. The group $(\Z/N\Z)^\times/\Delta$ acts on $X_\Delta(N)$ by the diamond operators $\diamondop{d}$, and $X_0(N)$ is the quotient of $X_\Delta(N)$ by this action. We denote by $\Delta^\perp$ the group of Dirichlet characters modulo $N$ which are trivial on $\Delta$. As $-1\in\Delta$, all these characters are even, and $$S_2(\Gamma_\Delta(N))=\bigoplus_{\chi\in\Delta^\perp} S_2(N,\chi), \qquad g_\Delta=\sum_{\chi\in\Delta^\perp}\dim S_2(N,\chi).$$ Let $\Nor(\Gamma_\Delta(N))$ be the normalizer in $\PSL_2(\R)$ of the image $\overline{\Gamma}_\Delta(N)$ of $\Gamma_\Delta(N)$ in $\PSL_2(\R)$. Every element of $\Nor(\Gamma_\Delta(N))$ induces an automorphism of $X_\Delta(N)_{\C}$, and we call the automorphisms obtained in this way \textit{modular}. They form a group isomorphic to $\Nor(\Gamma_\Delta(N))/\overline{\Gamma}_\Delta(N)$, which contains the diamond operators and those Atkin-Lehner operators $w_Q$, $Q\parallel N$, that normalize $\Gamma_\Delta(N)$ (not all of them do, see \cite[Lemma 1.3 and Example 1.5]{JKS20}). Note that $\Nor(\Gamma_\Delta(N))$ need not be contained in the normalizer of $\Gamma_0(N)$ (see \Cref{sec:order}). If $g_\Delta\geq 2$, all the automorphisms of $X_\Delta(N)_\C$ are defined over $\Qbar$, and we will identify $\Aut(X_\Delta(N)_{\Qbar})$ with $\Aut(X_\Delta(N)_\C)$. For a non-cuspidal point $P=(E,s)$ of $X_\Delta(N)$, let $\Aut(E,s)$ be the group of automorphisms $\alpha$ of $E$ such that $\alpha(s)=s$, and let $e(P)$ be the order of $\Aut(E,s)/\{\pm1\}$. Then $e(P)\in\{1,2,3\}$ is the order of the stabilizer in $\overline{\Gamma}_\Delta(N)$ of any point of $\HH$ above $P$, and $P$ is an \textit{elliptic point} if $e(P)>1$. Let $\ell\nmid N$ be a prime. For $m\geq 1$ we denote by $T^\cyc_{\ell^m}$ the correspondence on $X_\Delta(N)$ that sends a non-cuspidal point $(E,s)$ to the divisor $$T^\cyc_{\ell^m}(E,s)=\sum_{C}\left(E/C, s_C\right),$$ where $C$ runs over the cyclic subgroups of $E$ of order $\ell^m$ and $s_C$ is the image of $s$ in $E/C$. We write $T_\ell=T_\ell^\cyc$ and $T^\cyc_1=\mathrm{id}$. The correspondence $T_\ell$ induces the Hecke operator $T_\ell$ on $S_2(\Gamma_\Delta(N))$ and on $J_\Delta(N)$, which we denote by the same letter. Let $K=\Q(\zeta_N)$. For $a\in (\Z/N\Z)^\times$ let $\sigma_a\in\Gal(K/\Q)$ be the automorphism satisfying $\sigma_a(\zeta_N)=\zeta_N^a$, and by a \textit{lift} of $\sigma_a$ we mean an element of $\Gal(\Qbar/\Q)$ whose restriction to $K$ is $\sigma_a$. For $u\in \Aut(X_\Delta(N)_{\Qbar})$ and $\sigma\in \Gal(\Qbar/\Q)$ we write $u^\sigma=\sigma\circ u\circ\sigma^{-1}$. For a newform $f$ of weight $2$ we denote by $N_f$ its level, by $\chi_f$ its character and by $a_n(f)$ its coefficients. For a Dirichlet character $\psi$ we denote by $f\otimes\psi$ the newform whose $\ell$-th coefficient is $\psi(\ell)a_\ell(f)$ for all but finitely many primes $\ell$. We fix a prime $r$ and an isomorphism $\C\simeq\Qbar_r$, and denote by $\rho_f:\Gal(\Qbar/\Q)\rightarrow\GL_2(\Qbar_r)$ the $r$-adic Galois representation attached to $f$, normalized such that $\Frob_\ell$ has characteristic polynomial $X^2-a_\ell(f)X+\chi_f(\ell)\ell$ for the primes $\ell\nmid N_fr$. Then $\rho_{f\otimes\psi}\simeq\rho_f\otimes\psi$, where we view $\psi$ also as a character of $\Gal(\Qbar/\Q)$. For an imaginary quadratic field $F$ of discriminant $-D$ we denote by $\OO_F$ its ring of integers, by $h(-D)$ its class number and by $\eps_F$ its quadratic character, and for a prime $p$ we write $\OO_{F,p}=\OO_F\otimes\Z_p$. A newform $f$ \textit{has CM} if $f\otimes\eps_F=f$ for some imaginary quadratic field $F$. We denote by $J_\Delta(N)^\cm$ the abelian subvariety of $J_\Delta(N)$ corresponding to the CM newforms (and their old forms) in $S_2(\Gamma_\Delta(N))$, and by $J_\Delta(N)^\ncm$ the one corresponding to the remaining newforms. Then $J_\Delta(N)$ is isogenous to $J_\Delta(N)^\cm\times J_\Delta(N)^\ncm$, and there are no non-zero homomorphisms between the two factors. Let $g_\cm(\Delta)=\dim J_\Delta(N)^\cm$. We will often use the condition \begin{equation}\label{CM}\tag{CM} 2g_\cm(\Delta)e$. The central character $\chi_p$ of $\pi$ is the local component at $p$ of the character attached to $\chi_f$, so $a(\chi_p)\leq v_p(N_f)\leq e$. Hence $a(\chi_p\psi_p)=a(\psi_p)$, and as $a(\psi_p)+a(\chi_p\psi_p)=2a(\psi_p)>a(\pi)$, it follows from \cite[Lemma 1.4]{BLS20} that $a(\pi\otimes\psi_p)=\max\{a(\pi),2a(\psi_p)\}=2a(\psi_p)>e$, which is a contradiction. \end{proof} \begin{proposition}\label{prop:tate} Let $u$ be an automorphism of $X_\Delta(N)_{\Qbar}$, which we view also as an automorphism of $J_\Delta(N)_{\Qbar}$. Then on $J_\Delta(N)^\ncm$ the following relations hold: \begin{itemize} \item[a)] $u^\sigma=u$ for all $\sigma\in\Gal(\Qbar/K)$, \item[b)] $\diamondop{d}\circ u\circ \diamondop{d}^{-1}=u^{\sigma}$ for all $d\in(\Z/N\Z)^\times$ and every lift $\sigma$ of $\sigma_{d^2}$, \item[c)] $T_\ell\circ u=u^{\sigma}\circ T_\ell$ for every prime $\ell\nmid N$ and every lift $\sigma$ of $\sigma_\ell$. \end{itemize} \end{proposition} \begin{proof} Let $V=V_r(J_\Delta(N))\otimes_{\Q_r}\Qbar_r$. As a module over $\Gal(\Qbar/\Q)$ and the Hecke algebra, we have $$V\simeq \bigoplus_f \rho_f\otimes M_f,$$ where $f$ runs over the newforms of level dividing $N$ with character in $\Delta^\perp$, and $M_f$ is a vector space of dimension equal to the number of divisors of $N/N_f$, on which $T_\ell$ acts by $a_\ell(f)$ for $\ell\nmid N$ and $\diamondop{d}$ acts by $\chi_f(d)$ (see \cite[Theorem 6.6.6 and Section 9.5]{DS05}). For a non-CM newform $f$ let $\Psi_f$ be the set of Dirichlet characters $\psi$ such that $f\otimes\psi$ occurs in $V$, and put $$V_{[f]}=\bigoplus_{\psi\in\Psi_f}\rho_{f\otimes\psi}\otimes M_{f\otimes\psi}\simeq \rho_f\otimes M_{[f]},\qquad M_{[f]}=\bigoplus_{\psi\in\Psi_f} M_{f\otimes\psi}.$$ Since $\rho_{f\otimes\psi}\simeq\rho_f\otimes\psi$, an element $\sigma\in\Gal(\Qbar/\Q)$ acts on $V_{[f]}$ as $\rho_f(\sigma)\otimes A(\sigma)$, where $A(\sigma)$ acts on $M_{f\otimes\psi}$ as multiplication by $\psi(\sigma)$. By \Cref{lem:twist} b), every $\psi\in\Psi_f$ is trivial on $\Gal(\Qbar/K)$, so $A(\sigma)$ depends only on the restriction of $\sigma$ to $K$. As the nebentypus of $f\otimes\psi$ is $\chi_f\psi^2$, we have \begin{align*} T_\ell&=a_\ell(f)A(\sigma) \text{ for any lift } \sigma \text{ of } \sigma_\ell,\\ \diamondop{d}&=\chi_f(d)A(\sigma)^2 \text{ for any lift } \sigma \text{ of } \sigma_d \end{align*} on $V_{[f]}$. The subspace of $V$ corresponding to $J_\Delta(N)^\ncm$ is the direct sum of the spaces $V_{[f]}$, and for every number field $L\supseteq K$ which is Galois over $\Q$ these are the isotypic components of its restriction to $\Gal(\Qbar/L)$ by \Cref{lem:twist}. Let $L\supseteq K$ be a number field which is Galois over $\Q$ and such that $u$ is defined over $L$. Then $u$ commutes with $\Gal(\Qbar/L)$, so $u$ preserves each $V_{[f]}$ and acts on it as $1\otimes U$ for some $U\in\End(M_{[f]})$. It follows that $$u^\sigma=1\otimes A(\sigma)UA(\sigma)^{-1}$$ on $V_{[f]}$ for all $\sigma\in\Gal(\Qbar/\Q)$. Since $A(\sigma)$ is the identity for $\sigma\in\Gal(\Qbar/K)$, this proves a). Relations b) and c) follow directly from the displayed formulas for $\diamondop{d}$ and $T_\ell$. \end{proof} \begin{lemma}\label{lem:faithful} Let $X$ be a curve of genus $g\geq 2$ and let $v\neq 1$ be an automorphism of $X$. If $v$ acts trivially on an abelian subvariety $A$ of $\Pic^0(X)$, then $\dim A\leq (g+1)/2$. \end{lemma} \begin{proof} The abelian variety $A$ is contained in the image of $\Pic^0(X/\diamondop{v})$, so $\dim A\leq g(X/\diamondop{v})$. If $g(X/\diamondop{v})\geq 1$, the Riemann-Hurwitz formula gives $2g-2\geq 2(2g(X/\diamondop{v})-2)$, from which it follows that $g(X/\diamondop{v})\leq (g+1)/2$. \end{proof} \begin{corollary}\label{cor:field} Suppose that $X_\Delta(N)$ satisfies \eqref{CM}. Then every automorphism $u$ of $X_\Delta(N)_{\Qbar}$ is defined over $K$, and $$\diamondop{d}\circ u\circ\diamondop{d}^{-1}=u^{\sigma_{d^2}}\quad\text{for all } d\in(\Z/N\Z)^\times.$$ \end{corollary} \begin{proof} Condition \eqref{CM} is equivalent to $\dim J_\Delta(N)^\ncm>(g_\Delta+1)/2$. For $\sigma\in\Gal(\Qbar/K)$, the automorphism $u^\sigma u^{-1}$ acts trivially on $J_\Delta(N)^\ncm$ by \Cref{prop:tate} a), so it is trivial by \Cref{lem:faithful}. Hence $u$ is defined over $K$, and $u^\sigma$ depends only on the restriction of $\sigma$ to $K$. The second claim follows in the same way from \Cref{prop:tate} b). \end{proof} \begin{proposition}\label{prop:ES} Suppose that $X_\Delta(N)$ satisfies \eqref{CM}. Then for every automorphism $u$ of $X_\Delta(N)_{\Qbar}$ and every prime $\ell\nmid N$ we have $$T_\ell\circ u=u^{\sigma_\ell}\circ T_\ell \quad\text{in } \End(J_\Delta(N)_{\Qbar}).$$ \end{proposition} \begin{proof} Let $r'\neq\ell$ be a prime and let $V=V_{r'}(J_\Delta(N))$. Let $\sigma\in\Gal(\Qbar/\Q)$ be a Frobenius element at a prime above $\ell$. Then $\sigma$ restricts to $\sigma_\ell$ on $K$, and as $u$ is defined over $K$ by \Cref{cor:field}, we have $u^\sigma=u^{\sigma_\ell}$. Pullback along $X_1(N)\rightarrow X_\Delta(N)$ embeds $V$ into $V_{r'}(J_1(N))$, compatibly with the actions of $\Gal(\Qbar/\Q)$, $T_\ell$ and $\diamondop{\ell}$. By the Eichler-Shimura relation, in the form of \cite[Theorem 9.5.1 and its proof]{DS05}, we have $\sigma^2-T_\ell\sigma+\ell\diamondop{\ell}=0$ on $V_{r'}(J_1(N))$, so $$T_\ell=\sigma+\ell\diamondop{\ell}\sigma^{-1}\quad\text{on } V.$$ By \Cref{cor:field}, applied to $u^{\sigma^{-1}}$ with $d=\ell$, we have $\diamondop{\ell}u^{\sigma^{-1}}=u^{\sigma}\diamondop{\ell}$. As $\sigma u=u^\sigma\sigma$ and $\sigma^{-1}u=u^{\sigma^{-1}}\sigma^{-1}$ on $V$, it follows that $$T_\ell u=u^\sigma\sigma+\ell\diamondop{\ell}u^{\sigma^{-1}}\sigma^{-1}=u^\sigma\sigma+\ell u^\sigma\diamondop{\ell}\sigma^{-1}=u^\sigma T_\ell$$ on $V$. As $\End(J_\Delta(N)_{\Qbar})$ acts faithfully on $V$, the claim follows. \end{proof} For $X_0(N)$, \Cref{cor:field} and \Cref{prop:ES} are \cite[Lemmas 1.4 and 2.6]{KM88} (see also \cite[Lemma 4.1 and Proposition 2.2]{DLM22}). For all the curves $X_H$, analogues of \Cref{prop:tate} b) and \Cref{prop:ES} were obtained independently in \cite[Theorem 2.15 and Lemma 3.9]{DLM26}. For $\Delta=(\Z/N\Z)^\times$ the diamond operators are trivial, so $u$ is defined over the compositum of the quadratic fields whose discriminant divides $N$, and the second relation of \Cref{cor:field} is not needed. \section{From endomorphisms to correspondences}\label{sec:corr} Let $\ell\nmid N$ be a prime. We view $T_\ell$ as a divisor on $X_\Delta(N)\times X_\Delta(N)$, namely the image of the modular curve attached to $\Gamma_\Delta(N)\cap\Gamma_0(\ell)$ under the product of the two degeneracy maps. It is a positive multiple of an irreducible curve, and both its projections have degree $\ell+1$. We will say that an automorphism $u$ of $X_\Delta(N)_{\Qbar}$ satisfies the \textit{correspondence identity at $\ell$} if \begin{equation}\label{eq:corr} T_\ell(uP)=u^\sigma(T_\ell(P))\quad\text{for all } P\in X_\Delta(N)(\Qbar) \end{equation} and every lift $\sigma$ of $\sigma_\ell$. For a prime $\ell\nmid N$ let $S_\ell=\sum_f|a_\ell(f)|^2$, where $f$ runs over a basis of $S_2(\Gamma_\Delta(N))$ consisting of eigenforms for all the Hecke operators $T_n$ with $(n,N)=1$ (so old forms are counted with multiplicity), and let $S_\ell^\cm$ and $S_\ell^\ncm$ be the analogous sums over the eigenforms with and without CM. Since $\overline{a_\ell(f)}=\chi_f(\ell)^{-1}a_\ell(f)$, we have $S_\ell=\tr(\diamondop{\ell}^{-1}T_\ell^2\mid S_2(\Gamma_\Delta(N)))$. \begin{proposition}\label{prop:corr} Let $\ell\nmid N$ be a prime and suppose that one of the following holds: \begin{itemize} \item[a)] $X_\Delta(N)$ satisfies \eqref{CM} and $S_\ell>(\ell+1)^2$, \item[b)] $S_\ell^\ncm-S_\ell^\cm>(\ell+1)^2$, \item[c)] $X_\Delta(N)$ satisfies \eqref{CM} and $\gon_\C X_\Delta(N)>2(\ell+1)$. \end{itemize} Then every automorphism of $X_\Delta(N)_{\Qbar}$ satisfies the correspondence identity at $\ell$. \end{proposition} \begin{proof} Let $X=X_\Delta(N)$, let $u$ be an automorphism of $X_{\Qbar}$ and let $\sigma$ be a lift of $\sigma_\ell$. Put $$C_1=(u^{-1}\times 1)(T_\ell),\qquad C_2=(1\times u^\sigma)(T_\ell).$$ Then $C_1(P)=T_\ell(uP)$ and $C_2(P)=u^\sigma(T_\ell(P))$ for all points $P$ of $X$, so we need to show that $C_1=C_2$. For correspondences $C$ and $C'$ on $X$ we have $$C\cdot C'=d_1(C)d_2(C')+d_2(C)d_1(C')-\tr\left(\gamma_C\,\gamma_{C'}^\dagger\mid H^1(X)\right),$$ where $d_i$ is the degree of the $i$-th projection, $\gamma_C$ is the endomorphism of $H^1(X)$ induced by $C$ and $\dagger$ is the Rosati involution, which corresponds to transposing correspondences (this follows from \cite[Propositions 11.5.2 and 11.5.3 and Exercise 11.12 (14)]{BL04}, as $C\cdot C'$ is the intersection number of the diagonal with the composition of $C$ and the transpose of $C'$). The correspondences $C_1$ and $C_2$ induce the endomorphisms $T_\ell u$ and $u^\sigma T_\ell$ of $J_\Delta(N)$. Note that $u^\dagger=u^{-1}$ and $T_\ell^\dagger=\diamondop{\ell}^{-1}T_\ell$, so $\tr(T_\ell u(T_\ell u)^\dagger\mid H^1(X))=\tr(T_\ell T_\ell^\dagger\mid H^1(X))=2S_\ell$. Suppose first that a) holds. By \Cref{prop:ES}, $T_\ell u=u^\sigma T_\ell$, so $$C_1\cdot C_2=2(\ell+1)^2-2S_\ell<0.$$ As $C_1$ and $C_2$ are positive multiples of irreducible curves, they have a common component, and as their projections have the same degrees, it follows that $C_1=C_2$. Suppose now that b) holds. By \Cref{prop:tate} c), the endomorphisms $T_\ell u$ and $u^\sigma T_\ell$ agree on $J_\Delta(N)^\ncm$, where the trace above contributes $2S_\ell^\ncm$. On $J_\Delta(N)^\cm$ the Rosati involution is positive \cite[Section 21, Theorem 1]{Mumford}, so by the Cauchy-Schwarz inequality the contribution of $J_\Delta(N)^\cm$ to the trace has absolute value at most $2S_\ell^\cm$. Hence $$C_1\cdot C_2\leq 2(\ell+1)^2-2S_\ell^\ncm+2S_\ell^\cm<0,$$ and we conclude as in a). Suppose finally that c) holds. Then $T_\ell u=u^\sigma T_\ell$ by \Cref{prop:ES}, so the map $P\mapsto [C_1(P)-C_2(P)]$ from $X$ to $J_\Delta(N)$ is constant, and the effective divisors $C_1(P)+C_2(Q)$ and $C_2(P)+C_1(Q)$ of degree $2(\ell+1)$ are linearly equivalent for all $P,Q\in X$. Since $2(\ell+1)<\gon_\C X$, they are equal. For a given $P$ we may choose $Q$ such that $C_1(P)$ and $C_1(Q)$ have disjoint supports, as only finitely many $Q$ fail this. Then $C_1(P)\leq C_2(P)$, and as both divisors have degree $\ell+1$, it follows that $C_1(P)=C_2(P)$ (this is the argument of \cite[Proposition 2.2]{DLM22}, see also \cite[Theorem 3.12]{DLM26}). \end{proof} To apply c) we use the following result of Abramovich. \begin{theorem}[{\cite[Theorem 0.1]{Abramovich96}}]\label{thm:abramovich} Let $\Gamma\subseteq\PSL_2(\Z)$ be a congruence subgroup of index $D$. Then $\gon_\C X_\Gamma\geq \frac{7}{800}D$. \end{theorem} The constant comes from the Li-Yau inequality and the bound $\lambda_1\geq 21/100$ of Luo, Rudnick and Sarnak \cite{LRS95} for the smallest positive eigenvalue of the Laplacian (see \cite[Sections 1.5 and 1.6]{Abramovich96}). As $[\PSL_2(\Z):\overline{\Gamma}_\Delta(N)]=\psi(N)i_\Delta$, where $\psi(N)=N\prod_{p\mid N}(1+1/p)$, it follows that \begin{equation}\label{eq:gonality} \gon_\C X_\Delta(N)\geq \frac{7}{800}\,\psi(N)\,i_\Delta. \end{equation} \section{Cusps, elliptic points and modularity}\label{sec:elliptic} We now show that the correspondence identity forces an automorphism to preserve the cusps and the elliptic points. For $\ell\geq 5$ these are characterized by the multiplicities of the points in $T_\ell(P)$ \cite[Theorem 2.4]{DLM22}. We use the divisors $T_\ell^n(P)$ instead, which also works for $\ell=2$ and $\ell=3$ (these primes are also treated in \cite[Lemma 3.2]{DLM26}, with a different argument for the elliptic points). \begin{lemma}\label{lem:iterate} Let $\ell\nmid N$ be a prime, let $u$ be an automorphism of $X_\Delta(N)_{\Qbar}$ which satisfies the correspondence identity at $\ell$, and let $\sigma$ be a lift of $\sigma_\ell$. Then \begin{equation}\label{eq:iterate} T_\ell^n(uP)=u^{\sigma^n}\left(T_\ell^n(P)\right)\quad \text{for all } n\geq 1 \text{ and all } P\in X_\Delta(N)(\Qbar), \end{equation} as an equality of divisors. \end{lemma} \begin{proof} Since $T_\ell$ is defined over $\Q$, applying $\sigma^j$ to \eqref{eq:corr} gives $T_\ell\circ u^{\sigma^j}=u^{\sigma^{j+1}}\circ T_\ell$ for all $j\geq 0$, and the claim follows by induction on $n$. \end{proof} \begin{lemma}\label{lem:decomp} Let $\ell\nmid N$ be a prime and let $P$ be a non-cuspidal point of $X_\Delta(N)$. Then $$T_\ell^n(P)=\sum_{k=0}^{\lfloor n/2\rfloor}c_{n,k}\,T^\cyc_{\ell^{n-2k}}\left(\diamondop{\ell}^kP\right)$$ for some non-negative integers $c_{n,k}$ with $c_{n,0}=1$. \end{lemma} \begin{proof} Write $P=(E,s)$. The divisor $T_\ell^n(P)$ is the sum of the points $(E/K_n,s_{K_n})$ over all the chains $0=K_0\subset K_1\subset\cdots\subset K_n$ of subgroups of $E$ with $[K_i:K_{i-1}]=\ell$. A subgroup $K$ of $E$ of order $\ell^n$ is isomorphic to $\Z/\ell^{n-k}\Z\times\Z/\ell^k\Z$ for some $0\leq k\leq n/2$, and then $K$ contains $E[\ell^k]$. Since $E/E[\ell^k]\simeq E$ via multiplication by $\ell^k$, which maps $s$ to $\ell^ks$, we have $(E/K,s_K)\simeq(E/\ell^kK,(\ell^ks)_{\ell^kK})$, and $K\mapsto \ell^kK$ is a bijection from the subgroups of this type to the cyclic subgroups of $E$ of order $\ell^{n-2k}$. The number of chains ending in $K$ depends only on the isomorphism type of $K$, which proves the claim, with $c_{n,k}$ the number of chains of subgroups with successive quotients of order $\ell$ in $\Z/\ell^{n-k}\Z\times\Z/\ell^k\Z$. As a cyclic group has only one such chain, $c_{n,0}=1$. \end{proof} \begin{lemma}\label{lem:cusps} Let $\ell\nmid N$ be a prime and let $u$ be an automorphism of $X_\Delta(N)_{\Qbar}$ which satisfies the correspondence identity at $\ell$. Then $u$ maps cusps to cusps. \end{lemma} \begin{proof} Let $c$ be a cusp. The support of $T_\ell^n(c)$ consists of cusps, so by \Cref{lem:iterate} the support of $T_\ell^n(uc)$ is contained in the finite set $\bigcup_\tau u^\tau(\mathrm{cusps})$, where $\tau$ runs over $\Gal(\Qbar/\Q)$ (the automorphism $u$ has finitely many conjugates). If $uc=(E,s)$ were not a cusp, then by \Cref{lem:decomp} the support of $T_\ell^n(uc)$ would contain all the points $(E/C,s_C)$ with $C$ cyclic of order $\ell^n$, and as $n$ grows these have infinitely many different $j$-invariants, which is a contradiction. \end{proof} For elliptic points the support of $T_\ell^n(P)$ is not enough, as different cyclic subgroups often have isomorphic quotients when $\ell$ splits into principal primes in the CM field of $E$, so we compare multiplicities. For example, we compute that on $X(1)$ with $\ell=2$ the number of points in the support of $T_2^n(P)$ grows at the same rate for the non-elliptic point $j=-3375$ as for the elliptic point $j=1728$ (see \githubbare{recheck_lemmaE.py}). For a prime $\ell\nmid N$, a non-cuspidal point $P$ of $X_\Delta(N)$, $n\geq 1$ and $e\in\{2,3\}$ put $$\nu_e(P,n)=\#\left\{R : \mult_R\,T_\ell^n(P)\not\equiv 0 \pmod e\right\}.$$ We use the following facts about isogenies between elliptic curves with CM, see \cite{Kohel96} or \cite[Sections 2.7, 2.9 and 2.10, Lemma 6 and its proof, and Remark 8]{Sutherland13}. Let $\ell$ be a prime. For an elliptic curve $E$ with CM, let $d(E)$ be the $\ell$-adic valuation of the conductor of the order $\End(E)$, and call an $\ell$-isogeny $E\rightarrow E'$ \textit{descending} if $d(E')=d(E)+1$ and \textit{ascending} if $d(E')=d(E)-1$. Every $\ell$-isogeny changes $d$ by at most $1$, and the dual of a descending $\ell$-isogeny is ascending. At least $\ell-1$ of the $\ell+1$ isogenies of degree $\ell$ from $E$ are descending, and if $d(E)\geq 1$, exactly one is ascending and the remaining $\ell$ are descending. For an elliptic curve $E$ over $\Qbar$ and $n\geq 1$ we call a cyclic subgroup $C$ of $E$ of order $\ell^n$ \textit{descending} if $E$ does not have CM, or if $E$ has CM and all the $\ell$-isogenies in the sequence $E\rightarrow E/C[\ell]\rightarrow\cdots\rightarrow E/C$ are descending. \begin{lemma}\label{lem:descending} Let $\ell$ be a prime, let $E$ be an elliptic curve over $\Qbar$ and let $n\geq 1$. \begin{itemize} \item[a)] There are at least $(\ell-1)\ell^{n-1}$ descending cyclic subgroups of $E$ of order $\ell^n$. \item[b)] Let $C$ be a descending cyclic subgroup of $E$ of order $\ell^n$, and let $C'$ be a cyclic subgroup of $E$ of order $\ell^m$ with $m\leq n$ such that $E/C\simeq E/C'$. Then $m=n$ and $C'=\beta C$ for some $\beta\in\Aut(E)$. \item[c)] Let $C$ be a descending cyclic subgroup of $E$ of order $\ell^n$. Then $\Aut(E/C)=\{\pm1\}$, and $\beta C\neq C$ for all $\beta\in\Aut(E)\setminus\{\pm1\}$. \end{itemize} \end{lemma} \begin{proof} Suppose first that $E$ does not have CM. Then all the $(\ell+1)\ell^{n-1}$ cyclic subgroups of order $\ell^n$ are descending, and $\Aut(E)=\Aut(E/C)=\{\pm1\}$, which proves a) and c). In b), composing $E\rightarrow E/C\simeq E/C'$ with the dual of $E\rightarrow E/C'$ gives an endomorphism of $E$ of degree $\ell^{n+m}$, i.e. multiplication by $\pm\ell^{(n+m)/2}$, whose kernel contains the cyclic group $C$ of order $\ell^n$ only if $m=n$, and then $C'=C$. Suppose now that $E$ has CM. Let $1\leq i4$, and at most this number if $D\in\{3,4\}$. \end{lemma} \begin{proof} We view $\xi$ as a character of $\mathbb A_F^\times/F^\times$ whose restriction to $(F\otimes\R)^\times=\C^\times$ is $z\mapsto z^{-1}$. Its restriction to $\widehat\OO_F^\times=\prod_\fp \OO_{F,\fp}^\times$ is a product of local characters $\xi_\fp$, whose conductors give $\ff$. As $\xi$ is trivial on $F^\times$, we have $\prod_\fp\xi_\fp(u)=u$ for all $u\in\OO_F^\times$. Conversely, every character of $\widehat\OO_F^\times$ satisfying this condition extends to exactly $h(-D)$ characters $\xi$ of $\mathbb A_F^\times/F^\times$ with the given restriction to $\C^\times$, as $\mathbb A_F^\times/(F^\times\C^\times\widehat\OO_F^\times)$ is the class group of $F$. Evaluating $\xi$ on the principal idele generated by an integer $n$ coprime to $\ff$ shows that the condition $\xi((n))=n\omega(n)$ is equivalent to $\prod_{\fp\mid p}\xi_\fp|_{\Z_p^\times}=\omega_p^{-1}$ for all $p$. If $D>4$, then $\OO_F^\times=\{\pm1\}$ and the unit condition $\prod_\fp\xi_\fp(-1)=-1$ follows from $\prod_p\omega_p(-1)=\omega(-1)=-1$. This proves the claim for $D>4$, and for $D\in\{3,4\}$ we obtain an upper bound by dropping the conditions coming from the units of order $4$ and $6$. \end{proof} The local numbers $e_p(\ff_p,\omega_p)$ of \Cref{lem:count} are computed by inclusion-exclusion. Let $s_p$ be the conductor exponent of $\omega_p$, let $\mathfrak g$ be an ideal of $\OO_{F,p}$ and let $p^{v}\Z_p=\mathfrak g\cap\Z_p$. Denote by $U(\mathfrak g)$ the kernel of the reduction map $\OO_{F,p}^\times\rightarrow(\OO_{F,p}/\mathfrak g)^\times$ (so $U(\OO_{F,p})=\OO_{F,p}^\times$), and by $U(p^v)$ the kernel of $\Z_p^\times\rightarrow(\Z/p^v\Z)^\times$. Since $\Z_p^\times/U(p^v)$ injects into $\OO_{F,p}^\times/U(\mathfrak g)$, the number of characters of $\OO_{F,p}^\times$ that are trivial on $U(\mathfrak g)$ and restrict to $\omega_p^{-1}$ is $$r(\mathfrak g)=\frac{\#\left(\OO_{F,p}^\times/U(\mathfrak g)\right)}{\varphi(p^{v})}\ \text{ if } s_p\leq v, \qquad\text{and } 0 \text{ otherwise}.$$ Explicitly, if $p$ splits in $F$ and $\mathfrak g=\fp^x\overline\fp^{\,y}$, then $v=\max\{x,y\}$ and the numerator is $\varphi(p^x)\varphi(p^y)$, where $\varphi(1)=1$. If $p$ is inert and $\mathfrak g=p^x\OO_{F,p}$, then $v=x$ and the numerator is $p^{2x}-p^{2x-2}$ for $x\geq1$. If $p$ ramifies and $\mathfrak g=\fp^x$, then $v=\lceil x/2\rceil$ and the numerator is $p^x-p^{x-1}$ for $x\geq 1$. In both cases the numerator is $1$ for $x=0$. It follows that $$e_p(\ff_p,\omega_p)=\sum_{\mathfrak g}\mu(\ff_p\mathfrak g^{-1})\,r(\mathfrak g),$$ the sum running over the ideals $\mathfrak g\mid\ff_p$ with $\ff_p\mathfrak g^{-1}$ square-free. \begin{proposition}\label{prop:cm_count} Let $\chi$ be an even Dirichlet character modulo $N$. For a fundamental discriminant $-D$ with $D\mid N$ and a prime $p\mid N$, let $s_p(D,\chi)$ be the conductor exponent of the character $\chi_p\eps_{F,p}$ of $\Z_p^\times$, where $F=\Q(\sqrt{-D})$ and $\chi_p$ and $\eps_{F,p}$ are the $p$-components of $\chi$ and $\eps_F$, and put $$E_p(D,\chi)=\sum_{\ff_p} e_p(\ff_p)\left(v_p(N)-v_p(D)-n_p(\ff_p)+1\right),$$ where $n_p(\ff_p)=v_p(N(\ff_p))$, the sum runs over the ideals $\ff_p$ of $\OO_{F,p}$ with $v_p(D)+n_p(\ff_p)\leq v_p(N)$, and $e_p(\ff_p)$ is computed with $s_p=s_p(D,\chi)$. Then $$\dim S_2(N,\chi)^\cm\leq B(\chi):=\sum_{D} h(-D)\prod_{p\mid N}E_p(D,\chi),$$ where the sum runs over the fundamental discriminants $-D$ with $D\mid N$. For $D>4$ the contribution of the forms with CM by $\Q(\sqrt{-D})$ is equal to the corresponding term on the right. \end{proposition} \begin{proof} By \Cref{prop:hecke}, a CM newform $f_\xi$ of level $M\mid N$ contributes to $S_2(N,\chi)$ if and only if $\chi$ is induced by its nebentypus $\eps_F\omega$, i.e. $\omega_p=\chi_p\eps_{F,p}$ on $\Z_p^\times$ for all $p$, and in that case it contributes $\prod_{p}(v_p(N)-v_p(M)+1)$ dimensions. As $M=D\cdot N(\ff)$, the claim follows from \Cref{lem:count}. \end{proof} Note that $E_p(D,\chi)$ depends on $\chi$ only through $s_p(D,\chi)$, which is determined by the \textit{local type} of $\chi$ at $p$: for odd $p$ the conductor exponent of $\chi_p$, together with whether $\chi_p$ is the quadratic character if its conductor exponent is $1$, and for $p=2$ the pair $(u,k)$ such that $\chi_2=\chi_{-4}^u\psi$ with $\psi$ trivial on $-1$ of order $2^k$. It depends on $D$ only through $v_p(D)$, the splitting of $p$ in $F$ and $\eps_{F,p}$. This makes $B(\chi)$ easy to compute (see \githubbare{cmV.py} and \githubbare{cm_exact.c}). As a check of \Cref{prop:cm_count}, we compared $B(\chi)$ with the dimensions of the subspaces of $S_2(N,\chi)$ on which $T_q=0$ for the primes $q$ up to some bound that are inert in $F$, which contain the forms with CM by $F$, at all levels $N\leq 200$ and at $24$ levels between $216$ and $1728$, and found no contradiction (see \githubbare{recheck_V.m}). \subsection{A uniform bound} Let $M(N)$ be the maximum of $\dim S_2(N,\chi)^\cm$ over the even characters $\chi$ modulo $N$. \begin{lemma}\label{lem:PN} Suppose that $2M(N)4$ we have $h(-D)=\sqrt D L(1,\eps_F)/\pi$, and partial summation, using that the partial sums of $\eps_F$ are bounded by $D/2$, gives $|L(1,\eps_F)|\leq\sum_{n\leq D}1/n+1\leq \log D+2$. \end{proof} To obtain a bound which is uniform in $\chi$, we use a cruder count of the characters. Every ideal $\ff_p$ of $\OO_{F,p}$ can be written uniquely as $p^i\mathfrak g$, where $\mathfrak g$ is \textit{primitive}, i.e. not divisible by $p$, and one checks that $e_p(\ff_p)\leq r(\ff_p)=\rho(p^i)$ if $s_p\leq i+v_p(N(\mathfrak g))$, where $\rho(1)=1$ and $\rho(p^i)=p^i(1-\eps_F(p)/p)$ for $i\geq 1$. For a prime $p$ with $p^e\parallel N$, integers $\delta,s\geq 0$ and a splitting type $\tau$ of $p$ let $$L_p(e,\delta,\tau,s)=\sum_{\substack{\delta+2i+j\leq e\\ i+j\geq s}}\rho(p^i)\,a(p^j)\,(e-\delta-2i-j+1),$$ where $\rho$ is computed with $\eps_F(p)=1,-1,0$ according to $\tau$ and $a(p^j)$ is the number of primitive ideals of norm $p^j$ (an empty sum is $0$). Then $E_p(D,\chi)\leq L_p(e,v_p(D),\tau,s_p(D,\chi))$, where $\tau$ is the splitting type of $p$ in $F$. The exponent $s_p(D,\chi)$ depends only on the local type $t$ of $\chi$ at $p$ and on the character $\eps=\eps_{F,p}$, and we denote it by $s(t,\eps)$. The possible pairs $(\tau,\eps)$ for $\delta=v_p(D)$ are the following. For $\delta=0$, $\tau$ is split or inert and $\eps=1$. For odd $p$ and $\delta=1$, $\tau$ is ramified and $\eps$ is the quadratic character of $\Z_p^\times$. For $p=2$ and $\delta\in\{2,3\}$, $\tau$ is ramified, and $\eps=\chi_{-4}$ if $\delta=2$ and $\eps\in\{\chi_8,\chi_{-8}\}$ if $\delta=3$. Let $$\Lambda_p(e)=\max_t\sum_\delta p^{\delta/2}\max_{(\tau,\eps)} L_p(e,\delta,\tau,s(t,\eps)),$$ where $\delta$ runs over $\{0,1\}$ for odd $p$ and over $\{0,2,3\}$ for $p=2$, and $(\tau,\eps)$ over the pairs just described. Note that for $\delta=3$ both characters $\chi_{\pm8}$ are needed, as they can give different values of $s(t,\eps)$ (for example $\Q(\sqrt{-2})$ and $\Q(\sqrt{-6})$ for $\chi_2=\chi_8$). Since $h(-D)\leq \sqrt D(\log N+2)/\pi$ by \Cref{lem:classnumber}, $\sqrt D=\prod_p p^{v_p(D)/2}$, and each $D$ is determined by the valuations $v_p(D)$ for $p\mid N$, we obtain \begin{equation}\label{eq:MN} M(N)\leq\frac{\log N+2}{\pi}\prod_{p^e\parallel N}\Lambda_p(e). \end{equation} For an odd prime $p$ we have $\Lambda_p(1)=\max\{4,2+\sqrt p\}$ and $\Lambda_p(2)=p+5+3\sqrt p$. To see this, let $c\leq e$ be the conductor exponent of $\chi_p$ and let $\eps$ be the quadratic character of $\Z_p^\times$. Then $s(t,1)=c$, while $s(t,\eps)=0$ if $\chi_p=\eps$ and $s(t,\eps)=\max\{c,1\}$ otherwise. For $\delta=0$ the maximum over $\tau$ is attained when $p$ splits, and $L_p(1,0,\tau,c)=4,2$ for $c=0,1$ and $L_p(2,0,\tau,c)=p+8,p+5,2$ for $c=0,1,2$. For $\delta=1$ we have $L_p(1,1,\tau,s)=1,0$ for $s=0$ and $s\geq1$, and $L_p(2,1,\tau,s)=3,1,0$ for $s=0$, $s=1$ and $s\geq 2$. Hence the sum in the definition of $\Lambda_p(1)$ is $4$ if $\chi_p$ is trivial, $2+\sqrt p$ if $\chi_p=\eps$ and $2$ otherwise, and the sum in the definition of $\Lambda_p(2)$ is $p+8+\sqrt p$ if $\chi_p$ is trivial, $p+5+3\sqrt p$ if $\chi_p=\eps$, $p+5+\sqrt p$ if $c=1$ and $\chi_p\neq\eps$, and $2$ if $c=2$. As $2\sqrt p>3$, the claim follows. The function \texttt{Lam} in \githubbare{cmlocal.py} computes $\Lambda_p(e)$ for all $p$ and $e$. By \cite[Theorem 3.1.1]{DS05}, $g(X_0(N))-1=\frac{\psi(N)}{12}-\frac{\nu_2}{4}-\frac{\nu_3}{3}-\frac{\nu_\infty}{2}$, where $\nu_2,\nu_3\leq 2^{\omega(N)}$ \cite[Corollary 3.7.2]{DS05} are the numbers of elliptic points of order $2$ and $3$ and $\nu_\infty=\prod_{p^e\parallel N}\nu_\infty(p^e)$ is the number of cusps. Combining this with \eqref{eq:MN}, it follows that the assumption of \Cref{lem:PN} holds whenever $$G(N):=\frac{24}{\pi}(\log N+2)\prod_{p^e\parallel N}\frac{\Lambda_p(e)}{\psi(p^e)}+7\prod_{p^e\parallel N}\frac{2}{\psi(p^e)}+6\prod_{p^e\parallel N}\frac{\nu_\infty(p^e)}{\psi(p^e)}<1.$$ For a prime $p$ and $e\geq 1$ put $\kappa(p,e)=\Lambda_p(e)/\psi(p^e)$ and $\theta(p,e)=\kappa(p,e)(1+\frac{e\log p}{2})$. \begin{lemma}\label{lem:kappa} Let $e\geq 1$. For every odd prime $q$ we have $$\kappa(q,e)\leq U(q,e):=\frac{(e+1)^2+2e}{1-1/q}\,q^{-e/2},$$ and $\kappa(2,e)\leq 2((e+1)^2+4e)2^{-e/2}$. \end{lemma} \begin{proof} Let $q$ be an odd prime. We drop the condition $i+j\geq s$ in $L_q$, and use that $\rho(q^i)\leq q^i$ if $q$ splits or ramifies and $\rho(q^i)\leq q^i(1+1/q)$ if $q$ is inert. For $\delta=0$ and $q$ split, the sum over $j$ for fixed $i$ is $(e-2i+1)^2$, so the split term is at most $(e+1)^2q^{\lfloor e/2\rfloor}/(1-1/q)$. For $q$ inert only $j=0$ occurs, and the inert term is at most $(e+1)(1+1/q)q^{\lfloor e/2\rfloor}/(1-1/q)$, which is smaller. The ramified term (with its factor $\sqrt q$) is at most $2eq^{e/2}/(1-1/q)$. As $\Lambda_q(e)$ is at most the sum of the term for $\delta=0$ and the ramified term, and $\psi(q^e)\geq q^e$, it follows that $\kappa(q,e)\leq U(q,e)$. The bound for $\kappa(2,e)$ is proved in the same way. \end{proof} \begin{lemma}\label{lem:theta} For all primes $q\geq 11$ and all $e\geq 1$ we have $\theta(q,e)<1$ and $\theta(q,e)\leq \theta(q,1)$. \end{lemma} \begin{proof} As $\Lambda_q(1)=2+\sqrt q$, the function $\theta(q,1)=\frac{2+\sqrt q}{q+1}(1+\frac{\log q}{2})$ is decreasing for $q\geq 11$, and $\theta(11,1)=0.9742\ldots$. Hence it is enough to show that $\theta(q,e)\leq\theta(q,1)$ for $e\geq 2$. For $11\leq q<2000$ and $2\leq e\leq 25$ we compute the exact values of $\Lambda_q(e)$ (see \githubbare{review_dfs_bounds.sage}, where interval arithmetic is used), and the largest value of $\theta(q,e)/\theta(q,1)$ is $\theta(11,2)/\theta(11,1)=0.6856\ldots$. Suppose now that $q\geq 2000$ or $e\geq 26$. As $\frac{2+\sqrt q}{q+1}\geq q^{-1/2}$, $\frac{1}{1-1/q}\leq\frac{11}{10}$ and $1+\frac{e\log q}{2}\leq e(1+\frac{\log q}{2})$, it follows from \Cref{lem:kappa} that $$\frac{\theta(q,e)}{\theta(q,1)}\leq R(q,e):=\frac{11}{10}\,e\,(e^2+4e+1)\,q^{-(e-1)/2}.$$ The function $R(q,e)$ is decreasing in $q$, and it is decreasing in $e\geq 2$, as both fractions in $$\frac{R(q,e+1)}{R(q,e)}=\frac{e+1}{e}\cdot\frac{e^2+6e+6}{e^2+4e+1}\cdot q^{-1/2}$$ are decreasing in $e$, so this ratio is at most $\frac32\cdot\frac{22}{13}\cdot 11^{-1/2}<1$. Hence $\theta(q,e)/\theta(q,1)\leq\max\{R(2000,2),R(11,26)\}<0.64$. \end{proof} \begin{proposition}\label{prop:finite} The set $\mathcal S$ of integers $N\geq 2$ with $G(N)\geq 1$ is finite. It has $2\,370\,285$ elements, the largest being $266\,378\,112\,000$. \end{proposition} \begin{proof} As $\log N+2\leq 2\prod_{p^e\parallel N}(1+\frac{e\log p}{2})$, we have $$G(N)\leq \frac{48}{\pi}\prod_{p^e\parallel N}\theta(p,e)+7\prod_{p^e\parallel N}\frac{2}{\psi(p^e)}+6\prod_{p^e\parallel N}\frac{\nu_\infty(p^e)}{\psi(p^e)}.$$ By \Cref{lem:theta}, multiplying $N$ by a power of a prime $q\geq 11$ not dividing $N$ does not increase this upper bound for $G$. Note that $\theta(q,e)\leq \theta(q,1)$ is equivalent to $\kappa(q,e)(2+e\log q)\leq \kappa(q,1)(2+\log q)$, so for such $q$ the exponent $e=1$ gives the largest value of $G(Nq^e)$, and one checks directly that $G(Nq)$ is decreasing in $q\geq 11$. This reduces the determination of $\mathcal S$ to a finite depth-first search over the factorizations of $N$, with the primes in increasing order. The primes $2,3,5,7$ can increase the first term, but only by the factors $\sup_e\theta(p,e)$, which are less than $3.786$, $2.491$, $1.454$ and $1.146$, respectively. While some of these primes can still be added to $N$, we abandon a branch when the bound for $G$, with its first term multiplied by the factors of the primes that can still be added, is less than $1$. Once all the primes that can still be added are at least $11$, we abandon a branch when $G(Nq)<1$ for the smallest admissible next prime $q$. Exponents $e\geq 60$ can be excluded, as the worst case is $p=2$ and $e=60$, which gives, by \Cref{lem:kappa}, $$G(N)<\frac{48}{\pi}\cdot 16\cdot 2\left(61^2+240\right)2^{-30}(1+30\log 2)+7\cdot 2^{-59}+6\cdot 2^{-30}<0.04,$$ where $16$ bounds the product of the factors $\max\{1,\sup_e\theta(p,e)\}$ for $p\in\{2,3,5,7\}$. Similarly, prime powers $q^e>10^{40}$ with $q\geq 11$ and $e<60$ can be excluded, as $U(q,e)(1+\frac{e\log q}{2})\leq\frac{11}{10}\cdot 3718\cdot x^{-1/2}(1+\frac12\log x)$ with $x=q^e$, which gives $G(N)<5\cdot 10^{-13}$. We compute the resulting set, obtaining the stated numbers (see \githubbare{cm_general_dfs.py}). A second implementation of the search using interval arithmetic, which keeps $N$ whenever the upper end of the interval for $G(N)$ is at least $1$, gives the same set (see \githubbare{review_dfs_interval.sage}). \end{proof} \begin{proposition}\label{prop:exact} The assumption of \Cref{lem:PN} holds for all $N>200$ except for the $3$ square-free values $N\in\{213,285,429\}$ and the following $55$ values: \begin{align*} &207, 216, 225, 240, 243, 252, 256, 279, 288, 300, 320, 324, 336, 351,\\ &360, 363, 375, 378, 384, 392, 400, 432, 441, 480, 486, 504, 512, 540,\\ &567, 576, 600, 640, 648, 675, 720, 756, 768, 784, 800, 864, 900, 972,\\ &1024, 1080, 1152, 1296, 1440, 1536, 1728, 2304, 2592, 3072, 3456, 4608, 6912. \end{align*} \end{proposition} \begin{proof} By \Cref{prop:finite} we only need to consider $N\in\mathcal S$. For each such $N$ we compute the maximum of $B(\chi)$ from \Cref{prop:cm_count} over all the tuples of local types that are realized by even characters modulo $N$, using a branch and bound search, with exact class numbers for $D\leq 10^7$ and the bound of \Cref{lem:classnumber} for larger $D$. We find that $2\max B(\chi)200$}{N>200}}\label{sec:large} For some levels we check the conditions of \Cref{prop:corr} directly, as follows. For each Galois orbit of even characters $\chi$ modulo $N$ we compute $S_2(N,\chi)$ using modular symbols and the subspace $W_\chi\subseteq S_2(N,\chi)$ obtained as the sum, over the imaginary quadratic fields $F$ whose discriminant divides $N$, of the joint kernels of the Hecke operators $T_q$ for the primes $q\leq 60$ with $q\nmid N$ that are inert in $F$. The space $W_\chi$ is stable under the Hecke operators and contains the CM part of $S_2(N,\chi)$. We also compute the traces of $\diamondop{\ell}^{-1}T_\ell^2$ on $S_2(N,\chi)$ and on $W_\chi$ for the primes $\ell\leq 37$ with $\ell\nmid N$. These traces lie in $\Q(\chi)$ and need not be the same for all the characters of an orbit (for $N=25$, $\ell=2$ and $\chi$ of order $5$ they are $(3\pm\sqrt 5)/2$), so each orbit contributes the trace from $\Q(\chi)$ to $\Q$ of these numbers. Summing over the orbits in $\Delta^\perp$, this gives an upper bound for $g_\cm(\Delta)$, the exact value of $S_\ell$ and an upper bound for $S_\ell^\cm$, so we can check the conditions a), b) and c) of \Cref{prop:corr} for every $\Delta$ (using \eqref{eq:gonality} for c)). We call this computation the \textit{scan} of level $N$ (see \githubbare{xdelta.m}). \begin{proposition}\label{prop:scans} In each of the following cases, the scan shows that $X_\Delta(N)$ satisfies one of the conditions of \Cref{prop:corr}. \begin{itemize} \item[a)] $200500$ is not one of the levels in b), either $N$ is one of the levels of \Cref{prop:exact} or $7\psi(N)\leq 1600(\ell+1)$ for the smallest prime $\ell\nmid N$, and $\Delta=(\Z/N\Z)^\times$. There are $113$ such levels, the largest being $6912$. \end{itemize} \end{proposition} The largest of these computations is the case $N=6912$ and $\Delta=(\Z/6912\Z)^\times$ in c), where $g(X_0(6912))=1081$ and the upper bound for $g_\cm$ is $236$. At $N=4608$ the two subgroups $\Delta$ of index $2$ left over by \Cref{prop:perdelta} give curves of genus $1409$ with CM parts of dimension at most $392$ and $428$. \begin{lemma}\label{lem:gonality} Let $\ell$ be the smallest prime not dividing $N$. \begin{itemize} \item[a)] If $\ell\geq 13$, then $7\psi(N)>1600(\ell+1)$. \item[b)] If $N>500$, then $7\psi(N)>800(\ell+1)$, and $7\psi(N)>1600(\ell+1)$ unless $N\leq 840$. There are $105$ values $N>500$ with $7\psi(N)\leq 1600(\ell+1)$. \item[c)] If $200400(\ell+1)$. \end{itemize} \end{lemma} \begin{proof} If $\ell\geq 13$, then $N$ is divisible by $P_\ell=\prod_{p<\ell}p$, so $\psi(N)\geq\psi(P_\ell)$. For $\ell=13$ we have $7\psi(2310)=48384>1600\cdot 14$, and if $\ell'$ is the prime following $\ell$, then $\psi(P_{\ell'})/(\ell'+1)=\frac{(\ell+1)^2}{\ell'+1}\cdot \frac{\psi(P_\ell)}{\ell+1}$, where $(\ell+1)^2>\ell'+1$ by Bertrand's postulate. This proves a). If $\ell\leq 11$, then a failure of one of the inequalities in b) or c) implies $N\leq\psi(N)\leq 1600\cdot 12/7<2743$, and we check all $N<2743$ directly (see \githubbare{gon_general.py} and \githubbare{review_gonality.sage}). \end{proof} \begin{proof}[Proof of \Cref{main_theorem} for $N>200$] Let $N>200$ and let $\Delta$ be such that $g_\Delta\geq 2$. By \Cref{thm:criterion} it is enough to show that $X_\Delta(N)$ satisfies one of the conditions a), b) or c) of \Cref{prop:corr}. Suppose first that $i_\Delta=1$, i.e. $X_\Delta(N)=X_0(N)$. If $N\leq 500$ or $N$ is one of the levels of \Cref{prop:scans} b) or c), this follows from \Cref{prop:scans}. Otherwise $N>500$ is not one of the levels of \Cref{prop:scans} c), so by the definition of that list $N$ is not one of the levels of \Cref{prop:exact} and $7\psi(N)>1600(\ell+1)$. Hence $X_0(N)$ satisfies \eqref{CM} by \Cref{prop:exact} and \Cref{lem:PN}, and $\gon_\C X_0(N)>2(\ell+1)$ by \eqref{eq:gonality}, so condition c) holds. Suppose now that $i_\Delta\geq 2$. We first show that $X_\Delta(N)$ satisfies \eqref{CM}, or directly one of the conditions of \Cref{prop:corr}. If $N$ is not one of the $58$ levels of \Cref{prop:exact}, then \eqref{CM} holds by \Cref{lem:PN}. If $N\in\{213,285,429\}$, one of the conditions holds by \Cref{prop:scans} a). If $N$ is one of the $55$ levels of \Cref{prop:exact}, then \eqref{CM} holds by \Cref{prop:perdelta}, except for $63$ subgroups $\Delta$ with $i_\Delta\leq 4$. We check that each of these is covered by \Cref{prop:scans} a) or b), comparing the subgroups as sets of residues (see \githubbare{check_large.py}). It remains to prove the correspondence identity when \eqref{CM} holds. If $N>500$, then $\gon_\C X_\Delta(N)\geq \frac{7}{800}\psi(N)\cdot 2>2(\ell+1)$ by \eqref{eq:gonality} and \Cref{lem:gonality} b), so c) holds. If $200(g_\Delta+1)/2$, so it is trivial by \Cref{lem:faithful}. In both cases $H$ is normal, so $u$ induces an automorphism $\overline u$ of $Y$. Suppose that $\overline u$ is modular. Then $\overline u$ maps cusps to cusps and preserves the orders of elliptic points of $Y$, and hence $u$ maps cusps to cusps. For a non-cuspidal point $P$ of $X$ with image $\overline P$ in $Y$ we have $e(P)=e(\overline P)/\#\Stab_H(P)$, and $\#\Stab_H(uP)=\#\Stab_H(P)$ as $uHu^{-1}=H$. Hence $u$ preserves the orders of the elliptic points of $X$, and we conclude as in the proof of \Cref{thm:criterion} that $u$ is modular. \end{proof} We verify the conditions of \Cref{lem:descent} as follows. The number $a_p(f)^2/\chi_f(p)$ does not change if we replace $f$ by a twist, and it is replaced by its conjugate if we replace $f$ by a Galois conjugate. Hence, if the $\Q$-characteristic polynomials of $\diamondop{p}^{-1}T_p^2$ on $J^H$ and on $A$ are coprime for some prime $p\nmid N$, then by \cite{Ribet80} $J^H$ and $A$ have no common isogeny factor without CM. This does not exclude common CM factors, as two CM newforms with the same CM field always give isogenous factors over $\Qbar$, even if their Hecke eigenvalues at a prime split in the CM field are different. Hence, for each imaginary quadratic field $F$ whose discriminant divides $N$, we also compute an upper bound for the dimension of the part with CM by $F$ of $J^H$ and of $A$, as in \Cref{sec:large}. If no field $F$ occurs on both sides, condition a) holds. We compute that the $12$ curves in \Cref{table:small} marked with a letter satisfy the corresponding condition of \Cref{lem:descent} for the indicated $\Delta'$ (see \githubbare{recheck_c4.m}). For $N=128$ and $N=144$ both sides have CM by $\Q(i)$ and by $\Q(\sqrt{-3})$, respectively, and we use b). As the parts of $J^H$ and $A$ without CM have no common isogeny factor, $S$ is contained in the part with CM by this field, which gives $\dim S\leq 7$ and $\dim S\leq 8$, while $g_\Delta=17$ and $g_\Delta=25$, respectively. In all cases the automorphisms of $X_{\Delta'}(N)$ are modular, either by \cite{KM88} (when $X_{\Delta'}(N)=X_0(N)$) or by the scan (for $N=75$). \section{The exceptional curves}\label{sec:63} By \Cref{sec:large,sec:small}, all the automorphisms of the curves $X_\Delta(N)$ with $g_\Delta\geq 2$ are modular, except possibly for the curves in \Cref{main_theorem}. The curves $X_0(37)$, $X_0(63)$ and $X_0(108)$ have non-modular automorphisms by \cite{Ogg77,Elkies90,Harrison}, and $X_{\Delta_{37}}(37)$ by \cite[Theorem 4.4]{JKS20} (see also \Cref{sec:explicit}). It remains to deal with $X_{\Delta_{63}}(63)$. \begin{proposition}\label{prop:63} Let $X=X_{\Delta_{63}}(63)$ and $Y=X_0(63)$, and let $\delta$ be the non-trivial diamond operator on $X$. Then $X$ has genus $9$, the map $X\rightarrow Y$ is étale, $\delta$ is central in $\Aut(X_{\Qbar})$, and $\Aut(X_{\Qbar})/\diamondop{\delta}\simeq\Aut(Y_{\Qbar})\simeq S_4\times\torz{2}$. In particular $\#\Aut(X_{\Qbar})=96$, and exactly $48$ of these automorphisms are modular. \end{proposition} \begin{proof} We have $g(X)=9$ and $g(Y)=5$, so $X\rightarrow Y$ is étale by the Riemann-Hurwitz formula. We compute that $J_0(63)$ and the part $A$ of $J_\Delta(63)$ corresponding to the quadratic character of conductor $21$ satisfy condition a) of \Cref{lem:descent} (with $\Delta'=(\Z/63\Z)^\times$), so $\delta$ is central and $\Aut(X_{\Qbar})/\diamondop{\delta}$ embeds into $\Aut(Y_{\Qbar})$, which has order $48$ by \cite{Elkies90}. This gives $\#\Aut(X_{\Qbar})\leq 96$. For the lower bound, we need to show that every automorphism of $Y$ lifts to $X$. The cover $X\rightarrow Y$ corresponds to a non-zero element $\eta\in J_0(63)[2]$, and an automorphism $a$ of $Y_{\Qbar}$ lifts to $X_{\Qbar}$ if and only if $a^*\eta=\eta$. We compute the canonical models of $X$ and $Y$ over $\F_{127^2}$ and find that $\#\Aut(X_{\overline\F_{127}})=96$, that the reduction of $\delta$ is central in $\Aut(X_{\overline\F_{127}})$ and that $\#\Aut(Y_{\overline\F_{127}})=48$, where by the method of \Cref{sec:explicit} all the geometric automorphisms are defined over $\F_{127^2}$ (see \githubbare{review_xdelta63.m} and \githubbare{review_frobenius_fields.m}). It follows that every automorphism of $Y_{\overline\F_{127}}$ lifts to $X_{\overline\F_{127}}$, i.e. fixes the reduction $\overline\eta$ of $\eta$. The reduction map $\Aut(Y_{\Qbar})\rightarrow\Aut(Y_{\overline\F_{127}})$ is injective, hence bijective, and reduction is injective on $J_0(63)[2]$ and compatible with the action of automorphisms. Hence $a^*\eta=\eta$ for all $a\in\Aut(Y_{\Qbar})$, and every automorphism of $Y$ has exactly $2$ lifts to $X$. Finally, $48$ of the automorphisms of $X$ are modular, as we find $48$ distinct cosets of explicit matrices normalizing $\Gamma_{\Delta_{63}}(63)$ (see \githubbare{normalizer.m}). Conversely, a modular automorphism of $X$ descends to a modular, hence cusp-preserving, automorphism of $Y$, and exactly $24$ automorphisms of $Y$ preserve the set of cusps (see \githubbare{x063.m}). As each of them has $2$ lifts, there are at most $48$ modular automorphisms of $X$. \end{proof} \begin{remark}\label{rem:lift} If an automorphism $\overline u$ of $X_0(N)$ lifts to an automorphism $u$ of $X_\Delta(N)$, then $u$ normalizes the group of diamond operators, so if $u$ is modular, then so is $\overline u$ (as $\overline{\Gamma}_0(N)$ consists of the elements of $\Nor(\Gamma_\Delta(N))$ that induce diamond operators). Hence, by \Cref{main_theorem}, the non-modular automorphisms of $X_0(63)$ lift to no curve $X_\Delta(63)$ other than $X_{\Delta_{63}}(63)$, and those of $X_0(108)$ lift to no curve $X_\Delta(108)$ with $\Delta\neq(\Z/108\Z)^\times$. \end{remark} \begin{remark}\label{rem:momose} The argument of \cite{MomoseX1} for square-free $N$ contains the following errors, which we found by checking it against the computations of \Cref{sec:small}. In the treatment of $N=37$, it is claimed that the class of the divisor $(0_i)-(0_1)$ of two cusps on $X_{\Delta_{37}}(37)$ has order $7$ in $J_{\Delta_{37}}(37)(\Q)$. We compute, by reduction modulo $3,5,7,11$ and $13$, that it has order $21$, and the claimed contradiction disappears. This is consistent with the existence of the non-modular automorphisms of $X_{\Delta_{37}}(37)$ found in \cite{JKS20}. Furthermore, the group generated by the diamond operators and the Atkin-Lehner involutions $w_p$, $p\mid N$, which is used throughout \cite{MomoseX1}, is not a subgroup of $\Aut(X_\Delta(N))$ when some $w_p$ does not normalize $\Gamma_\Delta(N)$ (the same problem in \cite{IshiiMomose91} was pointed out in \cite[Remark 2.4]{JK07}). For square-free $N\leq 70$ this first happens for $N=65$ (see also \cite[Example 1.5]{JKS20}). \end{remark} \begin{proof}[Proof of \Cref{main_theorem}, \Cref{cor:X1} and \Cref{cor:sqfree}] \Cref{main_theorem} follows from \Cref{sec:large,sec:small} and \Cref{prop:63}. By \Cref{main_theorem}, every automorphism of $X_1(N)$ is modular, i.e. $\Aut(X_1(N)_{\Qbar})\simeq\Nor(\Gamma_1(N))/\overline{\Gamma}_1(N)$. For $\Delta=\{\pm1\}$ and $N\neq 4$ we have $h'_\Delta=1$ (see the paragraph after \Cref{thm:normalizer}), and $\iota_Q(\Delta)=\Delta$ for all $Q\parallel N$. Hence, by \Cref{thm:normalizer}, the normalizer of $\Gamma_1(N)$ in $\PSL_2(\R)$ is generated by $\Gamma_0(N)$ and the Atkin-Lehner matrices, as was proved in \cite{KimKoo00,Lang01}. This proves \Cref{cor:X1}, as $\Gamma_0(N)/\pm\Gamma_1(N)$ has order $\varphi(N)/2$ and the Atkin-Lehner matrices generate a group of order $2^{\omega(N)}$ modulo $\Gamma_0(N)$. \Cref{cor:sqfree} follows directly from \Cref{main_theorem}. \end{proof} \section{The order of the automorphism group}\label{sec:order} If $g_\Delta\geq 2$ and $X_\Delta(N)$ is not one of the five curves of \Cref{main_theorem}, then all the automorphisms of $X_\Delta(N)$ are modular by \Cref{main_theorem}, so $$\#\Aut(X_\Delta(N)_{\Qbar})=[\Nor(\Gamma_\Delta(N)):\overline{\Gamma}_\Delta(N)].$$ For $X_1(N)$ this index is given by \Cref{cor:X1}. The five curves of \Cref{main_theorem}, in the order in which they are listed there, have $4$, $48$, $216$, $12$ and $96$ automorphisms, of which $2$, $24$, $108$, $6$ and $48$ are modular. We now determine the index for every $\Delta$. Let $\eps_\Delta$ be the greatest common divisor of $N$ and of the integers $d^2-1$ with $d \bmod N\in\Delta$, and let $$h_\Delta=\prod_{p\mid N}p^{\min\{v_p(\eps_\Delta),\lfloor v_p(N)/2\rfloor\}},\qquad n_\Delta=\frac{N}{h_\Delta^2}.$$ Let $h(N)$ be the largest divisor of $24$ whose square divides $N$. Every unit modulo a divisor of $24$ squares to $1$, so $\gcd(N,24)$ divides $\eps_\Delta$, and hence $h(N)$ divides $h_\Delta$. One easily checks that $h_\Delta=h(N)$ unless one of the following holds: \begin{itemize} \item[i)] $p^2\mid N$ and $d\equiv\pm1 \pmod p$ for all $d\in\Delta$, for some prime $p\geq 5$, \item[ii)] $3^4\mid N$ and $d\equiv\pm1\pmod 9$ for all $d\in\Delta$, \item[iii)] $2^8\mid N$ and $d\equiv\pm1 \pmod 8$ for all $d\in\Delta$. \end{itemize} We first compute the $\Z$-span of $\Gamma_\Delta(N)$. We denote by $E_{ij}$ the matrix units in $M_2(\Z)$. \begin{lemma}\label{lem:span} Let $L\subseteq M_2(\Z)$ be the $\Z$-span of $\Gamma_\Delta(N)$. Then $$L=\Z+\Z E_{12}+N\Z E_{21}+\eps_\Delta\Z E_{22}.$$ Every $g\in\SL_2(\R)$ which normalizes $\Gamma_\Delta(N)$ is of the form $g=\lambda A$ with $\lambda\in\R^\times$ and $A\in M_2(\Z)$ primitive, and then $ALA^{-1}=L$. \end{lemma} \begin{proof} As $T=\begin{pmatrix}1&1\\0&1\end{pmatrix}$ and $U=\begin{pmatrix}1&0\\N&1\end{pmatrix}$ lie in $\Gamma_\Delta(N)$, the span $L$ contains $E_{12}=T-1$, $NE_{21}=U-1$, $NE_{11}=(T-1)(U-1)$ and $NE_{22}=N-NE_{11}$. For $\gamma=\begin{pmatrix}x&y\\Nz&t\end{pmatrix}\in\Gamma_\Delta(N)$ it also contains $\gamma-x-yE_{12}-zNE_{21}=(t-x)E_{22}$, where $t-x\equiv t^{-1}(t^2-1)\pmod N$. As $x\equiv t^{-1}\equiv t\pmod{\eps_\Delta}$ for all such $\gamma$, the first claim follows. Let $g\in\SL_2(\R)$ normalize $\Gamma_\Delta(N)$. Then $gLg^{-1}=L$, and the entries of $gE_{12}g^{-1}$, $g(NE_{21})g^{-1}$ and $g(NE_{11})g^{-1}$ show that $Nxy\in\Z$ for any two entries $x,y$ of $g$. Hence $g=\lambda A$ with $\lambda\in\R^\times$ and $A\in M_2(\Z)$ primitive, and $ALA^{-1}=gLg^{-1}=L$. \end{proof} Let $p$ be a prime. We use the tree of $\mathrm{PGL}_2(\Q_p)$ \cite[Chapter II, Section 1]{Serre80}, whose vertices are the classes $[\Lambda]$ of $\Z_p$-lattices $\Lambda\subset\Q_p^2$ up to multiplication by $\Q_p^\times$, and on which $\GL_2(\Q_p)$ acts by isometries. The vertices $e_s=[\Z_p\oplus p^s\Z_p]$, $s\in\Z$, form a line. Every vertex $x$ has a unique closest vertex $e_{F(x)}$ on this line, and we denote by $i(x)$ the distance between them. Then $d(x,e_s)=i(x)+|F(x)-s|$. A vertex $x$ with $i(x)=i\geq 1$ and $F(x)=F$ is the class of $g_x\Z_p^2$ for a matrix $g_x=\begin{pmatrix}p^{i-F}&u\\0&1\end{pmatrix}$ with $v_p(u)=-F$. \begin{lemma}\label{lem:tree} Let $p$ be a prime and let $0\leq j\leq\nu$ be integers. Put $k=\min\{j,\lfloor\nu/2\rfloor\}$ and $$L_p=\Z_p+\Z_pE_{12}+p^\nu\Z_pE_{21}+p^j\Z_pE_{22}.$$ Let $\mathcal X$ be the set of vertices $[\Lambda]$ with $L_p\Lambda\subseteq\Lambda$, and let $\mathcal C$ be the set of vertices $x$ such that all the vertices at distance at most $k$ from $x$ lie in $\mathcal X$. Then $\mathcal C=\{e_s:k\leq s\leq \nu-k\}$. \end{lemma} \begin{proof} Computing $g_x^{-1}Yg_x$ for $Y=E_{12}, p^\nu E_{21}, p^jE_{22}$ shows that $$\mathcal X=\{x : 0\leq F(x)\leq\nu \text{ and } i(x)\leq\min\{j,F(x),\nu-F(x)\}\}.$$ If $k\leq s\leq\nu-k$ and $d(y,e_s)\leq k$, then $i(y)+|F(y)-s|\leq k\leq j$, which implies $y\in \mathcal X$, so $e_s\in \mathcal C$. If $s\nu-k$, then $e_s$ is at distance at most $k$ from $e_{-1}\notin \mathcal X$ or from $e_{\nu+1}\notin \mathcal X$. If $x\in \mathcal X$ and $i(x)\geq 1$, let $m=\min\{j,F(x),\nu-F(x)\}$. Then $m\leq k$, and a vertex $y$ with $F(y)=F(x)$ and $i(y)=m+1$ on a ray from $e_{F(x)}$ through $x$ is not in $\mathcal X$ and satisfies $d(x,y)=m+1-i(x)\leq k$, so $x\notin\mathcal C$. \end{proof} \begin{proposition}\label{prop:normalizer} Every element of $\Nor(\Gamma_\Delta(N))$ is the image of a matrix $$\frac{1}{\sqrt e}\begin{pmatrix}ae&b/h_\Delta\\ Nc/h_\Delta&de\end{pmatrix}\quad \text{with } a,b,c,d\in\Z,\ e\parallel n_\Delta \text{ and } ade^2-bcn_\Delta=e.$$ \end{proposition} For $\Delta=(\Z/N\Z)^\times$ this is one half of Newman's description of the normalizer of $\Gamma_0(N)$ (see \cite{AS90}). For the groups generated by $\Gamma_0(N)$ and some Atkin-Lehner involutions, which contain $\Gamma_0(N)$, the normalizers were determined by Bars and Dalal \cite{BD26} when $4\nmid N$ and $9\nmid N$. \begin{proof} Let $g\in\SL_2(\R)$ normalize $\Gamma_\Delta(N)$, and let $L$ be the $\Z$-span of $\Gamma_\Delta(N)$. By \Cref{lem:span}, $g=\lambda A$ with $\lambda\in\R^\times$ and $A\in M_2(\Z)$ primitive such that $ALA^{-1}=L$. Fix a prime $p$ and put $\nu=v_p(N)$, $j=v_p(\eps_\Delta)$ and $k=\min\{j,\lfloor\nu/2\rfloor\}=v_p(h_\Delta)$. As $\eps_\Delta\mid N$, we have $j\leq\nu$, and $L\otimes\Z_p$ is the ring $L_p$ of \Cref{lem:tree}. Hence $AL_pA^{-1}=L_p$, so $A$ preserves the set $\mathcal X$ of \Cref{lem:tree}, and hence the set $\mathcal C$ and the set $\{e_k,e_{\nu-k}\}$ of the endpoints of $\mathcal C$. Let $D=\begin{pmatrix}h_\Delta&0\\0&1\end{pmatrix}$ and $B=DAD^{-1}$. As $D$ maps $e_s$ to $e_{s-k}$, the matrix $B$ preserves $\{e_0,e_{\nu-2k}\}$. If $B$ fixes $e_0$, then we may rescale $B$ to lie in $\GL_2(\Z_p)$, and as $B$ also fixes $e_{\nu-2k}$, its lower left entry is then divisible by $p^{\nu-2k}$. Otherwise $w^{-1}B$ fixes $e_0$ and $e_{\nu-2k}$, where $w=\begin{pmatrix}0&-1\\p^{\nu-2k}&0\end{pmatrix}$ interchanges these two vertices. Let $B_0$ be the primitive integral multiple of $B$ with positive determinant $e$. By the above, for every prime $p$ either $p\nmid e$ and $p^{v_p(n_\Delta)}$ divides the lower left entry of $B_0$, or $v_p(e)=v_p(n_\Delta)$ and $p^{v_p(n_\Delta)}$ divides the lower left entry and both diagonal entries of $B_0$. Hence $e\parallel n_\Delta$ and $B_0=\begin{pmatrix}ae&b\\n_\Delta c&de\end{pmatrix}$ with $ade^2-bcn_\Delta=e$, and $g=\pm e^{-1/2}D^{-1}B_0D$ is of the stated form. \end{proof} We will use the following conjugation formulas in the proofs of \Cref{cor:order} and \Cref{thm:normalizer}. \begin{lemma}\label{lem:conj} Let $h$ and $n$ be positive integers, let $Q\parallel n$, and let $W=\begin{pmatrix}QA&B\\nC&QE\end{pmatrix}$ be an integral matrix with $\det W=Q$. Let $x=\begin{pmatrix}a&h\beta\\hn\gamma&d\end{pmatrix}\in\SL_2(\Z)$ with $\beta,\gamma\in\Z$ and $a\equiv d\pmod h$, and let $y_{ij}$ be the entries of $y=WxW^{-1}$. Then \begin{align*} y_{12}&=AB(d-a)+h\left(QA^2\beta-\tfrac nQB^2\gamma\right),\\ y_{21}&=nCE(a-d)+hn\left(QE^2\gamma-\tfrac nQC^2\beta\right),\\ y_{22}&=d+\tfrac nQBC(d-a)+hn(AC\beta-BE\gamma). \end{align*} In particular $y\in\SL_2(\Z)$, $h\mid y_{12}$ and $hn\mid y_{21}$. For every prime $p$ we have $y_{22}\equiv d\pmod{p^{v_p(hn)}}$ if $p\nmid Q$, and $y_{22}\equiv a\pmod{p^{v_p(hn)}}$ if $p\mid Q$. \end{lemma} \begin{proof} The formulas follow from a direct computation, using $W^{-1}=Q^{-1}\begin{pmatrix}QE&-B\\-nC&QA\end{pmatrix}$ and $QAE-\frac nQBC=1$. They show that $y_{12}$, $y_{21}$ and $y_{22}$ are integers, and so is $y_{11}=a+d-y_{22}$. Let $p$ be a prime and $m=v_p(hn)$. If $p\nmid Q$, then $v_p(n/Q)=v_p(n)$, and as $h\mid d-a$, we obtain $y_{22}\equiv d\pmod{p^m}$. If $p\mid Q$, then $v_p(Q)=v_p(n)$, and as $\frac nQBC=QAE-1$, we obtain $y_{22}\equiv a+QAE(d-a)\equiv a\pmod{p^m}$. \end{proof} \begin{corollary}\label{cor:order} Suppose that $g_\Delta\geq 2$, that $X_\Delta(N)$ is not one of the curves of \Cref{main_theorem} and that $h_\Delta=h(N)$. Then $\Nor(\Gamma_\Delta(N))$ is contained in the normalizer of $\Gamma_0(N)$, and $$\#\Aut(X_\Delta(N)_{\Qbar})=i_\Delta\cdot s_\Delta,$$ where $s_\Delta$ is the number of elements of $\Nor(\Gamma_0(N))/\overline{\Gamma}_0(N)$ that normalize $\overline{\Gamma}_\Delta(N)$. If in addition $4\nmid N$ and $9\nmid N$, then $s_\Delta$ is the number of $Q\parallel N$ such that $\iota_Q(\Delta)=\Delta$, where $\iota_Q$ is the automorphism of $(\Z/N\Z)^\times$ such that $\iota_Q(d)\equiv d^{-1}\pmod Q$ and $\iota_Q(d)\equiv d\pmod {N/Q}$. \end{corollary} \begin{proof} Put $H=h_\Delta$ and $D=\begin{pmatrix}H&0\\0&1\end{pmatrix}$. By \Cref{prop:normalizer}, every element of $\Nor(\Gamma_\Delta(N))$ is the image of $\frac{1}{\sqrt e}D^{-1}WD$ for an integral matrix $W=\begin{pmatrix}eA&B\\n_\Delta C&eE\end{pmatrix}$ with $e\parallel n_\Delta$ and $\det W=e$. Let $\gamma=\begin{pmatrix}x&y\\Nz&t\end{pmatrix}\in\Gamma_0(N)$. As $H=h(N)$ divides $24$, we have $t^2\equiv 1\pmod H$, and as $xt\equiv 1\pmod N$, it follows that $x\equiv t\pmod H$. As $N=H^2n_\Delta$, we may apply \Cref{lem:conj} to $W$ and $D\gamma D^{-1}=\begin{pmatrix}x&Hy\\Hn_\Delta z&t\end{pmatrix}$, with $h=H$, $n=n_\Delta$ and $Q=e$. It shows that $WD\gamma D^{-1}W^{-1}$ lies in $\SL_2(\Z)$, and that its upper right entry is divisible by $H$ and its lower left entry by $N/H$. Hence $D^{-1}WD\gamma D^{-1}W^{-1}D\in\Gamma_0(N)$, so $\Nor(\Gamma_\Delta(N))$ is contained in $\Nor(\Gamma_0(N))$. As $\Gamma_\Delta(N)$ is a normal subgroup of $\Gamma_0(N)$ of index $i_\Delta$, the formula for $\#\Aut(X_\Delta(N)_{\Qbar})$ follows from \Cref{main_theorem}. If $4\nmid N$ and $9\nmid N$, then $H=h(N)=1$ and $n_\Delta=N$, so every element of $\Nor(\Gamma_\Delta(N))$ which is not in $\overline{\Gamma}_0(N)$ is the image of $\frac{1}{\sqrt Q}W$ for an integral matrix $W=\begin{pmatrix}QA&B\\NC&QE\end{pmatrix}$ with $Q\parallel N$, $Q>1$ and $\det W=Q$, and the matrices of this form with the same $Q$ lie in the same coset of $\overline{\Gamma}_0(N)$. For $\gamma$ as above, \Cref{lem:conj} with $h=1$ and $n=N$ shows that the lower right entry of $W\gamma W^{-1}$ is congruent to $x\equiv t^{-1}$ modulo $Q$ and to $t$ modulo $N/Q$, so $W\Gamma_\Delta(N)W^{-1}=\Gamma_{\iota_Q(\Delta)}(N)$ (see also \cite[Lemma 1.3]{JKS20}). This proves the last claim. \end{proof} For general $\Delta$ we need a refinement of $h_\Delta$. For a positive integer $h$ with $h^2\mid N$ let $U_h$ be the kernel of the reduction map $(\Z/N\Z)^\times\rightarrow(\Z/(N/h)\Z)^\times$. As $N/h$ is divisible by every prime divisor of $N$, the group $U_h$ has order $h$, and by the Chinese remainder theorem $U_{h_1}U_{h_2}=U_{\mathrm{lcm}(h_1,h_2)}$. Let $h'_\Delta$ be the largest positive integer $h$ such that $$h^2\mid N,\qquad d^2\equiv 1\pmod h \text{ for all } d\in\Delta\qquad\text{and}\qquad U_h\subseteq\Delta.$$ The set of such $h$ contains $1$ and is closed under taking least common multiples, so every such $h$ divides $h'_\Delta$. Note that $h'_\Delta$ divides $h_\Delta$, as $h'_\Delta\mid\eps_\Delta$ and $(h'_\Delta)^2\mid N$. Put $n'_\Delta=N/(h'_\Delta)^2$ and let $\overline\Delta$ be the image of $\Delta$ in $(\Z/(N/h'_\Delta)\Z)^\times$. For $Q\parallel n'_\Delta$ let $\iota_Q$ be the automorphism of $(\Z/(N/h'_\Delta)\Z)^\times$ such that $\iota_Q(d)\equiv d^{-1}\pmod{p^{v_p(N/h'_\Delta)}}$ for the primes $p\mid Q$ and $\iota_Q(d)\equiv d\pmod{p^{v_p(N/h'_\Delta)}}$ for the other primes $p$. If $h'_\Delta=1$, this is the automorphism $\iota_Q$ of \Cref{cor:order}. For a positive integer $n$ let $\Gamma_0(n)^+$ be the group generated by $\Gamma_0(n)$ and its Atkin-Lehner matrices. Zemel \cite[Corollary 2.6]{Zemel17} showed that $\Nor(\Gamma_\Delta(N))$ is contained in a group $\Gamma_0^{*,\sigma}(N)$, where $\sigma$ is the integer $h'_\Delta$ (his $\sigma_H$ for $H=\Delta$), and by \cite[Remark 1.10]{Zemel17} this group is $D'^{-1}\Gamma_0(n'_\Delta)^+D'$, with $D'$ as in the theorem below. He also described $\Nor(\Gamma_\Delta(N))$ as the set of elements of this group that satisfy a congruence condition. The following theorem makes this condition explicit and gives the index. For completeness we give a short proof, which uses \Cref{prop:normalizer} and \Cref{lem:conj}. \begin{theorem}\label{thm:normalizer} Let $D'=\begin{pmatrix}h'_\Delta&0\\0&1\end{pmatrix}$ and let $S_\Delta$ be the set of $Q\parallel n'_\Delta$ such that $\iota_Q(\overline\Delta)=\overline\Delta$. Then $\Nor(\Gamma_\Delta(N))$ is the image in $\PSL_2(\R)$ of the matrices $\frac{1}{\sqrt Q}D'^{-1}WD'$ with $$W=\begin{pmatrix}Qa&b\\n'_\Delta c&Qd\end{pmatrix},\quad a,b,c,d\in\Z,\ Q\in S_\Delta \text{ and } adQ^2-bcn'_\Delta=Q.$$ In particular $$[\Nor(\Gamma_\Delta(N)):\overline{\Gamma}_\Delta(N)]=i_\Delta\cdot\frac{\psi(N)}{\psi(n'_\Delta)}\cdot\#S_\Delta,$$ where $\psi(m)=m\prod_{p\mid m}(1+1/p)$ is the index of $\Gamma_0(m)$ in $\SL_2(\Z)$. \end{theorem} \begin{proof} Write $h=h'_\Delta$ and $n=n'_\Delta$, so $N=h^2n$, and let $\Gamma'=D'\Gamma_\Delta(N)D'^{-1}$. Then $\Gamma'$ consists of the matrices $$x=\begin{pmatrix}a&h\beta\\hn\gamma&d\end{pmatrix}\in\SL_2(\Z)\quad\text{with } d\bmod N\in\Delta.$$ For such $x$ we have $ad\equiv 1\pmod N$, and as $d^2\equiv1\pmod h$, it follows that $a\equiv d\pmod h$. Let $W=\begin{pmatrix}QA&B\\nC&QE\end{pmatrix}$ be an integral matrix with $Q\parallel n$ and $\det W=Q$, and let $y=WxW^{-1}$. By \Cref{lem:conj}, $y\in\SL_2(\Z)$, $h\mid y_{12}$ and $hn\mid y_{21}$, and as $hn=N/h$ and $a\equiv d^{-1}\pmod N$, we have $y_{22}\equiv\iota_Q(d)\pmod{N/h}$. As $U_h\subseteq\Delta$, a unit modulo $N$ lies in $\Delta$ if and only if its reduction modulo $N/h$ lies in $\overline\Delta$, so $y\in\Gamma'$ if and only if $\iota_Q(d)\in\overline\Delta$. When $x$ runs over $\Gamma'$, $d\bmod N$ runs over all of $\Delta$, and hence $W\Gamma'W^{-1}\subseteq\Gamma'$ if and only if $Q\in S_\Delta$. The same holds for $W^{-1}$, which is a multiple of a matrix of the same form with the same $Q$. This proves that the matrices of the theorem normalize $\Gamma_\Delta(N)$, and that $\frac{1}{\sqrt Q}D'^{-1}WD'$ does not normalize $\Gamma_\Delta(N)$ if $Q\notin S_\Delta$. Now let $g\in\Nor(\Gamma_\Delta(N))$, and put $H=h_\Delta$ and $D=\begin{pmatrix}H&0\\0&1\end{pmatrix}$. By \Cref{prop:normalizer}, $g$ is the image of $\frac{1}{\sqrt e}D^{-1}WD$ for an integral matrix $W=\begin{pmatrix}eA&B\\n_\Delta C&eE\end{pmatrix}$ with $e\parallel n_\Delta$ and $\det W=e$. The matrix $W$ normalizes $D\Gamma_\Delta(N)D^{-1}$, which contains $\begin{pmatrix}1&H\beta\\0&1\end{pmatrix}$ and $\begin{pmatrix}1&0\\(N/H)\gamma&1\end{pmatrix}$ for all $\beta,\gamma\in\Z$. The formula for $y_{22}$ in \Cref{lem:conj}, with $H$, $n_\Delta$ and $e$ in place of $h$, $n$ and $Q$, shows that $1+(N/H)AC\beta$ and $1-(N/H)BE\gamma$ lie in $\Delta$ for all $\beta,\gamma\in\Z$. As $N/H$ is divisible by every prime divisor of $N$, it follows that $U_{h_1}\subseteq\Delta$ for $h_1=H/\gcd(H,AC,BE)$. Since $H^2\mid N$ and $H\mid\eps_\Delta$, the integer $h_1$ satisfies the three conditions in the definition of $h'_\Delta$, so $h_1\mid h$, i.e. $t=H/h$ divides both $AC$ and $BE$. Let $p$ be a prime divisor of $t$ and $k=v_p(t)$. We use that $eAE-\frac{n_\Delta}{e}BC=1$, as $\det W=e$. If $p\nmid AE$, then $p^k$ divides $B$ and $C$, and hence $p\nmid e$. If $p\mid AE$, then $p\nmid BC$, so $p^k$ divides $A$ and $E$, and $p\mid e$ or $p\nmid n_\Delta$, as otherwise $p$ would divide both $AE$ and $\frac{n_\Delta}{e}$, and hence $1$. Let $t_2$ be the product of the $p^{v_p(t)}$ over the prime divisors $p$ of $t$ with $p\mid AE$, and put $Q'=t_2^2e$. As $n=t^2n_\Delta$, it follows that $Q'\parallel n$ and that $$W'=t_2\begin{pmatrix}t&0\\0&1\end{pmatrix}^{-1}W\begin{pmatrix}t&0\\0&1\end{pmatrix}=\begin{pmatrix}t_2eA&t_2B/t\\t_2tn_\Delta C&t_2eE\end{pmatrix}$$ is an integral matrix of determinant $Q'$, whose diagonal entries are divisible by $Q'$ and whose lower left entry is divisible by $n$. As $D=\begin{pmatrix}t&0\\0&1\end{pmatrix}D'$, the element $g$ is the image of $\frac{1}{\sqrt{Q'}}D'^{-1}W'D'$, and $Q'\in S_\Delta$ by the first part of the proof. This proves the first claim. The matrices $W$ of the theorem are primitive, as $Qad-\frac nQbc=1$, so $Q$ is determined by the image of $\frac{1}{\sqrt Q}W$ in $\PSL_2(\R)$. Such matrices exist for every $Q\parallel n$, as $\gcd(Q,n/Q)=1$, and a direct computation shows that $W_1W_2^{-1}\in\Gamma_0(n)$ if $W_1$ and $W_2$ have the same $Q$. Hence $\Nor(\Gamma_\Delta(N))$ contains $D'^{-1}\overline{\Gamma}_0(n)D'$ with index $\#S_\Delta$. The group $D'\Gamma_0(N)D'^{-1}$ consists of the matrices in $\SL_2(\Z)$ whose upper right entry is divisible by $h$ and whose lower left entry is divisible by $hn$, so it is contained in $\Gamma_0(n)$, and it has index $\psi(N)$ in $\SL_2(\Z)$, as conjugation by $D'$ preserves hyperbolic area. Hence $[D'^{-1}\Gamma_0(n)D':\Gamma_0(N)]=\psi(N)/\psi(n)$, and as $[\Gamma_0(N):\Gamma_\Delta(N)]=i_\Delta$, the formula for the index follows. \end{proof} For $\Delta=(\Z/N\Z)^\times$ we have $h'_\Delta=h(N)$ and $S_\Delta$ consists of all $Q\parallel n'_\Delta$, and \Cref{thm:normalizer} is Newman's description of the normalizer of $\Gamma_0(N)$ (see \cite{AS90}). For $\Delta=\{\pm1\}$ and $N\neq 4$ we have $h'_\Delta=1$, as $U_h$ has order $h$ and $U_2=\{1,1+N/2\}$ is contained in $\{\pm1\}$ only for $N=4$, and \Cref{thm:normalizer} is the description of the normalizer of $\Gamma_1(N)$ from \cite{KimKoo00,Lang01}. Zemel \cite[Theorems 3.1 and 3.8]{Zemel17} determined the normalizers explicitly when $\Delta$ is the kernel of the reduction map $(\Z/N\Z)^\times\rightarrow(\Z/N_0\Z)^\times$ for some $N_0\mid N$, and when $\Delta$ is the $m$-torsion subgroup of $(\Z/N\Z)^\times$. Note that $\Nor(\Gamma_\Delta(N))$ is contained in the normalizer of $\Gamma_0(N)$ if $h_\Delta=h(N)$ (\Cref{cor:order}), but not in general. \begin{corollary}\label{cor:aut} Suppose that $g_\Delta\geq 2$ and that $X_\Delta(N)$ is not one of the curves of \Cref{main_theorem}. Then $$\#\Aut(X_\Delta(N)_{\Qbar})=i_\Delta\cdot\frac{\psi(N)}{\psi(n'_\Delta)}\cdot\#S_\Delta.$$ \end{corollary} \begin{proof} This follows from \Cref{main_theorem} and \Cref{thm:normalizer}. \end{proof} We have formalized \Cref{prop:normalizer} and the claims of \Cref{cor:order} about $\Nor(\Gamma_\Delta(N))$ and its index in Lean 4 with Mathlib \cite{NormalizerLean}, as \texttt{newman\_\allowbreak{}delta}, \texttt{normG\_\allowbreak{}GammaDeltaR\_\allowbreak{}le\_\allowbreak{}Norm0}, \texttt{card\_\allowbreak{}BG\_\allowbreak{}GammaDeltaR} and \texttt{card\_\allowbreak{}BG\_\allowbreak{}GammaDeltaR\_\allowbreak{}of\_\allowbreak{}not\_\allowbreak{}dvd}, and \Cref{thm:normalizer} as \texttt{mem\_\allowbreak{}normG\_\allowbreak{}GammaDeltaR\_\allowbreak{}iff} and \texttt{card\_\allowbreak{}BG\_\allowbreak{}GammaDeltaR\_\allowbreak{}hStar}, where $h'_\Delta$ is \texttt{hStar}. The formalization also proves that $\Nor(\Gamma_\Delta(N))$ is contained in the normalizer of $\Gamma_0(N)$ if and only if $h'_\Delta$ divides $h(N)$ (\texttt{normG\_\allowbreak{}GammaDeltaR\_\allowbreak{}le\_\allowbreak{}Norm0\_\allowbreak{}iff}). The formalization also contains the claim that $h_\Delta=h(N)$ unless one of i), ii) and iii) holds (\texttt{hDelta\_\allowbreak{}eq\_\allowbreak{}hPart\_\allowbreak{}iff}), the description of the normalizer of $\Gamma_1(N)$ from \cite{KimKoo00,Lang01} together with the order $2^{\omega(N)}\varphi(N)/2$ of \Cref{cor:X1} (\texttt{normG\_\allowbreak{}pmGamma1R} and \texttt{card\_\allowbreak{}BG\_\allowbreak{}pmGamma1R}), and the index for $X(M)$ used in \Cref{rem:XM} (\texttt{card\_\allowbreak{}BG\_\allowbreak{}GammaDeltaR\_\allowbreak{}sq}). As a check of \Cref{thm:normalizer}, we also computed the index directly. The matrices of \Cref{prop:normalizer} form the group $M_\Delta=D^{-1}\Gamma_0(n_\Delta)^+D$, where $D=\begin{pmatrix}h_\Delta&0\\0&1\end{pmatrix}$. Every element of $M_\Delta$ is a multiple of a primitive integral matrix whose determinant divides $N$ (for the normalizer of any group $\Gamma_H$ of level $n$, the analogous statement with $n$ in place of $N$ is \cite[Proposition 4.3]{DLM26}), so every coset $\overline{\Gamma}_0(N)g$ in $\Nor(\Gamma_\Delta(N))$ contains a multiple of a matrix $\sigma H$, where $\sigma$ runs over a fixed set of representatives of $\Gamma_0(N)\backslash\SL_2(\Z)$ and $H$ over the matrices $\begin{pmatrix}a&b\\0&d\end{pmatrix}$ with $ad\mid N$, $0\leq b