%\iffalse
%<*internal>
\iffalse
%</internal>
%<*readme>
Orbifold Points on Prym-Teichmüller Curves in Genus Three -- PARI File

David Torres-Teigell and Jonathan Zachhuber


This PARI code computes the orbifold type (i.e. number and type of orbifold points, cusps and Euler characteristic) of Prym-Teichmüller curves in $\mathcal{M}_3$.

To extract the PARI file (and this README file) and build the documentation, run
     pdflatex ptmcorbitsg3.dtx
     bibtex ptmcorbitsg3
     pdflatex ptmcorbitsg3.dtx

%</readme>
%<*internal>
\fi
\begingroup
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\nopreamble\nopostamble
\generate{\file{\jobname.pari}{\from{\jobname.dtx}{pari}}}
%</install>
%<install>\endbatchfile
%<*internal>
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{install}}}
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
\generate{\file{\jobname.bib}{\from{\jobname.dtx}{bib}}}
\endgroup
%</internal>
%<*driver>
\documentclass{amsart}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[numbered]{hypdoc}
\usepackage[backend=bibtex,style=alphabetic]{biblatex}
\bibliography{\jobname}
\StopEventually{\printbibliography}
\AtBeginDocument{\MakeShortVerb{\|}}
\CodelineNumbered
\EnableCrossrefs
%\CodelineIndex
% doc package redefines \maketitle, in particular it handles \thanks differently
% http://tex.stackexchange.com/a/229328/3830
\makeatletter
\def\@setthanks{\vspace{-\baselineskip}\def\thanks##1{\@par##1\@addpunct.}\thankses}
\makeatother
\begin{document}
\title{Orbifold Points on Prym-Teichmüller Curves in Genus Three -- PARI File}

\author{David Torres-Teigell}
\thanks{The first-named author was supported by the Alexander von Humboldt Foundation.}
\address{FB 12 -- Institut für Mathematik\\Johann Wolfgang Goethe-Universität\\Robert-Mayer-Str. 6--8\\D-60325 Frankfurt am Main}
\curraddr{Departamento de Matem\'{a}ticas, Universidad Aut\'{o}noma de Madrid\\28049 Madrid, Spain}
\email{david.torres@uam.es}

\author{Jonathan Zachhuber}
\thanks{The second-named author was partially supported by ERC-StG 257137.}
\address{FB 12 -- Institut für Mathematik\\Johann Wolfgang Goethe-Universität\\Robert-Mayer-Str. 6--8\\D-60325 Frankfurt am Main}
\email{zachhuber@math.uni-frankfurt.de}

\begin{abstract}
The following PARI code computes the orbifold type (i.e. number and type of orbifold points, cusps and Euler characteristic) of Prym-Teichmüller curves in $\mathcal{M}_3$.
\end{abstract}

\maketitle

\tableofcontents

\section{Introduction}

The following PARI code calculates the number and type of orbifold points on Prym-Teichmüller curves $W_D$ in $\mathcal{M}_3$, see \cite{TTZ} for details. By implementing the algorithm of Lanneau-Nguyen \cite{lanneaunguyen} for the number of cusps and using Möller's formula for the Euler characteristic \cite{moellerprym} (see e.g. \cite{bainbridgeeulerchar} for details how to compute this), we can give the complete orbifold classification for all $D$.

As neither of the authors can honestly call himself a programmer, we hold no claims for efficiency or ``clean'' programming. Moreover, we are grateful for any comments or feedback.

While there can be no doubt that the efficiency can be improved, the programme runs in a reasonable time for $D$ up to around $10000$. 

The code should work with \cite{PARI2} and (hopefully) all newer versions.

\section{Usage}

To extract the PARI file (and this |pdf| file), run\\
|    pdflatex |\texttt{\jobname.dtx}\\
|    bibtex |\texttt{\jobname}\\
|    pdflatex |\texttt{\jobname.dtx}\\
and then in PARI, e.g.
\begin{verbatim}
? \r ptmcorbiptsg3.pari 
? printsignature(50)
D      D(8) Chi    cusps g   p2  p3  p4  p6
8      0    -5/12  1     0   0   1   1   0
12     4    -5/6   2     0   0   0   0   1
17     1    -5/3   3     0   0   1   0   0
20     4    -5/2   4     0   1   0   0   0
24     0    -5/2   4     0   1   0   0   0
28     4    -10/3  4     0   0   2   0   0
32     0    -5     7     0   0   0   0   0
33     1    -5     7     0   0   0   0   0
40     0    -35/6  6     0   1   2   0   0
41     1    -20/3  8     0   0   1   0   0
44     4    -35/6  6     0   1   2   0   0
48     0    -10    10    1   0   0   0   0
? ##
  ***   last result computed in 5 ms.
\end{verbatim}
  
The default value for |printsignature| is $100$.

To obtain the signature for a single $D$:
\begin{verbatim}
? getsignature(10540)
%30 = [-25110, 368, 12361, 12, 24, 0, 0]
? ##
  ***   last result computed in 57 ms.
\end{verbatim}

\section{Implementation}

\DocInput{\jobname.dtx}
\end{document}
%</driver>
%\fi
%\iffalse
%<*pari>
%\fi
% We assume always that $D$ is a (non-square!) quadratic discriminant, i.e. $0$ or $1$ mod $4$.
%
%\subsection{Cusps}
%
% We begin by computing the number of cusps, $C(W_D)$ of $W_D$. By \cite[Thm C.1]{lanneaunguyen}, we have
%\[C(W_D)=2\lvert\mathcal{Q}_D\rvert+\lvert\mathcal{P}'_D\rvert,\]
% where $\mathcal{Q}_D$ and $\mathcal{P}'_D$ are sets of prototypes. More precisely, we have
%\newlength{\qwidth}\settowidth{\qwidth}{$\gcd(w,h,t,e)=1, D=e^2+8wh,$ }
%\[\mathcal{Q}_D=\left\{(w,h,t,e,\varepsilon)\in\mathbb{Z}^5:\ \begin{minipage}{\qwidth}$w>0$, $h>0$, $0\leq t<\gcd(w,h)$,\\$\gcd(w,h,t,e)=1$, $D=e^2+8wh$,\\$e+2h<w$, and $\varepsilon=\pm 1$.\end{minipage}\right\},\]
% while $\mathcal{P}'_D$ is given by
%\[\mathcal{P}'_D=\left\{(w,h,t,e)\in\mathbb{Z}^4:\ \begin{minipage}{\qwidth}$w>0$, $h>0$, $0\leq t<\gcd(w,h)$,\\$\gcd(w,h,t,e)=1, D=e^2+8wh,$\\$0<\tfrac{e+\sqrt{D}}{4}<w<\tfrac{e+\sqrt{D}}{2}$.\end{minipage}\right\}.\]
% To enumerate these prototypes, we loop over the possible values of $e$, setting $r=8wh$. Then we loop over the possible values for $h$ and finally over $t$. Note that the choice of $\varepsilon$ leads to each $\mathcal{Q}$-prototype being counted twice.
%    \begin{macrocode}
cusps(D) = { \\ count cusps of W_D(4) (LN)
  local(h,r,P,Q);
  P=0; Q=0;
  for (e=0,sqrt(D),
    r=D-e^2;
    if( r%8 != 0, next());
    fordiv(r/8,w,
      h=r/(8*w);
      for(t=0,gcd(w,h)-1,
        if(gcd(w,gcd(h,gcd(t,e)))!=1, next());
        if(e+2*h<w, Q+=2);
        if(e!=0 && -e+2*h<w, Q+=2);
        if((e+sqrt(D))/4<w && w<(e+sqrt(D))/2, P++);
        if(e!=0 && (-e+sqrt(D))/4<w && w<(-e+sqrt(D))/2, P++);
      );
    );
  );
  return(P+Q);
}
%    \end{macrocode}
%\subsection{Euler characteristic}
%
% By \cite[Thm 4.3]{moellerprym}, for $D\equiv 5\mod 8$, the locus $W_D$ is empty and for $D\equiv 0,4\mod 8$, we have
%\[\chi(W_D)=-\frac{5}{2}\chi(X_{D,(1,2)}),\]
%where $X_{D,(1,2)}$ is the Hilbert modular surface parametrising abelian twofolds with a $(1,2)$-polarisation admitting proper real multiplication by the order $\mathcal{O}_D$. In the case $D\equiv 1\mod8$, there are two components to $W_D$, but for each component the same formula holds as above.
%    \begin{macrocode}
geteulercharWP(D) = { \\ calculate chi(W_D(4) (genus 3)
  return(-5/2*geteulercharXP(D));
}
%    \end{macrocode}
% By \cite[Prop 1.2]{moellerprym}, if we write $D=f^2D_0$, where $D_0$ is a fundamental discriminant and $f$ is the conductor of $D$, we have the relationship
%\[\frac{\chi(X_{D,(1,2)})}{\chi(X_D)}=\begin{cases}1&\text{if }2 \not\:\mid f\text{, and}\\3/2&\text{if }2 \mid f.\end{cases}\]
% This leads to
%    \begin{macrocode}
geteulercharXP(D) = { \\ calculate chi(X_D,(1,2))
  local(DD,f,z);
  if (D%8==5, return(0));
  z=coredisc(D,1);
  DD=z[1]; f=z[2]; \\ split into fundamental discriminant and square
  if (f%2!=0, return(geteulercharX(D)), return(3/2*geteulercharX(D)));
}
%    \end{macrocode}
% Luckily, the Euler characteristic of the ``normal'' Hilbert modular surface $X_D$ is known. Siegel and, later, Cohen gave explicit expressions for it in terms of zeta functions and divisor sums, see \cite[Thm 2.12, 2.15 and 2.16]{bainbridgeeulerchar} for a detailed discussion. First, we must calculate certain divisor sums
%\[H(D)=-\frac{1}{5}\sum_{e\equiv D(2)}\sigma_1\left(\frac{D-e^2}{4}\right).\]
% Here:
%    \begin{macrocode}
H (D) = { \\ calculate H(2,D)
  local(HH,e);
  HH=0;
  forstep (e=D%2,sqrt(D),2,
    if (e==0, 
      HH+=mysigma((D-e^2)/4),
      HH+=2*mysigma((D-e^2)/4));
  );
  HH/=-5;
  if (issquare(D),HH-=D/10);
  return(HH);
}
%    \end{macrocode}
% Note that we slightly modified PARI's sigma function to accept $0$:
%    \begin{macrocode}
mysigma (n) = {\\ return sigma_1 for >0, -1/24 for 0
  if (n==0, return (-1/24));
  return(sigma(n));
}
%    \end{macrocode}
% By exploiting the fact that $\zeta_D$, the Dedekind zeta function of $\mathbb{Q}(\sqrt{D})$ satisfies
%\[\zeta_D(-1)=-\frac{1}{12}H(D),\]
% we can finally calculate the Euler characteristic:
%    \begin{macrocode}
geteulercharX(D) = { \\ calculate chi(X_D) for D
  local (DD,f,z,chi);
  z=coredisc(D,1); 
  DD=z[1]; f=z[2]; \\ split into fundamental discriminant and square
  chi=sumdiv(f,r,kronecker(DD,r)*moebius(r)/r^2);
  chi*=-H(DD)/12;
  chi*=2*f^3;
  return(chi);
}
%    \end{macrocode} 
%
% \subsection{Orbifold points}
%
% By \cite[Thm 5.1 and 5.6]{TTZ}, orbifold points occuring on $W_D$ are necessarily of order $2,3,4$ or $6$. Moreover, $W_8$ is the only curve with a point of order $4$ and $W_{12}$ is the only curve with a point of order $6$. Points of order $2$ occur only for even $D$ and for $D>12$, their number is equal to the cardinality of
%\[\mathcal{H}_2(D)=\{(a,b,c)\in\mathbb{Z}^3:a^2+b^2+c^2=D,\,\gcd(a,b,c,f)=1\}\]
% divided by $24$, where $f$ is the conductor of $D$.
%
% This is implemented by a simple combination of loops. Note that, as $D\equiv0\mod4$, any valid $a,b,c$ must all be even. By definition of the conductor, any other common divisor of $a,b,c$ will also divide $f$ and, by reducing the equation mod $16$, it is not difficult to see that the case $\gcd(a,b,c,f)=2$ does not occur. Therefore, the condition $\gcd(a,b,c)=2$ is indeed equivalent to the ``proper'' condition in \cite{TTZ}.
%    \begin{macrocode}
countpointsC4(D) = {\\ count C4 orbifold points, D non-square
  local(c,C);
  C=0;
  if(D%4==1,return(0)); \\ no endomorphism (sqrt(D)+1)/2
  for (a=0,sqrt(D),
    for (b=0,sqrt(D),
      if(issquare(D-a^2-b^2),
        c=sqrtint(D-a^2-b^2);
        if(mygcd(a,b,c)==2, \\ 0 mod 4, otherwise not maximal!
          if((a==0 || b==0 || c==0),C+=4,C+=8);
        );
      );
    );
   );
  return(C/24);
}
%    \end{macrocode}
% To simplify notation, we expanded PARI's \texttt{gcd} function to accept three variables:
%    \begin{macrocode}
mygcd(a,b,c) = {\\ gcd for three values ....
  return(gcd(a,gcd(b,c)));
}
%    \end{macrocode}
% Next, we count points of order $3$. Their number may be determined, for $D\neq 12$ by the cardinality of
%\newlength{\hwidth}\settowidth{\hwidth}{$(4a+3b+3c<0)\vee(4a+3b+3c=0\ \wedge\ 3b<c)\,$}
%\[\mathcal{H}_{3}(D)= \left\{(a,b,c)\in\mathbb{Z}^{3}\ :\ \begin{minipage}{\hwidth}$2a^{2}-3b^{2}-c^{2}=2D\ ,\ \gcd(a,b,c,f)=1\ ,$\\$\ -3\sqrt{D}<a<-\sqrt{D}\ ,\ c<b\leq0\ , $\\\ $(4a-3b-3c<0)\vee(4a-3b-3c=0\ \wedge\ c<3b)\,$\end{minipage}\right\},\]
% where, again, $f$ is the conductor of $D$.
%
% This is implemented by first looping over $a$ (note that we replace $a$, $b$, and $c$ by $-a$, $-b$, and $-c$ so that all integers are positive) and distinguishing the case $b=0$. In this case, as $D$ is not a square, $c$ is never $0$ and, using the bound on $a$, it is not difficult to see that $3c-4a<0$. For $b\neq0$, these conditions must be checked separately. Observe that the first condition implies that $b$ is bounded by $\tfrac{1}{3}\sqrt{6}\sqrt{a^2-D}$. Note also that the gcd condition prevents $3b=c$ in the case $4a-3b-3c=0$.
%    \begin{macrocode}
countpoints(D) = {\\ count C6 orbifold points, D non-square
  local(z,c,p,f);
  p=0;
  z=sqrtint(D)+1; 
  f=coredisc(D,1)[2]; \\ f^2*D_0=D
  for (a=z,3*sqrt(D),
    if(issquare(2*(a^2-D)),
      c=sqrtint(2*(a^2-D));
      if(mygcd(a,c,f)==1, \\proper
        p+=1; 
      );
    );
    for(b=1,sqrt(6)*sqrt(a^2-D)/3,
      if(b>=sqrt(2*a^2-3*b^2-2*D),next());
      if(-4*a+3*b+3*sqrt(2*a^2-3*b^2-2*D)>0,next());
      if(issquare(2*a^2-3*b^2-2*D),
          c=sqrtint(2*a^2-3*b^2-2*D);
          if(gcd(mygcd(a,b,c),f)==1, \\ proper
            if(! (-4*a+3*b+3*c==0 && 3*b>c), p+=1); 
          );
       );      
     );
   );
  return(p);
}
%    \end{macrocode}
%
% \subsection{Orbifold signature}
%
% We combine all this data to give the orbifold signature, using the formula
%\[2-2g= \chi+C+\sum_{d} h_{d}\left(1-\frac{1}{d}\right),\]
% where $g$ denotes the genus of $W_D$, $\chi$ the Euler characteristic, $C$ the number of cusps and $h_{d}$ the number of orbifold points of order $d$. 
%
%Note that whenever $W_D$ has two components (i.e. $D\equiv 1\mod 8$, cf. \cite{lanneaunguyen}), these two components are in fact homeomorphic (cf. \cite{components}), so we may simply divide all values by $2$.
%    \begin{macrocode}
getsignature(D) = {
  local(chi,gg,g,c,P2,p2,p3,p6,G);
  p2=0; p3=0; p4=0; p6=0;
  if(D%8==1,c=cusps(D)/2,c=cusps(D));
  chi=geteulercharWP(D);
  if(D==12,p6=1,p3=countpoints(D));
  if(D==12,p2=0,if(D==8,p4=1,p2=countpointsC4(D)));
  if(D%8==1,p3/=2); \\ two components
  G=(2-chi-c-(1/2*p2+2/3*p3+3/4*p4+5/6*p6))/2;
  return([chi,c,G,p2,p3,p4,p6]);
} 
%    \end{macrocode}
% Finally, we provide a macro printing a table of the orbifold signature of $W_D$ for $D$ up to $n$ (default $n=100$).
%    \begin{macrocode}
printsignature(n=100) = {
  local(sig);
  print("D\tD(8)\tChi\tcusps\tg\tp2\tp3\tp4\tp6");
  forstep(D=5,n,[3,1],
    if(issquare(D),next()); \\ D non-square
    if(D%8==5,next()); \\ empty
    sig=getsignature(D);
    print1(D,"\t",D%8);
    for(i=1,7,print1("\t",sig[i])); 
    print1("\n");
  );
}
%    \end{macrocode}
%\iffalse
%</pari>
%\fi
%\Finale
%\endinput
%<*bib>
@article{lanneaunguyen,
   author={Erwan Lanneau and Duc-Manh Nguyen},
   title={Teichmüller curves generated by Weierstrass Prym eigenforms in genus 3 and genus 4},
   journal={J. Topol.},
   volume={7},
   number={2},
   pages={475--522},
   year={2014}
}
@article{moellerprym,
   author={Martin M{\"o}ller},
   title={Prym covers, theta functions and Kobayashi geodesics in Hilbert modular surfaces},
   year={2014},
   journal={Amer. Journal. of Math.},
  volume={135},
  pages={995--1022},
}
@article{bainbridgeeulerchar,
   author={Matt Bainbridge},
   title={Euler characteristics of Teichmüller curves in genus two},
   journal={Geom. Topol.},
   volume={11},
   year={2007},
   pages={1887--2073},
}
@article{TTZ,
  author={David Torres Teigell and Jonathan Zachhuber},
  title={Orbifold Points on Prym-Teichmüller Curves in Genus Three},
  year={2015},
  eprint={1502.05381},
  eprinttype={arxiv},
  eprintclass={math.AG}
}
@manual{PARI2,
  organization = "{The PARI~Group}",
  title        = "{PARI/GP version {\tt 2.3.5}}",
  year         = 2010,
  address      = "Bordeaux",
  url         = {http://pari.math.u-bordeaux.fr/}
 }
@online{components,
  title={The Galois Action and a Spin Invariant for Prym-Teichmüller Curves in Genus 3},
  author={Jonathan Zachhuber},
  year={2015},
  eprint={1511.06275},
  eprinttype={arxiv},
  eprintclass={math.AG}
}
%</bib>