% This file is intended to be processed by plain TeX (TeX82).
% Reference Card for PARI-GP.

% Copyright (c) 1997-2008 Karim Belabas.
% Permission is granted to copy, distribute and/or modify this document
% under the terms of the GNU General Public License

% Based on an earlier version by Joseph H. Silverman who kindly let me
% use his original file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The original copyright notice read:
%
%% Copyright (c) 1993,1994 Joseph H. Silverman. May be freely distributed.
%% Created Tuesday, July 27, 1993
%% Thanks to Stephen Gildea for the multicolumn macro package
%% which I modified from his GNU emacs reference card
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\TITLE{Pari/GP reference card}
\def\versionnumber{2.27}% Version of this reference card
\def\PARIversion{2.6.1}% Version of PARI described on this reference card
\def\year{2013}
\def\month{September}

\special{papersize=29.7cm,21cm}

% ignore parimacro.tex's \magnification setting
\let\oldmagnification\magnification
\catcode`@=11
\def\magnification{\count@}%
\catcode`@=12
\input parimacro.tex
\let\magnification\oldmagnification
\ifPDF
  \pdfpagewidth=11.69in
  \pdfpageheight=8.26in
\fi
%**start of header
\newcount\columnsperpage
% The final reference card has six columns, three on each side.
% This file can be used to produce it in any of three ways:
% 1 column per page
%    produces six separate pages, each of which needs to be reduced to 80%.
%    This gives the best resolution.
% 2 columns per page
%    produces three already-reduced pages.
%    You will still need to cut and paste.
% 3 columns per page
%    produces two pages which must be printed sideways to make a
%    ready-to-use 8.5 x 11 inch reference card.
%    For this you need a dvi device driver that can print sideways.
% [For 2 or 3 columns, you'll need 6 and 8 point fonts.]
% Which mode to use is controlled by setting \columnsperpage above.
%
% Specify how many columns per page you want here:
\columnsperpage=3

% You shouldn't need to modify anything below this line.
%
% Author:
%  Karim Belabas
%  Universite Bordeaux 1, 351 avenue de la Liberation, F-33405 Talence
%  email: Karim.Belabas@math.u-bordeaux.fr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (original reference card by Joseph H. Silverman)
% (original reference card macros due to Stephen Gildea)
%
%% Original Thanks:
%%  I would like to thank Jim Delaney, Kevin Buzzard, Dan Lieman,
%%  and Jaap Top for sending me corrections.
%%
% Thanks to Bill Allombert, Henri Cohen, Gerhard Niklasch, and Joe Silverman
% for many comments and corrections.

\def\version{\month\ \year\ v\versionnumber}

\def\shortcopyrightnotice{\vskip .5ex plus 2 fill
  \centerline{\small \copyright\ \year\ Karim Belabas.
  Permissions on back.  v\versionnumber}}

\def\<#1>{$\langle${#1}$\rangle$}
\def\copyrightnotice{\vskip 1ex plus 2 fill
\begingroup\small
\centerline{Based on an earlier version by Joseph H. Silverman}
\centerline{\version. Copyright \copyright\ \year\ K. Belabas}
%\centerline{GP copyright by The PARI Group}

Permission is granted to make and distribute copies of this card provided the
copyright and this permission notice are preserved on all copies.

Send comments and corrections to \<Karim.Belabas@math.u-bordeaux.fr>
\endgroup}

% make \bye not \outer so that the \def\bye in the \else clause below
% can be scanned without complaint.
\def\bye{\par\vfill\supereject\end}

\newdimen\intercolumnskip
\newbox\columna
\newbox\columnb

\def\ncolumns{\the\columnsperpage}

\message{[\ncolumns\space
  column\if 1\ncolumns\else s\fi\space per page]}

\def\scaledmag#1{ scaled \magstep #1}

% This multi-way format was designed by Stephen Gildea
% October 1986.
\if 1\ncolumns
  \hsize 4in
  \vsize 10in
  \voffset -.7in
  \font\titlefont=\fontname\tenbf \scaledmag3
  \font\headingfont=\fontname\tenbf \scaledmag2
  \font\smallfont=\fontname\sevenrm
  \font\smallsy=\fontname\sevensy

  \footline{\hss\folio}
  \def\makefootline{\baselineskip10pt\hsize6.5in\line{\the\footline}}
\else
  \hsize 3.2in
%  \vsize 7.95in
  \vsize 7.90in
  \hoffset -.75in
%  \voffset -.745in
  \voffset -.815in
  \font\titlefont=cmbx10 \scaledmag2
  \font\headingfont=cmbx10 %\scaledmag1
  \font\smallfont=cmr6
  \font\smallsy=cmsy6
  \font\eightrm=cmr8
  \font\eightbf=cmbx8
  \font\eightit=cmti8
  \font\eighttt=cmtt8
  \font\eightsy=cmsy8
  \font\eightsl=cmsl8
  \font\eighti=cmmi8
  \font\eightex=cmex10 at 8pt
  \textfont0=\eightrm
  \textfont1=\eighti
  \textfont2=\eightsy
  \textfont3=\eightex
  \def\rm{\fam0 \eightrm}
  \def\bf{\eightbf}
  \def\it{\eightit}
  \def\tt{\eighttt}
  \normalbaselineskip=.8\normalbaselineskip
  \normallineskip=.8\normallineskip
  \normallineskiplimit=.8\normallineskiplimit
  \normalbaselines\rm %make definitions take effect

  \if 2\ncolumns
    \let\maxcolumn=b
    \footline{\hss\rm\folio\hss}
    \def\makefootline{\vskip 2in \hsize=6.86in\line{\the\footline}}
  \else \if 3\ncolumns
    \let\maxcolumn=c
    \nopagenumbers
  \else
    \errhelp{You must set \columnsperpage equal to 1, 2, or 3.}
    \errmessage{Illegal number of columns per page}
  \fi\fi

  \intercolumnskip=.46in
  \def\abc{a}
  \output={%
      % This next line is useful when designing the layout.
      %\immediate\write16{Column \folio\abc\space starts with \firstmark}
      \if \maxcolumn\abc \multicolumnformat \global\def\abc{a}
      \else\if a\abc
        \global\setbox\columna\columnbox \global\def\abc{b}
        %% in case we never use \columnb (two-column mode)
        \global\setbox\columnb\hbox to -\intercolumnskip{}
      \else
        \global\setbox\columnb\columnbox \global\def\abc{c}\fi\fi}
  \def\multicolumnformat{\shipout\vbox{\makeheadline
      \hbox{\box\columna\hskip\intercolumnskip
        \box\columnb\hskip\intercolumnskip\columnbox}
      \makefootline}\advancepageno}
  \def\columnbox{\leftline{\pagebody}}

  \def\bye{\par\vfill\supereject
    \if a\abc \else\null\vfill\eject\fi
    \if a\abc \else\null\vfill\eject\fi
    \end}
\fi

% we won't be using math mode much, so redefine some of the characters
% we might want to talk about
%\catcode`\^=12
%\catcode`\_=12
%\catcode`\~=12

\chardef\\=`\\
\chardef\{=`\{
\chardef\}=`\}

\hyphenation{}

\parindent 0pt
\parskip 0pt

\def\small{\smallfont\textfont2=\smallsy\baselineskip=.8\baselineskip}

\outer\def\newcolumn{\vfill\eject}

\outer\def\title#1{{\titlefont\centerline{#1}}}

\outer\def\section#1{\par\filbreak
  \vskip 1ex plus .4ex minus .5ex
  {\headingfont #1}\mark{#1}%
  \vskip .5ex plus .3ex minus .5ex
}

\outer\def\subsec#1{\filbreak
  \vskip 0.07ex plus 0.05ex
  {\bf #1}
  \vskip 0.03ex plus 0.05ex
}

\newdimen\keyindent
\def\beginindentedkeys{\keyindent=1em}
\def\endindentedkeys{\keyindent=0em}
\endindentedkeys

\def\kbd#1{{\tt#1}\null} %\null so not an abbrev even if period follows

\newbox\libox
\setbox\libox\hbox{\kbd{M-x }}
\newdimen\liwidth
\liwidth=\wd\libox

\def\li#1#2{\leavevmode\hbox to \hsize{\hbox to .75\hsize
  {\hskip\keyindent\relax#1\hfil}%
  \hskip -\liwidth minus 1fil
  \kbd{#2}\hfil}}

\def\threecol#1#2#3{\hskip\keyindent\relax#1\hfil&\kbd{#2}\quad
  &\kbd{#3}\quad\cr}

\def\mod{\;\hbox{\rm mod}\;}
\def\expr{\hbox{\it expr}}
\def\seq{\hbox{\it seq}}
\def\args{\hbox{\it args}}
\def\file{\hbox{\it file}}
\def\QQ{\hbox{\bf Q}}
\def\ZZ{\hbox{\bf Z}}
\def\RR{\hbox{\bf R}}
\def\FF{\hbox{\bf F}}
\def\CC{\hbox{\bf C}}
\def\deg{\mathop{\rm deg}}
\def\bs{\char'134}
\def\pow{\^{}\hskip0pt}
\def\til{\raise-0.3em\hbox{\~{}}}
\def\typ#1{\kbd{t\_#1}}
%**end of header

\title{PARI-GP Reference Card}
\centerline{(PARI-GP version \PARIversion)}
Note: optional arguments are surrounded by braces $\{\}$.\hfill\break
To start the calculator, type its name in the terminal: \kbd{gp}\hfill\break
To exit \kbd{gp}, type \kbd{quit}, \kbd{\\q}, or \kbd{<C-D>} at prompt.\hfill
\section{Help}
\li{describe function}{?{\it function}}
\li{extended description}{??{\it keyword}}
\li{list of relevant help topics}{???{\it pattern}}

\section{Input/Output}
\li{previous result, the result before}
  {\%{\rm, }\%`{\rm, }\%``{\rm, etc.}}
\li{$n$-th result since startup}{\%$n$}
\li{separate multiple statements on line}{;}
\li{extend statement on additional lines}{\\}
\li{extend statements on several lines}{\{$\seq_1$; $\seq_2$;\}}
\li{comment}{/* $\dots$ */}
\li{one-line comment, rest of line ignored}{\\\\ \dots}

\section{Metacommands \& Defaults}
\li{set default $d$ to \var{val}} {default$(\{d\},\{\var{val}\},\{\fl\})$}
\li{toggle timer on/off}{\#}
\li{print time for last result}{\#\#}
\li{print defaults}{\\d}
\li{set debug level to $n$}{\\g $n$}
\li{set memory debug level to $n$}{\\gm $n$}
\li{set output mode (raw=0, default=1)}{\\o $n$}
\li{set $n$ significant digits}{\\p $n$}
\li{set $n$ terms in series}{\\ps $n$}
\li{quit GP}{\\q}
\li{print the list of PARI types}{\\t}
\li{print the list of user-defined functions}{\\u}
\li{read file into GP}{\\r {\it filename}}

\section{Debugger / break loop}
\li{get out of break loop}{break {\rm or} <C-D>}
\li{go up $n$ frames}{dbg\_up$(\{n\})$}
\li{examine object $o$}{dbg\_x$(o)$}

\section{PARI Types \& Input Formats}
\li{\typ{INT}/\typ{REAL}. Integers, Reals}{$\pm n$, $\pm n.ddd$}
\li{\typ{INTMOD}. Integers modulo $m$}{Mod$(n,m)$}
\li{\typ{FRAC}. Rational Numbers}{$n/m$}
\li{\typ{FFELT}. Elt in finite field $\F_q$}{ffgen(q)}
\li{\typ{COMPLEX}. Complex Numbers}{$x +y\,*\;$I}
\li{\typ{PADIC}. $p$-adic Numbers}{$x\;+\;$O$(p$\pow$k)$}
\li{\typ{QUAD}. Quadratic Numbers}{$x + y\,*\;$quadgen$(D)$}
\li{\typ{POLMOD}. Polynomials modulo $g$}{Mod$(f,g)$}
\li{\typ{POL}. Polynomials}{$a*x$\pow$n+\cdots+b$}
\li{\typ{SER}. Power Series}{$f\;+\;$O$(x$\pow$k)$}
\li{\typ{QFI}/\typ{QFR}. Imag/Real bin.\ quad.\ forms}
  {Qfb$(a,b,c,\{d\})$}
\li{\typ{RFRAC}. Rational Functions}{$f/g$}
\li{\typ{VEC}/\typ{COL}. Row/Column Vectors}
  {[$x,y,z$]{\rm,} [$x,y,z$]\til}
\li{\typ{MAT}. Matrices}{[$x,y$;$z,t$;$u,v$]}
\li{\typ{LIST}. Lists}{List$($[$x,y,z$]$)$}
\li{\typ{STR}. Strings}{"abc"}

\section{Reserved Variable Names}
\li{$\pi=3.14\dots$, $\gamma=0.57\dots$, $C=0.91\dots$}{Pi{\rm, }Euler{\rm, }Catalan}
\li{square root of $-1$}{I}
\li{big-oh notation}{O}

% ****************************************
% This goes at the bottom of page 1
\shortcopyrightnotice
\newcolumn

\section{Information about an Object}
\li{PARI type of object $x$}{type$(x)$}
\li{length of $x$ / size of $x$ in memory}{\#$x${\rm, }sizebyte$(x)$}
\li{real or $p$-adic precision of $x$}{precision$(x)${\rm, }padicprec}

\section{Operators}
\li{basic operations}{+{\rm,} - {\rm,} *{\rm,} /{\rm,} \pow}
\li{\kbd{i=i+1}, \kbd{i=i-1}, \kbd{i=i*j}, \dots}
  {i++{\rm,} i--{\rm,} i*=j{\rm,}\dots}
\li{euclidean quotient, remainder}{$x$\bs/$y${\rm,} $x$\bs$y${\rm,}
$x$\%$y${\rm,} divrem$(x,y)$}
\li{shift $x$ left or right $n$ bits}{ $x$<<$n$, $x$>>$n$
  {\rm or} shift$(x,\pm n)$}
  \li{comparison operators}{<={\rm, }<{\rm, }>={\rm, }>{\rm, }=={\rm,
  }!={\rm, }==={\rm, }lex{\rm, }cmp}
\li{boolean operators (or, and, not)}{||{\rm, } \&\&{\rm ,} !}
\li{bit operations}{bitand{\rm, }bitneg{\rm, }bitor{\rm, }bitxor}
\li{sign of $x=-1,0,1$}{sign$(x)$}
\li{maximum/minimum of $x$ and $y$}{max{\rm,} min$(x,y)$}
\li{integer or real factorial of $x$}{$x$!~{\rm or} factorial$(x)$}
\li{derivative of $f$ w.r.t. $x$}{$f$'}
\li{apply differential operator}{diffop}
\li{restore $x$ as a formal variable}{$x$='$x$}
\li{simultaneous assignment $x\leftarrow v_1$, $y\leftarrow v_2$}{[x,y] = v}
\section{Select Components}
\li{$n$-th component of $x$}{component$(x,n)$}
\li{$n$-th component of vector/list $x$}{$x$[$n$]}
\li{components $a,a+1,\dots,b$ of vector $x$}{$x$[$a$..$b$]}
\li{$(m,n)$-th component of matrix $x$}{$x$[$m,n$]}
\li{row $m$ or column $n$ of matrix $x$}{$x$[$m,$]{\rm,} $x$[$,n$]}
\li{numerator/denominator of $x$}{numerator$(x)${\rm, }denominator}
%
\section{Conversions}
\li{to vector, matrix, set, list, string}
  {Col{\rm/}Vec{\rm,}Mat{\rm,}Set{\rm,}List{\rm,}Str}
\li{create PARI object $(x\mod y)$}{Mod$(x,y)$}
\li{make $x$ a polynomial of $v$}{Pol$(x,\{v\})$}
\li{as \kbd{Pol}/\kbd{Vec}, starting with constant term}{Polrev{\rm, }Vecrev}
\li{make $x$ a power series of $v$}{Ser$(x,\{v\})$}
\li{string from bytes / from format+args}{Strchr{\rm, }Strprintf}
\li{convert $x$ to simplest possible type}{simplify$(x)$}
\li{object $x$ with precision $n$}{precision$(x,n)$}
%
\subsec{Conjugates and Lifts}
\li{conjugate of a number $x$}{conj$(x)$}
\li{conjugate vector of algebraic number $x$}{conjvec$(x)$}
\li{norm of $x$, product with conjugate}{norm$(x)$}
\li{square of $L^2$ norm of vector $x$}{norml2$(x)$}
\li{lift of $x$ from Mods}{lift{\rm,} centerlift$(x)$}

\begingroup
\outer\def\subsec#1{\filbreak
  \vskip 0.05ex plus 0.05ex
  {\bf #1}
  \vskip 0.05ex plus 0.05ex
}

\section{Lists, Sets \& Sorting}
\li{sort $x$ by $k$-th component}{vecsort$(x,\{k\},\{fl=0\})$}
\li{min.~$m$ of $x$ ($m=x[i]$), max.}{vecmin$(x,\{\&i\})${\rm, }vecmax}
\li{does $y$ belong to $x$, sorted wrt. $f$}{vecsearch$(x,y,\{f\})$}
  {\bf Sets} (= row vector of strings with strictly increasing entries)\hfill\break
%
\li{intersection of sets $x$ and $y$}{setintersect$(x,y)$}
\li{set of elements in $x$ not belonging to $y$}{setminus$(x,y)$}
\li{union of sets $x$ and $y$}{setunion$(x,y)$}
\li{does $y$ belong to the set $x$}{setsearch$(x,y,\{\fl\})$}
\li{is $x$ a set ?}{setisset$(x)$}
%
\subsec{Lists. {\rm create empty list: $L$ = List$()$}}
\li{append $x$ to list $L$}{listput$(L,x,\{i\})$}
\li{remove $i$-th component from list $L$}{listpop$(L,\{i\})$}
\li{insert $x$ in list $L$ at position $i$}{listinsert$(L,x,i)$}
\li{sort the list $L$ in place}{listsort$(L,\{\fl\})$}

\newpage
\section{Programming}
\subsec{Functions and closures}
\leavevmode
 {\tt fun(vars) = my(local vars); \var{seq}\hfill\break}
 {\tt fun = (vars) -> my(local vars); \var{seq}\hfill}
\subsec{Control Statements {\rm ($X$: formal parameter in expression \seq)}}
\li{eval.\ \seq\ for $a\le X\le b$}{for$(X\,$=$\;a,b,\seq)$}
\li{eval.\ \seq\ for $X$ dividing $n$}{fordiv$(n,X,\seq)$}
\li{eval.\ \seq\ for primes $a\le X\le b$}{forprime$(X\,$=$\;a,b,\seq)$}
\li{eval.\ \seq\ for $a\le X\le b$ stepping
$s$}{forstep$(X\,$=$\;a,b,s,\seq)$}
\li{multivariable {\tt for}}{forvec$(X\,$=$\;v,\seq)$}
\li{loop over partitions of $n$}{forpart$(p\,$=$n\;\seq)$}
\li{loop over vectors $v$, $q(v)\leq B$, $q > 0$}{forqfvec$(v, q, b, \seq)$}
\li{loop over subgrps $H$ of abelian grp $G$}{forsubgroup$(H=G)$}
\li{evaluate \seq\ until $a\ne0$}{until$(a,\seq)$}
\li{while $a\ne0$, evaluate \seq}{while$(a,\seq)$}
\li{exit $n$ innermost enclosing loops}{break$(\{n\})$}
\li{start new iteration of $n$-th enclosing loop}{next$(\{n\})$}
\li{return $x$ from current subroutine}{return$(\{x\})$}
\li{raise an exception}{error$()$}
\li{if $a\ne0$, evaluate $\seq_1$, else $\seq_2$}{if$(a,\{\seq_1\},\{\seq_2\})$}
\li{try $\seq_1$, evaluate $\seq_2$ on error}{iferr$(\seq_1, E, \seq_2)$}
%\li{type of error message $E$}{errname$(E)$}
\li{select from $v$ according to $f$}{select$(f, v)$}
\li{apply $f$ to all entries in $v$}{apply$(f, v)$}
%
\subsec{Input/Output}
\li{print with/without \kbd{\bs n}, \TeX\ format}{print{\rm, }print1{\rm,
}printtex}
\li{formatted printing}{printf$()$}
\li{write \args\ to file}{write{\rm,} write1{\rm,} writetex$(\file,\args)$}
\li{write $x$ in binary format}{writebin$(\file,x)$}
\li{read file into GP}{read($\{\file\}$)}
\li{read file, return as vector of lines}{readvec($\{\file\}$)}
\li{read a string from keyboard}{input$()$}
%
\subsec{Interface with User and System}
\li{allocates a new stack of $s$ bytes}{allocatemem$(\{s\})$}
\li{alias \var{old}\ to \var{new}}{alias$(\var{new},\var{old})$}
\li{install function from library}{install$(f,code,\{\var{gpf\/}\},\{\var{lib}\})$}
\li{execute system command $a$}{system$(a)$}
\li{as above, feed result to GP}{extern$(a)$}
\li{as above, return GP string}{externstr$(a)$}
%\li{new name of function $f$ in GP 2.0}{whatnow$(f)$}
\li{get \kbd{\$VAR} from environment}{getenv$($\kbd{"VAR"}$)$}
\li{measure time in ms.}{gettime$()$}
\li{timeout command after $s$ seconds}{alarm$(s, \expr)$}
%
\section{Iterations, Sums \& Products}
\li{numerical integration}{intnum$(X\,$=$\;a,b,\expr,\{\fl\})$}
\li{sum \expr\ over divisors of $n$}{sumdiv$(n,X,\expr)$}
\li{\kbd{sumdiv}, with \expr\ multiplicative}{sumdivmult$(n,X,\expr)$}
\li{sum $X=a$ to $X=b$, initialized at $x$}{sum$(X\,$=$\;a,b,\expr,\{x\})$}
\li{sum of series \expr}{suminf$(X\,$=$\;a,\expr)$}
\li{sum of alternating/positive series}{sumalt{\rm,} sumpos}
\li{sum of series using \kbd{intnum}}{sumnum}
\li{product $a\le X\le b$, initialized at $x$}{prod$(X\,$=$\;a,b,\expr,\{x\})$}
\li{product over primes $a\le X\le b$}{prodeuler$(X\,$=$\;a,b,\expr)$}
\li{infinite product $a\le X\le\infty$}{prodinf$(X\,$=$\;a,\expr)$}
\li{real root of \expr\ between $a$ and $b$}{solve$(X\,$=$\;a,b,\expr)$}
\endgroup

\section{Random Numbers}
\li{random integer/prime in $[0,N[$}{random$(N)${\rm, }randomprime}
\li{get/set random seed}{getrand{\rm, }setrand$(s)$}

% This goes at the top of page 4 (=1st column on back of reference card)

\section{Vectors \& Matrices}
%
\li{dimensions of matrix $x$}{matsize$(x)$}
\li{concatenation of $x$ and $y$}{concat$(x,\{y\})$}
\li{extract components of $x$}{vecextract$(x,y,\{z\})$}
\li{transpose of vector or matrix $x$}{mattranspose$(x)$ {\rm or} $x$\til}
\li{adjoint of the matrix $x$}{matadjoint$(x)$}
\li{eigenvectors/values of matrix $x$}{mateigen$(x)$}
\li{characteristic/minimal polynomial of $x$}{charpoly$(x)${\rm, }minpoly}
\li{trace/determinant of matrix $x$}{trace$(x)${\rm, }matdet}
\li{Frobenius form of $x$}{matfrobenius$(x)$}
\li{QR decomposition}{matqr$(x)$}
%
\subsec{Constructors \& Special Matrices}
\li{row vec.\ of \expr\ eval'ed at $1\le i\le n$}{vector$(n,\{i\},\{\expr\})$}
\li{col.\ vec.\ of \expr\ eval'ed at $1\le i\le n$}{vectorv$(n,\{i\},\{\expr\})$}
\li{matrix $1\le i\le m$, $1\le j\le n$}{matrix$(m,n,\{i\},\{j\},\{\expr\})$}
\li{define matrix by blocks}{matconcat$(B)$}
\li{diagonal matrix with diagonal $x$}{matdiagonal$(x)$}
\li{$n\times n$ identity matrix}{matid$(n)$}
\li{Hessenberg form of square matrix $x$}{mathess$(x)$}
\li{$n\times n$ Hilbert matrix $H_{ij}=(i+j-1)^{-1}$}{mathilbert$(n)$}
%\li{$n\times n$ Pascal triangle}{matpascal$(n-1)$}
\li{companion matrix to polynomial $x$}{matcompanion$(x)$}
\li{Sylvester matrix of $x$}{polsylvestermatrix$(x)$}
%
\subsec{Gaussian elimination}
\li{kernel of matrix $x$}{matker$(x,\{\fl\})$}
\li{intersection of column spaces of $x$ and $y$}{matintersect$(x,y)$}
\li{solve $M*X = B$ ($M$ invertible)}{matsolve$(M,B)$}
\li{as solve, modulo $D$ (col. vector)}{matsolvemod$(M,D,B)$}
\li{one sol of $M*X = B$}{matinverseimage$(M,B)$}
\li{basis for image of matrix $x$}{matimage$(x)$}
\li{supplement columns of $x$ to get basis}{matsupplement$(x)$}
\li{rows, cols to extract invertible matrix}{matindexrank$(x)$}
\li{rank of the matrix $x$}{matrank$(x)$}

\section{Lattices \& Quadratic Forms}
\li{upper triangular Hermite Normal Form}{mathnf$(x)$}
\li{HNF of $x$ where $d$ is a multiple of det$(x)$}{mathnfmod$(x,d)$}
\li{elementary divisors of $x$}{matsnf$(x)$}
\li{LLL-algorithm applied to columns of $x$}{qflll$(x,\{\fl\})$}
\li{like \kbd{qflll}, $x$ is Gram matrix of lattice}
  {qflllgram$(x,\{\fl\})$}
\li{LLL-reduced basis for kernel of $x$}{matkerint$(x)$}
\li{$\ZZ$-lattice $\longleftrightarrow$ $\QQ$-vector space}{matrixqz$(x,p)$}
%
\li{signature of quad form $^ty*x*y$}{qfsign$(x)$}
\li{decomp into squares of $^ty*x*y$}{qfgaussred$(x)$}
\li{eigenvals/eigenvecs for real symmetric $x$}{qfjacobi$(x)$}
\li{find up to $m$ sols of $^ty*x*y\le b$}{qfminim$(x,b,m)$}
\li{perfection rank of $x$}{qfperfection$(x)$}
\li{$v$, $v[i]:=$number of sols of $^ty*x*y = i$}{qfrep$(x,B,\{\fl\})$}
\li{automorphism group of $q$}{qfauto$(q)$}
\li{find isomorphism between $q$ and $Q$}{qfisom$(q,Q)$}

\section{Formal \& p-adic Series}
\li{truncate power series or $p$-adic number}{truncate$(x)$}
\li{valuation of $x$ at $p$}{valuation$(x,p)$}
\subsec{Dirichlet and Power Series}
\li{Taylor expansion around $0$ of $f$ w.r.t. $x$}{taylor$(f,x)$}
\li{$\sum a_kb_k t^k$ from $\sum a_kt^k$ and $\sum b_kt^k$}{serconvol$(a,b)$}
\li{$f=\sum a_k t^k$ from $\sum (a_k/k!)t^k$}{serlaplace$(f)$}
\li{reverse power series $F$ so $F(f(x))=x$}{serreverse$(f)$}
\li{Dirichlet series multiplication / division}{dirmul{\rm,} dirdiv$(x,y)$}
\li{Dirichlet Euler product ($b$ terms)}{direuler$(p\,$=$\;a,b,\expr)$}

\newcolumn
\title{PARI-GP Reference Card}
\centerline{(PARI-GP version \PARIversion)}

\section{Polynomials \& Rational Functions}
%
\li{degree of $f$}{poldegree$(f)$}
\li{coeff. of degree $n$ of $f$, leading coeff.}{polcoeff$(f,n)${\rm, }pollead}
\li{gcd of coefficients of $f$}{content$(f)$}
\li{replace $x$ by $y$}{subst$(f,x,y)$}
\li{evaluate $f$ replacing vars by their value}{eval$(f)$}
\li{replace polynomial expr.~$T(x)$ by $y$ in $f$}{substpol$(f,T,y)$}
\li{replace $x_1,\dots,x_n$ by $y_1,\dots,y_n$ in $f$}{substvec$(f,x,y)$}
\li{discriminant of polynomial $f$}{poldisc$(f)$}
%\li{elementary divisors of Z[a]/f'(a)Z[a]}{poldiscreduced$(f)$}
\li{resultant $R = \text{Res}_v(f,g)$}{polresultant$(f,g,\{v\})$}
\li{$[u,v,R]$, $xu + yv = \text{Res}_v(f,g)$}{polresultantext$(x,y,\{v\})$}
\li{derivative of $f$ w.r.t. $x$}{deriv$(f,\{x\})$}
\li{formal integral of $f$ w.r.t. $x$}{intformal$(f,\{x\})$}
\li{formal sum of $f$ w.r.t. $x$}{sumformal$(f,\{x\})$}
\li{reciprocal poly $x^{\deg f}f(1/x)$}{polrecip$(f)$}
\li{interpol.~pol.~eval.~at $a$}{polinterpolate$(X,\{Y\},\{a\},\{$\&$e\})$}
\li{initialize $t$ for Thue equation solver}{thueinit$(f)$}
\li{solve Thue equation $f(x,y)=a$}{thue$(t,a,\{sol\})$}
%
\subsec{Roots and Factorization}
\li{number of real roots of $f$, $a < x\le b$}{polsturm$(f,\{a\},\{b\})$}
\li{complex roots of $f$}{polroots$(f)$}
\li{symmetric powers of roots of $f$ up to $n$}{polsym$(f,n)$}
\li{factor $f$}{factor$(f,\{lim\})$}
\li{factor $f\mod p$ / roots}{factormod$(f,p)${\rm, }polrootsmod}
\li{factor $f$ over $\FF_{p^a}$ / roots}{factorff$(f,p,a)${\rm, }polrootsff}
\li{factor $f$ over $\QQ_p$ / roots}{factorpadic$(f,p,r)${\rm, }polrootspadic}
\li{find irreducible $T\in \FF_p[x]$, $\deg T = n$}{ffinit$(p,n,\{x\})$}
\li{$\#\{{\rm monic\ irred.}\ T\in \FF_q[x], \deg T = n\}$}{ffnbirred$(q,n)$}
\li{$p$-adic root of $f$ cong. to $a\mod p$}{padicappr$(f,a)$}
\li{Newton polygon of $f$ for prime $p$}{newtonpoly$(f,p)$}
\li{extensions of $\QQ_p$ of degree $N$}{padicfields$(p,N)$}
%
\subsec{Special Polynomials}
\li{$n$-th cyclotomic polynomial in var. $v$}{polcyclo$(n,\{v\})$}
\li{$d$-th degree subfield of $\QQ(\zeta_n)$} {polsubcyclo$(n,d,\{v\})$}
\li{$P_n$, $T_n/U_n$, $H_n$}{pollegendre{\rm, }polchebyshev{\rm, }polhermite}
%\li{Zagier's polynomial of index $n$,$m$}{polzagier$(n,m)$}

\section{Transcendental and $p$-adic Functions}
\li{real, imaginary part of $x$}{real$(x)$, imag$(x)$}
\li{absolute value, argument of $x$}{abs$(x)$, arg$(x)$}
\li{square/nth root of $x$}{sqrt$(x)$, sqrtn$(x,n,\{$\&$z\})$}
\li{trig functions}{sin, cos, tan, cotan}
\li{inverse trig functions}{asin, acos, atan}
\li{hyperbolic functions}{sinh, cosh, tanh}
\li{inverse hyperbolic functions}{asinh, acosh, atanh}
\li{exponential / natural log of $x$}{exp{\rm, }log}
%
\li{Euler $\Gamma$ function, $\log \Gamma$, $\Gamma'/\Gamma$}
   {gamma{\rm, }lngamma{\rm, }psi}
%\li{half-integer gamma function $\Gamma(n+1/2)$}{gammah$(n)$}
\li{incomplete gamma function ($y=\Gamma(s)$)}{incgam$(s,x,\{y\})$}
\li{exponential integral $\int_x^\infty e^{-t}/t\,dt$}{eint1$(x)$}
\li{error function $2/\sqrt\pi\int_x^\infty e^{-t^2}dt$}{erfc$(x)$}
\li{dilogarithm of $x$}{dilog$(x)$}
\li{$m$-th polylogarithm of $x$}{polylog$(m,x,\{\fl\})$}
\li{$U$-confluent hypergeometric function}{hyperu$(a,b,u)$}
\li{Bessel $J_n(x)$, $J_{n+1/2}(x)$}{besselj$(n,x)$, besseljh$(n,x)$}
\li{Bessel $I_\nu$, $K_\nu$, $H^1_\nu$, $H^2_\nu$, $N_\nu$}
{(bessel)i{\rm, }k{\rm, }h1{\rm, }h2{\rm, }n}
\li{Lambert $W$: $x$ s.t. $xe^x =y$}{lambertw$(y)$}
\li{Teichmuller character of $p$-adic $x$}{teichmuller$(x)$}

\section{Elementary Arithmetic Functions}
\li{vector of binary digits of $|x|$}{binary$(x)$}
\li{bit number $n$ of integer $x$}{bittest$(x,n)$}
\li{Hamming weight of integer $x$}{hammingweight$(x)$}
%\li{Sum of decimal digits of integer $x$}{sumdigits$(x)$}
\li{ceiling/floor/fractional part}{ceil{\rm, }floor{\rm, }frac}
\li{round $x$ to nearest integer}{round$(x,\{$\&$e\})$}
\li{truncate $x$}{truncate$(x,\{$\&$e\})$}
\li{gcd/LCM of $x$ and $y$}{gcd$(x,y)$, lcm$(x,y)$}
\li{gcd of entries of a vector/matrix}{content$(x)$}
\par
\subsec{Primes and Factorization}
\li{add primes in $v$ to prime table}{addprimes$(v)$}
\li{Chebyshev $\pi(x)$, $n$-th prime $p_n$}{primepi$(x)$, prime$(n)$}
\li{vector of first $n$ primes}{primes$(n)$}
\li{smallest prime $\ge x$}{nextprime$(x)$}
\li{largest prime $\le x$}{precprime$(x)$}
\li{factorization of $x$}{factor$(x,\{lim\})$}
\li{$n=df^2$, $d$ squarefree/fundamental}{core$(n,\{fl\})${\rm, }coredisc}
\li{recover $x$ from its factorization}{factorback$(f,\{e\})$}
\par
\subsec{Divisors}
\li{number of prime divisors $\omega(n)$ / $\Omega(n)$}
   {omega$(n)${\rm, }bigomega}
\li{divisors of $n$ / number of divisors $\tau(n)$}{divisors$(n)${\rm, }numdiv}
\li{sum of ($k$-th powers of) divisors of $n$}{sigma$(n,\{k\})$}
\par
\subsec{Special Functions and Numbers}
\li{binomial coefficient $x\choose y$}{binomial$(x,y)$}
\li{Bernoulli number $B_n$ as real/rational}{bernreal$(n)${\rm, }bernfrac}
\li{Bernoulli polynomial $B_n(x)$}{bernpol$(n,\{x\})$}
\li{$n$-th Fibonacci number}{fibonacci$(n)$}
\li{Stirling numbers $s(n,k)$ and $S(n,k)$}{stirling$(n,k,\{\fl\})$}
\li{number of partitions of $n$}{numbpart$(n)$}
\li{M\"obius $\mu$-function}{moebius$(x)$}
\li{Hilbert symbol of $x$ and $y$ (at $p$)}{hilbert$(x,y,\{p\})$}
\li{Kronecker-Legendre symbol $({x\over y})$}{kronecker$(x,y)$}
\li{Dedekind sum $s(h,k)$}{sumdedekind$(h,k)$}
\par
\subsec{Multiplicative groups $(\ZZ/N\ZZ)^*$, $\FF_q^*$}
\li{Euler $\phi$-function}{eulerphi$(x)$}
\li{multiplicative order of $x$ (divides $o$)}{znorder$(x,\{o\})${\rm, }fforder}
\li{primitive root mod $q$ / $x$\kbd{.mod}}{znprimroot$(q)${\rm, }ffprimroot$(x)$}
\li{structure of $(\ZZ/n\ZZ)^*$}{znstar$(n)$}
\li{discrete logarithm of $x$ in base $g$}{znlog$(x,g,\{o\})${\rm, }fflog}
\subsec{Miscellaneous}
\li{integer square / $n$-th root of $x$}{sqrtint$(x)$, sqrtnint$(x,n)$}
\li{solve $z\equiv x$ and $z\equiv y$}{chinese$(x,y)$}
\li{minimal $u,v$ so $xu+yv=\gcd(x,y)$}{gcdext$(x,y)$}
\li{continued fraction of $x$}{contfrac$(x,\{b\},\{lmax\})$}
\li{last convergent of continued fraction $x$}{contfracpnqn$(x)$}
\li{rational approximation to $x$}{bestappr$(x,k)${\rm, }bestapprPade}

\section{True-False Tests}
\li{is $x$ the disc. of a quadratic field?}{isfundamental$(x)$}
\li{is $x$ a prime?}{isprime$(x)$}
\li{is $x$ a strong pseudo-prime?}{ispseudoprime$(x)$}
\li{is $x$ square-free?}{issquarefree$(x)$}
\li{is $x$ a square?}{issquare$(x,\{$\&$n\})$}
\li{is $x$ a perfect power?}{ispower$(x,\{k\},\{$\&$n\})$}
\li{is \var{pol}\ irreducible?}{polisirreducible$(\var{pol})$}

% This goes at the bottom of the second page (column 6)
\copyrightnotice
%

%%%%%%%%%%% Extra Material (part II)
%
\newcolumn
\title{PARI-GP Reference Card (2)}
\centerline{(PARI-GP version \PARIversion)}

\section{Elliptic Curves}
%
Elliptic curve initially given by $5$-tuple $v=$\kbd{[$a_1,a_2,a_3,a_4,a_6$]}.
\li{Initialize \var{ell} struct}{E = ellinit$(v,\{Domain\})$}
\leavevmode
Points are \kbd{[x,y]}, the origin is \kbd{[0]}.
Struct members accessed as \kbd{E.}\var{member}:\hfill\break
$\bullet$ All domains:
\kbd{E.a1},\kbd{a2},\kbd{a3},\kbd{a4},\kbd{a6},
\kbd{b2},\kbd{b4},\kbd{b6},\kbd{b8},
\kbd{c4},\kbd{c6}, \kbd{disc}, \kbd{j}\hfill\break
\li{$\bullet$ $E$ defined over $\RR$ or $\CC$}{}
\beginindentedkeys
\li{$x$-coords. of points of order $2$}{E.roots}
\li{periods / quasi-periods}{E.omega{,\rm }E.eta}
\li{volume of complex lattice}{E.area}
\endindentedkeys
\li{$\bullet$ $E$ defined over $\QQ_p$}{}
\beginindentedkeys
\li{residual characteristic}{E.p}
\li{If $|j|_p>1$: Tate's $[u^2, u, q, [a,b]]$}{E.tate}
\endindentedkeys
\li{$\bullet$ $E$ defined over $\FF_q$}{}
\beginindentedkeys
\li{characteristic}{E.p}
\li{$\#E(\FF_q)$/cyclic structure/generators}{E.no{\rm, }E.cyc{\rm, }E.gen}
\endindentedkeys
\li{$\bullet$ $E$ defined over $\QQ$}{}
\beginindentedkeys
\li{generators of $E(\QQ)$ (require \kbd{elldata})}{E.gen}
\endindentedkeys
\li{$[a_1,a_2,a_3,a_4,a_6]$ from $j$-invariant}{ellfromj$(j)$}
\li{change curve $E$ using $v=$\kbd{[}$u,r,s,t$\kbd{]}}{ellchangecurve$(E,v)$}
\li{change point $z$ using $v=$\kbd{[}$u,r,s,t$\kbd{]}}{ellchangepoint$(z,v)$}
\li{add points $P+Q$ / $P-Q$}{elladd$(E,P,Q)${\rm, }ellsub}
\li{negate point}{ellneg$(E,P)$}
\li{compute $n\cdot z$}{ellmul$(E,z,n)$}
\li{$n$-division polynomial $f_n(x)$}{elldivpol$(E,n,\{x\})$}
\li{check if $z$ is on $E$}{ellisoncurve$(E,z)$}
\li{order of torsion point $z$}{ellorder$(E,z)$}
\li{$y$-coordinates of point(s) for $x$}{ellordinate$(E,x)$}
\li{point $[\wp(z),\wp'(z)]$ corresp. to $z$}{ellztopoint$(E,z)$}
\li{complex $z$ such that $p=[\wp(z),\wp'(z)]$}{ellpointtoz$(E,p)$}

\subsec{Curves over finite fields, Pairings}
\li{random point on $E$}{random$(E)$}
\li{$\#E(\FF_q)$}{ellcard$(E)$}
\li{structure $\ZZ/d_1\ZZ\times \ZZ/d_2\ZZ$ of $E(\FF_q)$}{ellgroup$(E)$}
\li{Weil pairing of $m$-torsion pts $x,y$}{ellweilpairing$(E,x,y, m)$}
\li{Tate pairing of $x,y$; $x$ $m$-torsion}{elltatepairing$(E,x,y, m)$}
\li{Discrete log, find $n$ s.t. $P=[n]Q$}{elllog$(E,P,Q,\{ord\})$}

\subsec{Curves over $\QQ$ and the $L$-function}
\li{canonical bilinear form taken at $z_1$, $z_2$}{ellbil$(E,z_1,z_2)$}
\li{canonical height of $z$}{ellheight$(E,z,\{\fl\})$}
\li{height regulator matrix for pts in $x$}{ellheightmatrix$(E,x)$}
\li{cond, min mod, Tamagawa num \kbd{[}$N,v,c$\kbd{]}}{ellglobalred$(E)$}
\li{reduction of $y^2+Qy = P$ (genus $2$)}{genus2red$(Q,P,\{p\})$}
\li{Kodaira type of $p$-fiber of $E$}{elllocalred$(E,p)$}
\li{minimal model of $E/\QQ$} {ellminimalmodel$(E,\{$\&$v\})$}
\li{$p$-th coeff $a_p$ of $L$-function, $p$ prime}{ellap$(E,p)$}
\li{$k$-th coeff $a_k$ of $L$-function}{ellak$(E,k)$}
\li{vector of first $n$ $a_k$'s in $L$-function}{ellan$(E,n)$}
\li{$L(E,s)$}{elllseries$(E,s)$}
\li{$L^{(r)}(E,1)$}{ellL1$(E,r)$}
\li{return a Heegner point on $E$ of rank $1$}{ellheegner$(E)$}
\li{order of vanishing at $1$}{ellanalyticrank$(E,\{\var{eps}\})$}
\li{root number for $L(E,.)$ at $p$}{ellrootno$(E,\{p\})$}
\li{torsion subgroup with generators}{elltors$(E)$}
\li{modular parametrization of $E$}{elltaniyama$(E)$}
\shortcopyrightnotice

\subsec{Elldata package, Cremona's database:}
\li{db code $\leftrightarrow$ $[\var{conductor}, \var{class}, \var{index}]$}{ellconvertname$(s)$}
\li{generators of Mordell-Weil group}{ellgenerators$(E)$}
\li{look up $E$ in database}{ellidentify$(E)$}
\li{all curves matching criterion}{ellsearch$(N)$}
\li{loop over curves with cond.~from $a$ to $b$}{forell$(E, a,b,\seq)$}

\section{Elliptic \& Modular Functions}
$w = [\omega_1,\omega_2]$ or \var{ell} struct (\kbd{E.omega}), $\tau=\omega_1/\omega_2$.\hfill\break
%
\li{arithmetic-geometric mean}{agm$(x,y)$}
\li{elliptic $j$-function $1/q+744+\cdots$}{ellj$(x)$}
\li{Weierstrass $\sigma$/$\wp$/$\zeta$ function}
   {ellsigma$(w,z)${\rm, }ellwp{\rm, }ellzeta}
\li{periods/quasi-periods}{ellperiods$(E,\{\fl\})${\rm, }elleta$(w)$}
\li{$(2i\pi/\omega_2)^k E_k(\tau)$}{elleisnum$(w,k,\{\fl\})$}
\li{modified Dedekind $\eta$ func. $\prod(1-q^n)$}{eta$(x,\{\fl\})$}
\li{Jacobi sine theta function}{theta$(q,z)$}
\li{k-th derivative at z=0 of \kbd{theta}$(q,z)$}{thetanullk$(q,k)$}
\li{Weber's $f$ functions}{weber$(x,\{\fl\})$}
\li{Riemann's zeta $\zeta(s)=\sum n^{-s}$}{zeta$(s)$}
%
\bigskip
\section{Binary Quadratic Forms}
%
\li{create $ax^2+bxy+cy^2$ (distance $d$) }{Qfb$(a,b,c,\{d\})$}
\li{reduce $x$ ($s =\sqrt{D}$, $l=\floor{s}$)}
  {qfbred$(x,\{\fl\},\{D\},\{l\},\{s\})$}
\li{composition of forms}{$x$*$y$ {\rm or }qfbnucomp$(x,y,l)$}
\li{$n$-th power of form}{$x$\pow$n$ {\rm or }qfbnupow$(x,n)$}
\li{composition without reduction}{qfbcompraw$(x,y)$}
\li{$n$-th power without reduction}{qfbpowraw$(x,n)$}
\li{prime form of disc. $x$ above prime $p$}{qfbprimeform$(x,p)$}
\li{class number of disc. $x$}{qfbclassno$(x)$}
\li{Hurwitz class number of disc. $x$}{qfbhclassno$(x)$}
\li{Solve $Q(x,y) = p$ in integers, $p$ prime}{qfbsolve$(Q,p)$}

\section{Quadratic Fields}
%
\li{quadratic number $\omega=\sqrt x$ or $(1+\sqrt x)/2$}{quadgen$(x)$}
\li{minimal polynomial of $\omega$}{quadpoly$(x)$}
\li{discriminant of $\QQ(\sqrt{D})$}{quaddisc$(x)$}
\li{regulator of real quadratic field}{quadregulator$(x)$}
\li{fundamental unit in real $\QQ(x)$}{quadunit$(x)$}
\li{class group of $\QQ(\sqrt{D})$}{quadclassunit$(D,\{\fl\},\{t\})$}
\li{Hilbert class field of $\QQ(\sqrt{D})$}{quadhilbert$(D,\{\fl\})$}
\li{ray class field modulo $f$ of $\QQ(\sqrt{D})$}{quadray$(D,f,\{\fl\})$}
\bigskip

\section{General Number Fields: Initializations}
A number field $K$ is given by a monic irreducible $f\in\ZZ[X]$.\hfill\break
\li{init number field structure \var{nf}}{nfinit$(f,\{\fl\})$}
\subsec{nf members:}
\beginindentedkeys
\li{polynomial defining \var{nf}, $f(\theta)=0$}{\var{nf}.pol}
\li{number of real/complex places}{\var{nf}.r1/r2/sign}
\li{discriminant of \var{nf}}{\var{nf}.disc}
\li{$T_2$ matrix}{\var{nf}.t2}
\li{vector of roots of $f$}{\var{nf}.roots}
\li{integral basis of $\ZZ_K$ as powers of $\theta$}{\var{nf}.zk}
\li{different}{\var{nf}.diff}
\li{codifferent}{\var{nf}.codiff}
\li{index}{\var{nf}.index}
\endindentedkeys
\li{recompute \var{nf}\ using current precision}{nfnewprec$(nf)$}
\li{init relative \var{rnf}\ given by $g=0$ over $K$}{rnfinit$(\var{nf},g)$}
%
\li{init\var{bnf} structure}{bnfinit$(f,\{\fl\})$}
\subsec{bnf members: {\rm same as \var{nf}, plus}}
\beginindentedkeys
\li{underlying \var{nf}}{\var{bnf}.nf}
\li{classgroup}{\var{bnf}.clgp}
\li{regulator}{\var{bnf}.reg}
\li{fundamental units}{\var{bnf}.fu}
\li{torsion units}{\var{bnf}.tu}
\endindentedkeys
\li{compute a \var{bnf}\ from small \var{bnf}}{bnfinit$(\var{sbnf})$}
%
\li{add $S$-class group and units, yield \var{bnf} s}{bnfsunit$(\var{nf},S)$}
\li{init class field structure \var{bnr}}{bnrinit$(\var{bnf},m,\{\fl\})$}
%
\subsec{bnr members: {\rm same as \var{bnf}, plus}}
\beginindentedkeys
\li{underlying \var{bnf}}{\var{bnr}.bnf}
\li{big ideal structure}{\var{bnr}.bid}
\li{modulus}{\var{bnr}.mod}
\li{structure of $(\ZZ_K/m)^*$}{\var{bnr}.zkst}
\endindentedkeys
\medskip

\section{Basic Number Field Arithmetic (nf)}
Elements are \typ{INT}, \typ{FRAC}, \typ{POL}, \typ{POLMOD}, or \typ{COL} (on
integral basis \kbd{\var{nf}.zk}). Basic operations (prefix \kbd{nfelt}):
$($\kbd{nfelt}$)$\kbd{add}, \kbd{mul}, \kbd{pow}, \kbd{div}, \kbd{diveuc},
\kbd{mod}, \kbd{divrem}, \kbd{val}, \kbd{trace}, \kbd{norm} \hfill\break
%
\li{express $x$ on integer basis}{nfalgtobasis$(\var{nf},x)$}
\li{express element\ $x$ as a polmod}{nfbasistoalg$(\var{nf},x)$}
\li{reverse polmod $a=A(X)\mod T(X)$}{modreverse$(a)$}

\li{integral basis of field def. by $f=0$}{nfbasis$(f)$}
\li{field discriminant of field $f=0$}{nfdisc$(f)$}
\li{smallest poly defining $f=0$ (slow)}{polredabs$(f,\{\fl\})$}
\li{small poly defining $f=0$ (fast)}{polredbest$(f,\{\fl\})$}
\li{are fields $f=0$ and $g=0$ isomorphic?}{nfisisom$(f,g)$}
\li{is field $f=0$ a subfield of $g=0$?}{nfisincl$(f,g)$}
\li{compositum of $f=0$, $g=0$}{polcompositum$(f,g,\{\fl\})$}
\li{subfields (of degree $d$) of \var{nf}}{nfsubfields$(\var{nf},\{d\})$}
%
\li{roots of unity in \var{nf}}{nfrootsof1$(\var{nf}\,)$}
\li{roots of $g$ belonging to \var{nf}}{nfroots$(\{\var{nf}\},g)$}
\li{factor $g$ in \var{nf}}{nffactor$(\var{nf},g)$}
\li{factor $g$ mod prime $pr$ in \var{nf}}{nffactormod$(\var{nf},g,pr)$}
\li{conjugates of a root $\theta$ of \var{nf}}{nfgaloisconj$(\var{nf},\{\fl\})$}
\li{apply Galois automorphism $s$ to $x$}{nfgaloisapply$(\var{nf},s,x)$}
\li{quadratic Hilbert symbol (at $p$)}{nfhilbert$(\var{nf},a,b,\{p\})$}
%
\subsec{Linear and algebraic relations}
\li{poly of degree $\le k$ with root $x\in\CC$}{algdep$(x,k)$}
\li{alg. dep. with pol.~coeffs for series $s$}{seralgdep$(s,x,y)$}
\li{small linear rel.\ on coords of vector $x$}{lindep$(x)$}
\subsec{Dedekind Zeta Function $\zeta_K$, Hecke $L$ series}
\li{$\zeta_K$ as Dirichlet series, $N(I)<b$}{dirzetak$(\var{nf},b)$}
\li{init \var{nfz}\ for field $f=0$}{zetakinit$(f)$}
\li{compute $\zeta_K(s)$}{zetak$(\var{nfz},s,\{\fl\})$}
\li{Artin root number of $K$}{bnrrootnumber$(\var{bnr},\var{chi},\{\fl\})$}
\li{$L(1,\chi)$, for all $\chi$ trivial on $H$}{bnrL1$(\var{bnr},\{H\},\{\fl\})$}

\section{Class Groups \& Units (bnf, bnr)}
\leavevmode
$a_1,\{a_2\},\{a_3\}$ usually $bnr,subgp$ or $\var{bnf},module,\{subgp\}$
\hfill\break
%
\li{remove GRH assumption from \var{bnf}}{bnfcertify$(\var{bnf})$}
\li{expo.~of ideal $x$ on class gp}{bnfisprincipal$(\var{bnf},x,\{\fl\})$}
\li{expo.~of ideal $x$ on ray class gp}{bnrisprincipal$(\var{bnr},x,\{\fl\})$}
\li{expo.~of $x$ on fund.~units}{bnfisunit$(\var{bnf},x)$}
\li{as above for $S$-units}{bnfissunit$(\var{bnfs},x)$}
\li{signs of real embeddings of \kbd{\var{bnf}.fu}}{bnfsignunit$(\var{bnf})$}
\li{narrow class group}{bnfnarrow$(\var{bnf})$}
%
\subsec{Class Field Theory}
\li{ray class number for mod.~$m$}{bnrclassno$(\var{bnf},m)$}
\li{discriminant of class field ext}{bnrdisc$(a_1,\{a_2\},\{a_3\})$}
\li{ray class numbers, $l$ list of mods}{bnrclassnolist$(\var{bnf},l)$}
\li{discriminants of class fields}{bnrdisclist$(\var{bnf},l,\{arch\},\{\fl\})$}
\li{decode output from \kbd{bnrdisclist}}{bnfdecodemodule$(\var{nf},fa)$}
\li{is modulus the conductor?}{bnrisconductor$(a_1,\{a_2\},\{a_3\})$}
\li{conductor of character $chi$}{bnrconductorofchar$(\var{bnr},chi)$}
\li{conductor of extension}{bnrconductor$(a_1,\{a_2\},\{a_3\},\{\fl\})$}
\li{conductor of extension def.\ by $g$}{rnfconductor$(\var{bnf},g)$}
\li{Artin group of ext.\ def'd by $g$}{rnfnormgroup$(\var{bnr},g)$}
\li{subgroups of \var{bnr}, index $<=b$}{subgrouplist$(\var{bnr},b,\{\fl\})$}
\li{rel.\ eq.\ for class field def'd by $sub$}{rnfkummer$(\var{bnr},sub,\{d\})$}
\li{same, using Stark units (real field)}{bnrstark$(\var{bnr},sub,\{\fl\})$}

\section{Ideals: {\rm elements, primes, or matrix of generators in HNF}}
\li{is $id$ an ideal in \var{nf} ?}{nfisideal$(\var{nf},id)$}
\li{is $x$ principal in \var{bnf} ?}{bnfisprincipal$(\var{bnf},x)$}
\li{give {\tt [}$a,b${\tt ]}, s.t.~ $a\ZZ_K+b\ZZ_K = x$}{idealtwoelt$(\var{nf},x,\{a\})$}
\li{put ideal $a$ ($a\ZZ_K+b\ZZ_K$) in HNF form}{idealhnf$(\var{nf},a,\{b\})$}
\li{norm of ideal $x$}{idealnorm$(\var{nf},x)$}
\li{minimum of ideal $x$ (direction $v$)}{idealmin$(\var{nf},x,v)$}
\li{LLL-reduce the ideal $x$ (direction $v$)}{idealred$(\var{nf},x,\{v\})$}
%
\subsec{Ideal Operations}
\li{add ideals $x$ and $y$}{idealadd$(\var{nf},x,y)$}
\li{multiply ideals $x$ and $y$}{idealmul$(\var{nf},x,y,\{\fl\})$}
\li{intersection of ideals $x$ and $y$}{idealintersect$(\var{nf},x,y,\{\fl\})$}
\li{$n$-th power of ideal $x$}{idealpow$(\var{nf},x,n,\{\fl\})$}
\li{inverse of ideal $x$}{idealinv$(\var{nf},x)$}
\li{divide ideal $x$ by $y$}{idealdiv$(\var{nf},x,y,\{\fl\})$}
\li{Find $(a,b)\in x\times y$, $a+b=1$}{idealaddtoone$(\var{nf},x,\{y\})$}
\li{coprime integral $A,B$ such that $x=A/B$}{idealnumden$(\var{nf},x)$}
%
\subsec{Primes and Multiplicative Structure}
\li{factor ideal $x$ in \var{nf}}{idealfactor$(\var{nf},x)$}
\li{expand ideal factorization in \var{nf}}{idealfactorback$(nf,f,{e})$}
\li{decomposition of prime $p$ in \var{nf}}{idealprimedec$(\var{nf},p)$}
\li{valuation of $x$ at prime ideal $pr$}{idealval$(\var{nf},x,pr)$}
\li{weak approximation theorem in \var{nf}}{idealchinese$(\var{nf},x,y)$}
\li{give $bid=$structure of $(\ZZ_K/id)^*$}{idealstar$(\var{nf},id,\{\fl\})$}
\li{discrete log of $x$ in $(\ZZ_K/bid)^*$}{ideallog$(\var{nf},x,bid)$}
\li{\kbd{idealstar} of all ideals of norm $\le b$}{ideallist$(\var{nf},b,\{\fl\})$}
\li{add Archimedean places}{ideallistarch$(\var{nf},b,\{ar\},\{\fl\})$}
\li{init \kbd{prmod} structure}{nfmodprinit$(\var{nf},pr)$}
\li{kernel of matrix $M$ in $(\ZZ_K/pr)^*$}{nfkermodpr$(\var{nf},M,prmod)$}
\li{solve $M x = B$ in $(\ZZ_K/pr)^*$}{nfsolvemodpr$(\var{nf},M,B,prmod)$}

\section{Galois theory over $\QQ$}
\li{Galois group of field $\QQ[x]/(f)$}{polgalois$(f)$}
\li{initializes a Galois group structure $G$}{galoisinit$(\var{pol},\{den\})$}
\li{action of $p$ in nfgaloisconj form}{galoispermtopol$(G,\{p\})$}
\li{identify as abstract group}{galoisidentify$(G)$}
\li{export a group for GAP/MAGMA}{galoisexport$(G,\{\fl\})$}
\li{subgroups of the Galois group $G$}{galoissubgroups$(G)$}
\li{is subgroup $H$ normal?}{galoisisnormal$(G,H)$}
\li{subfields from subgroups}{galoissubfields$(G,\{\fl\},\{v\})$}
\li{fixed field}{galoisfixedfield$(G,\var{perm},\{\fl\},\{v\})$}
\li{Frobenius at maximal ideal $P$}{idealfrobenius$(\var{nf},G,P)$}
\li{ramification groups at $P$}{idealramgroups$(\var{nf},G,P)$}

\newcolumn
\title{PARI-GP Reference Card (2)}
\centerline{(PARI-GP version \PARIversion)}
\medskip

\li{is $G$ abelian?}{galoisisabelian$(G,\{\fl\})$}
\li{abelian number fields/$\QQ$}{galoissubcyclo(N,H,\{\fl\},\{v\})}
\li{query the \kbd{galpol} package}{galoisgetpol(a,b,\{s\})}

\section{Relative Number Fields (rnf)}
Extension $L/K$ is defined by $T\in K[x]$.
\hfill\break
%
\li{absolute equation of $L$}{rnfequation$(\var{nf},T,\{\fl\})$}
\li{is $L/K$ abelian?}{rnfisabelian$(\var{nf},T)$}
\li{relative {\tt nfalgtobasis}}{rnfalgtobasis$(\var{rnf},x)$}
\li{relative {\tt nfbasistoalg}}{rnfbasistoalg$(\var{rnf},x)$}
\li{relative {\tt idealhnf}}{rnfidealhnf$(\var{rnf},x)$}
\li{relative {\tt idealmul}}{rnfidealmul$(\var{rnf},x,y)$}
\li{relative {\tt idealtwoelt}}{rnfidealtwoelt$(\var{rnf},x)$}
%
\subsec{Lifts and Push-downs}
\li{absolute $\rightarrow$ relative repres.\ for $x$}
  {rnfeltabstorel$(\var{rnf},x)$}
\li{relative $\rightarrow$ absolute repres.\ for $x$}
  {rnfeltreltoabs$(\var{rnf},x)$}
\li{lift $x$ to the relative field}{rnfeltup$(\var{rnf},x)$}
\li{push $x$ down to the base field}{rnfeltdown$(\var{rnf},x)$}
\leavevmode idem for $x$ ideal:
\kbd{$($rnfideal$)$reltoabs}, \kbd{abstorel}, \kbd{up}, \kbd{down}\hfill
%
\subsec{Norms}
\li{absolute norm of ideal $x$}{rnfidealnormabs$(\var{rnf},x)$}
\li{relative norm of ideal $x$}{rnfidealnormrel$(\var{rnf},x)$}
\li{solutions of $N_{K/\QQ}(y)=x\in \ZZ$}{bnfisintnorm$(\var{bnf},x)$}
\li{is $x\in\QQ$ a norm from $K$?}{bnfisnorm$(\var{bnf},x,\{\fl\})$}
\li{initialize $T$ for norm eq.~solver}{rnfisnorminit$(K,pol,\{\fl\})$}
\li{is $a\in K$ a norm from $L$?}{rnfisnorm$(T,a,\{\fl\})$}
%
\subsec{Maximal order $\ZZ_L$ as a $\ZZ_K$-module}
\li{relative {\tt polred}}{rnfpolred$(\var{nf},T)$}
\li{relative {\tt polredabs}}{rnfpolredabs$(\var{nf},T)$}
\li{characteristic poly.\ of $a$ mod $T$}{rnfcharpoly$(\var{nf},T,a,\{v\})$}
\li{relative Dedekind criterion, prime $pr$}{rnfdedekind$(\var{nf},T,pr)$}
\li{discriminant of relative extension}{rnfdisc$(\var{nf},T)$}
\li{pseudo-basis of $\ZZ_L$}{rnfpseudobasis$(\var{nf},T)$}
%
\subsec{General $\ZZ_K$-modules:
  {\rm $M = [{\rm matrix}, {\rm vec.~of~ideals}] \subset L$}}
\li{relative HNF / SNF}{nfhnf$(\var{nf},M)${\rm, }nfsnf}
\li{reduced basis for $M$}{rnflllgram$(\var{nf},T,M)$}
\li{determinant of pseudo-matrix $M$}{rnfdet$(\var{nf},M)$}
\li{Steinitz class of $M$}{rnfsteinitz$(\var{nf},M)$}
\li{$\ZZ_K$-basis of $M$ if $\ZZ_K$-free, or $0$}{rnfhnfbasis$(\var{bnf},M)$}
\li{$n$-basis of $M$, or $(n+1)$-generating set}{rnfbasis$(\var{bnf},M)$}
\li{is $M$ a free $\ZZ_K$-module?}{rnfisfree$(\var{bnf},M)$}
\newpage

\section{Graphic Functions}
\li{crude graph of \expr\ between $a$ and $b$}{plot$(X\,$=$\;a,b,expr)$}
\subsec{High-resolution plot {\rm (immediate plot)}}
\li{plot \expr\ between $a$ and $b$}{ploth$(X\,$=$\;a,b,expr,\{\fl\},\{n\})$}
\li{plot points given by lists $lx$, $ly$}{plothraw$(lx,ly,\{\fl\})$}
\li{terminal dimensions}{plothsizes$()$}
%
\subsec{Rectwindow functions}
\li{init window $w$, with size $x$,$y$}{plotinit$(w,x,y)$}
\li{erase window $w$}{plotkill$(w)$}
\li{copy $w$ to $w_2$ with offset $(dx,dy)$}{plotcopy$(w,w_2,dx,dy)$}
\li{clips contents of $w$}{plotclip$(w)$}
\li{scale coordinates in $w$}{plotscale$(w,x_1,x_2,y_1,y_2)$}
\li{\kbd{ploth} in $w$}{plotrecth$(w,X\,$=$\;a,b,expr,\{\fl\},\{n\})$}
\li{\kbd{plothraw} in $w$}{plotrecthraw$(w,data,\{\fl\})$}
\li{draw window $w_1$ at $(x_1,y_1)$, \dots} {plotdraw$($[[$w_1,x_1,y_1$]$,\dots$]$)$}
%
\subsec{Low-level Rectwindow Functions}
%\li{}{plotlinetype$(w,)$}
%\li{}{plotpointtype$(w,)$}
%\li{}{plotterm$(w,)$}
\li{set current drawing color in $w$ to $c$}{plotcolor$(w,c)$}
\li{current position of cursor in $w$}{plotcursor$(w)$}
%
\li{write $s$ at cursor's position}{plotstring$(w,s)$}
\li{move cursor to $(x,y)$}{plotmove$(w,x,y)$}
\li{move cursor to $(x+dx,y+dy)$}{plotrmove$(w,dx,dy)$}
\li{draw a box to $(x_2,y_2)$}{plotbox$(w,x_2,y_2)$}
\li{draw a box to $(x+dx,y+dy)$}{plotrbox$(w,dx,dy)$}
\li{draw polygon}{plotlines$(w,lx,ly,\{\fl\})$}
\li{draw points}{plotpoints$(w,lx,ly)$}
\li{draw line to $(x+dx,y+dy)$}{plotrline$(w,dx,dy)$}
\li{draw point $(x+dx,y+dy)$}{plotrpoint$(w,dx,dy)$}
\li{draw point $(x+dx,y+dy)$}{plotrpoint$(w,dx,dy)$}
%
\subsec{Postscript Functions}
\li{as {\tt ploth}}{psploth$(X\,$=$\;a,b,expr,\{\fl\},\{n\})$}
\li{as {\tt plothraw}}{psplothraw$(lx,ly,\{\fl\})$}
\li{as {\tt plotdraw}}{psdraw$($[[$w_1,x_1,y_1$]$,\dots$]$)$}
\vfill
\copyrightnotice
\bye
% Local variables:
% compile-command: "tex PARIRefCard"
% End:
