Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
% Copyright (c) 2007-2016 Karim Belabas.1% Permission is granted to copy, distribute and/or modify this document2% under the terms of the GNU General Public License34% Reference Card for PARI-GP.5% Author:6% Karim Belabas7% Universite de Bordeaux, 351 avenue de la Liberation, F-33405 Talence8% email: [email protected]9%10% Based on an earlier version by Joseph H. Silverman who kindly let me11% use his original file.12% Thanks to Bill Allombert, Henri Cohen, Gerhard Niklasch, and Joe Silverman13% for comments and corrections.14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%15% The original copyright notice read:16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%17%% Copyright (c) 1993,1994 Joseph H. Silverman. May be freely distributed.18%% Created Tuesday, July 27, 199319%% Thanks to Stephen Gildea for the multicolumn macro package20%% which I modified from his GNU emacs reference card21%%22%% Original Thanks:23%% I would like to thank Jim Delaney, Kevin Buzzard, Dan Lieman,24%% and Jaap Top for sending me corrections.25%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%26% This file is intended to be processed by plain TeX (TeX82).27\def\TITLE{Pari-GP reference card}28\input refmacro.tex2930Note: optional arguments are surrounded by braces $\{\}$.\hfill\break31To start the calculator, type its name in the terminal: \kbd{gp}\hfill\break32To exit \kbd{gp}, type \kbd{quit}, \kbd{\\q}, or \kbd{<C-D>} at prompt.\hfill33\section{Help}34\li{describe function}{?{\it function}}35\li{extended description}{??{\it keyword}}36\li{list of relevant help topics}{???{\it pattern}}37\li{name of GP-1.39 function $f$ in GP-2.*}{whatnow$(f)$}3839\section{Input/Output}40\li{previous result, the result before}41{\%{\rm, }\%\`{}{\rm, }\%\`{}\`{}{\rm, etc.}}42\li{$n$-th result since startup}{\%$n$}43\li{separate multiple statements on line}{;}44\li{extend statement on additional lines}{\\}45\li{extend statements on several lines}{\{$\seq_1$; $\seq_2$;\}}46\li{comment}{/* $\dots$ */}47\li{one-line comment, rest of line ignored}{\\\\ \dots}4849\section{Metacommands \& Defaults}50\li{set default $d$ to \var{val}} {default$(\{d\},\{\var{val}\})$}51\li{toggle timer on/off}{\#}52\li{print time for last result}{\#\#}53\li{print defaults}{\\d}54\li{set debug level to $n$}{\\g $n$}55\li{set memory debug level to $n$}{\\gm $n$}56\li{set $n$ significant digits / bits}{\\p $n$, \\pb $n$}57\li{set $n$ terms in series}{\\ps $n$}58\li{quit GP}{\\q}59\li{print the list of PARI types}{\\t}60\li{print the list of user-defined functions}{\\u}61\li{read file into GP}{\\r {\it filename}}62\li{set debuglevel for domain $D$ to $n$}{setdebug$(D,n)$}6364\section{Debugger / break loop}65\li{get out of break loop}{break {\rm or} <C-D>}66\li{go up/down $n$ frames}{dbg\_up$(\{n\})${\rm, }dbg\_down}67\li{set break point}{breakpoint$()$}68\li{examine object $o$}{dbg\_x$(o)$}69\li{current error data}{dbg\_err$()$}70\li{number of objects on heap and their size}{getheap$()$}71\li{total size of objects on PARI stack}{getstack$()$}7273\section{PARI Types \& Input Formats}74\li{\typ{INT}. Integers; hex, binary}{$\pm 31$; $\pm $0x1F, $\pm$0b101}75\li{\typ{REAL}. Reals}{$\pm 3.14$, $6.022$ E$23$}76\li{\typ{INTMOD}. Integers modulo $m$}{Mod$(n,m)$}77\li{\typ{FRAC}. Rational Numbers}{$n/m$}78\li{\typ{FFELT}. Elt in finite field $\FF_q$}{ffgen($q$,\text{'t})}79\li{\typ{COMPLEX}. Complex Numbers}{$x +y\,*\;$I}80\li{\typ{PADIC}. $p$-adic Numbers}{$x\;+\;$O$(p$\pow$k)$}81\li{\typ{QUAD}. Quadratic Numbers}{$x + y\,*\;$quadgen($D$,\{'w\})}82\li{\typ{POLMOD}. Polynomials modulo $g$}{Mod$(f,g)$}83\li{\typ{POL}. Polynomials}{$a*x$\pow$n+\cdots+b$}84\li{\typ{SER}. Power Series}{$f\;+\;$O$(x$\pow$k)$}85\li{\typ{RFRAC}. Rational Functions}{$f/g$}86\li{\typ{QFB}. Binary quadratic form}{Qfb$(a,b,c)$}87\li{\typ{VEC}/\typ{COL}. Row/Column Vectors}88{[$x,y,z$]{\rm, }[$x,y,z$]\til}89\li{\typ{VEC} integer range}{[1..10]}9091% This goes at the bottom of page 192\shortcopyrightnotice93\newcolumn9495\li{\typ{VECSMALL}. Vector of small ints}{Vecsmall([$x,y,z$])}96\li{\typ{MAT}. Matrices}{[$a,b$;$c,d$]}97\li{\typ{LIST}. Lists}{List$($[$x,y,z$]$)$}98\li{\typ{STR}. Strings}{"abc"}99\li{\typ{INFINITY}. $\pm\infty$}{+oo, -oo}100101\section{Reserved Variable Names}102\li{$\pi\approx3.14$, $\gamma\approx0.57$, $C\approx0.91$, $I = \sqrt{-1}$}103{Pi{\rm, }Euler{\rm, }Catalan{\rm, }I}104\li{Landau's big-oh notation}{O}105106\section{Information about an Object, Precision}107\li{PARI type of object $x$}{type$(x)$}108\li{length of $x$ / size of $x$ in memory}{\#$x${\rm, }sizebyte$(x)$}109\li{real precision / bit precision of $x$}{precision$(x)${\rm, }bitprecision$(x)$}110\li{$p$-adic, series prec. of $x$}{padicprec$(x,p)${\rm, }serprec$(x,v)$}111\li{current dynamic precision}{getlocalprec{\rm, }getlocalbitprec}112113\section{Operators}114\li{basic operations}{+{\rm,} - {\rm,} *{\rm,} /{\rm,} \pow{\rm,} sqr}115\li{\kbd{i$\leftarrow$i+1}, \kbd{i$\leftarrow$i-1}, \kbd{i$\leftarrow$i*j}, \dots}116{i++{\rm,} i--{\rm,} i*=j{\rm,}\dots}117\li{Euclidean quotient, remainder}{$x$\bs/$y${\rm,} $x$\bs$y${\rm,}118$x$\%$y${\rm,} divrem$(x,y)$}119\li{shift $x$ left or right $n$ bits}{ $x$<<$n$, $x$>>$n$120{\rm or} shift$(x,\pm n)$}121\li{multiply by $2^n$}{shiftmul$(x,n)$}122\li{comparison operators}123{<={\rm, }<{\rm, }>={\rm, }>{\rm, }=={\rm, }!={\rm, }==={\rm, }lex{\rm, }cmp}124\li{boolean operators (or, and, not)}{||{\rm, } \&\&{\rm ,} !}125\li{bit operations}126{bitand{\rm, }bitneg{\rm, }bitor{\rm, }bitxor{\rm, }bitnegimply}127\li{maximum/minimum of $x$ and $y$}{max$(x,y)${\rm,} min$(x,y)$}128\li{sign of $x$ (gives $-1,0,1$)}{sign$(x)$}129\li{binary exponent of $x$}{exponent$(x)$}130\li{derivative of $f$, 2nd derivative, etc.}{$f$', $f$'', \dots}131\li{differential operator}{diffop$(f,v,d,\{n=1\})$}132\li{quote operator (formal variable)}{'x}133\li{assignment}{x = \var{value}}134\li{simultaneous assignment $x\leftarrow v[1]$, $y\leftarrow v[2]$}{[x,y] = v}135\section{Select Components}136\emph{Caveat:} components start at index $n = 1$.\hfil\break137\li{$n$-th component of $x$}{component$(x,n)$}138\li{$n$-th component of vector/list $x$}{$x$[$n$]}139\li{components $a,a+1,\dots,b$ of vector $x$}{$x$[$a$..$b$]}140\li{$(m,n)$-th component of matrix $x$}{$x$[$m,n$]}141\li{row $m$ or column $n$ of matrix $x$}{$x$[$m,$]{\rm,} $x$[$,n$]}142\li{numerator/denominator of $x$}{numerator$(x)${\rm, }denominator$(x)$}143144\section{Random Numbers}145\li{random integer/prime in $[0,N[$}{random$(N)${\rm, }randomprime$(N)$}146\li{get/set random seed}{getrand{\rm, }setrand$(s)$}147148\section{Conversions}149\li{to vector, matrix, vec. of small ints}{Col{\rm/}Vec{\rm,}Mat{\rm,}Vecsmall}150\li{to list, set, map, string}{List{\rm,} Set{\rm,} Map{\rm,} Str}151\li{create $(x\mod y)$}{Mod$(x,y)$}152\li{make $x$ a polynomial of $v$}{Pol$(x,\{v\})$}153\li{variants of \kbd{Pol} \emph{et al.}, in reverse order}154{Polrev{\rm, }Vecrev{\rm, }Colrev}155\li{make $x$ a power series of $v$}{Ser$(x,\{v\})$}156\li{convert $x$ to simplest possible type}{simplify$(x)$}157\li{object $x$ with real precision $n$}{precision$(x,n)$}158\li{object $x$ with bit precision $n$}{bitprecision$(x,n)$}159\li{set precision to $p$ digits in dynamic scope}{localprec$(p)$}160\li{set precision to $p$ bits in dynamic scope}{localbitprec$(p)$}161162\subsec{Character strings}163164\li{convert to TeX representation}{strtex$(x)$}165\li{string from bytes / from format+args}{strchr{\rm, }strprintf}166\li{split string / join strings}{strsplit{\rm, }strjoin}167\li{convert time $t$ ms. to h, m, s, ms format}{strtime$(t)$}168169\subsec{Conjugates and Lifts}170\li{conjugate of a number $x$}{conj$(x)$}171\li{norm of $x$, product with conjugate}{norm$(x)$}172\li{$L^p$ norm of $x$ ($L^\infty$ if no $p$)}{normlp$(x,\{p\})$}173\li{square of $L^2$ norm of $x$}{norml2$(x)$}174\li{lift of $x$ from Mods and $p$-adics}{lift{\rm,} centerlift$(x)$}175\li{recursive lift}{liftall}176\li{lift all \typ{INT} and \typ{PADIC} ($\to$\typ{INT})}{liftint}177\li{lift all \typ{POLMOD} ($\to$\typ{POL})}{liftpol}178179\section{Lists, Sets \& Maps}180{\bf Sets} (= row vector with strictly increasing entries w.r.t. \kbd{cmp})\hfill\break181%182\li{intersection of sets $x$ and $y$}{setintersect$(x,y)$}183\li{set of elements in $x$ not belonging to $y$}{setminus$(x,y)$}184\li{union of sets $x$ and $y$}{setunion$(x,y)$}185\li{does $y$ belong to the set $x$}{setsearch$(x,y,\{\fl\})$}186\li{set of all $f(x,y)$, $x\in X$, $y\in Y$}{setbinop$(f,X,Y)$}187\li{is $x$ a set ?}{setisset$(x)$}188189\subsec{Lists. {\rm create empty list: $L$ = \kbd{List}$()$}}190\li{append $x$ to list $L$}{listput$(L,x,\{i\})$}191\li{remove $i$-th component from list $L$}{listpop$(L,\{i\})$}192\li{insert $x$ in list $L$ at position $i$}{listinsert$(L,x,i)$}193\li{sort the list $L$ in place}{listsort$(L,\{\fl\})$}194195\subsec{Maps. {\rm create empty dictionary: $M$ = \kbd{Map}$()$}}196\li{attach value $v$ to key $k$}{mapput$(M,k,v)$}197\li{recover value attach to key $k$ or error}{mapget$(M,k)$}198\li{is key $k$ in the dict? (set $v$ to $M(k)$)}199{mapisdefined$(M,k,\{\&v\})$}200\li{remove $k$ from map domain}{mapdelete$(M,k)$}201202\section{GP Programming}203\subsec{User functions and closures}204$x,y$ are formal parameters; $y$ defaults to \kbd{Pi} if parameter omitted;205$z,t$ are local variables (lexical scope), $z$ initialized to 1.206\hfil\break207{\tt fun(x, y=Pi) = my(z=1, t); \var{seq}\hfil\break}208{\tt fun = (x, y=Pi) -> my(z=1, t); \var{seq}\hfill\break}209\li{attach help message $h$ to $s$}{addhelp$(s,h)$}210\li{undefine symbol $s$ (also kills help)}{kill$(s)$}211\subsec{Control Statements {\rm ($X$: formal parameter in expression \seq)}}212\li{if $a\ne0$, evaluate $\seq_1$, else $\seq_2$}{if$(a,\{\seq_1\},\{\seq_2\})$}213\smallskip214215\li{eval.\ \seq\ for $a\le X\le b$}{for$(X=a,b,\seq)$}216\li{\dots for $X\in v$}{foreach$(v,X,\seq)$}217\li{\dots for primes $a\le X\le b$}{forprime$(X=a,b,\seq)$}218\li{\dots for primes $\equiv a \pmod{q}$}{forprimestep$(X=a,b,q,\seq)$}219\li{\dots for composites $a\le X\le b$}{forcomposite$(X=a,b,\seq)$}220\li{\dots for $a\le X\le b$ stepping $s$}{forstep$(X=a,b,s,\seq)$}221\li{\dots for $X$ dividing $n$}{fordiv$(n,X,\seq)$}222\li{\dots $X=[n,\kbd{factor}(n)]$, $a\le n\le b$}{forfactored$(X=a,b,\seq)$}223\li{\dots as above, $n$ squarefree}{forsquarefree$(X=a,b,\seq)$}224\li{\dots $X=[d,\kbd{factor}(d)]$, $d\mid n$}{fordivfactored$(n,X,\seq)$}225\li{multivariable {\tt for}, lex ordering}{forvec$(X=v,\seq)$}226\newcolumn227\li{loop over partitions of $n$}{forpart$(p=n,\seq)$}228\li{\dots permutations of $S$}{forperm$(S, p,\seq)$}229\li{\dots subsets of $\{1,\ldots,n\}$}{forsubset$(n, p,\seq)$}230\li{\dots $k$-subsets of $\{1,\ldots,n\}$}{forsubset$([n,k], p,\seq)$}231\li{\dots vectors $v$, $q(v)\leq B$; $q > 0$}{forqfvec$(v, q, b, \seq)$}232\li{\dots $H < G$ finite abelian group}{forsubgroup$(H=G)$}233\li{evaluate \seq\ until $a\ne0$}{until$(a,\seq)$}234\li{while $a\ne0$, evaluate \seq}{while$(a,\seq)$}235\li{exit $n$ innermost enclosing loops}{break$(\{n\})$}236\li{start new iteration of $n$-th enclosing loop}{next$(\{n\})$}237\li{return $x$ from current subroutine}{return$(\{x\})$}238239\subsec{Exceptions, warnings}240\li{raise an exception / warning}{error$()$, warning$()$}241\li{type of error message $E$}{errname$(E)$}242\li{try $\seq_1$, evaluate $\seq_2$ on error}{iferr$(\seq_1, E, \seq_2)$}243244\subsec{Functions with closure arguments / results}245\li{number of arguments of $f$}{arity$(f)$}246\li{select from $v$ according to $f$}{select$(f, v)$}247\li{apply $f$ to all entries in $v$}{apply$(f, v)$}248\li{evaluate $f(a_1,\dots,a_n)$}{call$(f,a)$}249\li{evaluate $f(\dots f(f(a_1,a_2),a_3)\dots,a_n)$}{fold$(f,a)$}250\li{calling function as closure}{self$()$}251252\subsec{Sums \& Products}253\li{sum $X=a$ to $X=b$, initialized at $x$}{sum$(X=a,b,\expr,\{x\})$}254\li{sum entries of vector $v$}{vecsum$(v)$}255\li{product of all vector entries}{vecprod$(v)$}256\li{sum \expr\ over divisors of $n$}{sumdiv$(n,X,\expr)$}257\li{\dots assuming \expr\ multiplicative}{sumdivmult$(n,X,\expr)$}258\li{product $a\le X\le b$, initialized at $x$}{prod$(X=a,b,\expr,\{x\})$}259\li{product over primes $a\le X\le b$}{prodeuler$(X=a,b,\expr)$}260261\subsec{Sorting}262\li{sort $x$ by $k$-th component}{vecsort$(x,\{k\},\{fl=0\})$}263\li{min.~$m$ of $x$ ($m=x[i]$), max.}{vecmin$(x,\{\&i\})${\rm, }vecmax}264\li{does $y$ belong to $x$, sorted wrt. $f$}{vecsearch$(x,y,\{f\})$}265\li{$\prod g^x \rightarrow$ factorization266($\Rightarrow$ sorted, unique $g$)} {matreduce$(m)$}267%268269\subsec{Input/Output}270\li{print with/without \kbd{\bs n}, \TeX\ format}271{print{\rm, }print1{\rm, }printtex}272\li{pretty print matrix}{printp}273\li{print fields with separator}{printsep$(\var{sep},\dots)$,{\rm, }printsep1}274\li{formatted printing}{printf$()$}275\li{write \args\ to file}{write{\rm,} write1{\rm,} writetex$(\file,\args)$}276\li{write $x$ in binary format}{writebin$(\file,x)$}277\li{read file into GP}{read($\{\file\}$)}278\li{\dots return as vector of lines}{readvec($\{\file\}$)}279\li{\dots return as vector of strings}{readstr($\{\file\}$)}280\li{read a string from keyboard}{input$()$}281282\subsec{Files and file descriptors}283File descriptors allow efficient small consecutive reads284or writes from or to a given file. The argument $n$ below is always a285descriptor, attached to a file in \kbd{r}(ead), \kbd{w}(rite) or \kbd{a}(ppend)286mode.\hfil\break287\li{get descriptor $n$ for file \var{path} in given \var{mode}}288{fileopen$(\var{path},\var{mode})$}289\li{\dots from shell \var{cmd} output (pipe)}{fileextern$(\var{cmd})$}290\smallskip291\li{close descriptor}{fileclose$(n)$}292\li{commit pending write operations}{fileflush($n$)}293\li{read logical line from file}{fileread$(n)$}294\li{\dots raw line from file}{filereadstr$(n)$}295\li{write $s$\kbd{\bs n} to file}{filewrite$(n, s)$}296\li{\dots write $s$ to file}{filewrite1$(n, s)$}297\newcolumn298299\title{\TITLE}300\centerline{(PARI-GP version \PARIversion)}301302\subsec{Timers}303\li{CPU time in \var{ms} and reset timer}{gettime$()$}304\li{CPU time in \var{ms} since gp startup}{getabstime$()$}305\li{time in \var{ms} since UNIX Epoch}{getwalltime$()$}306\li{timeout command after $s$ seconds}{alarm$(s, \expr)$}307308\subsec{Interface with system}309\li{allocates a new stack of $s$ bytes}{allocatemem$(\{s\})$}310\li{alias \var{old}\ to \var{new}}{alias$(\var{new},\var{old})$}311\li{install function from library}{install$(f,code,\{\var{gpf\/}\},\{\var{lib}\})$}312\li{execute system command $a$}{system$(a)$}313\li{\dots and feed result to GP}{extern$(a)$}314\li{\dots returning GP string}{externstr$(a)$}315316\li{get \kbd{\$VAR} from environment}{getenv$($\kbd{"VAR"}$)$}317\li{expand env. variable in string}{strexpand$(x)$}318319\section{Parallel evaluation}320These functions evaluate their arguments in parallel (pthreads or MPI);321args.~must not access global variables (use \kbd{export} for this) and322must be free of side effects. Enabled if threading engine is not \emph{single}323in gp header.\hfil\break324\li{evaluate $f$ on $x[1],\dots,x[n]$}{parapply$(f,x)$}325\li{evaluate closures $f[1],\dots,f[n]$}{pareval$(f)$}326\li{as \kbd{select}}{parselect$(f,A,\{\fl\})$}327\li{as \kbd{sum}}{parsum$(i = a,b,\var{expr})$}328\li{as \kbd{vector}}{parvector$(n,i,\{\var{expr}\})$}329\li{eval $f$ for $i=a,\dots,b$}330{parfor$(i = a, \{b\}, f,\{r\}, \{f_2\})$}331\li{\dots for each element $x$ in $v$}332{parforeach$(v, x, f,\{r\}, \{f_2\})$}333\li{\dots for $p$ prime in $[a,b]$}334{parforprime$(p = a, \{b\}, f,\{r\}, \{f_2\})$}335\li{\dots for $p = a \mod q$}336{parforprimestep$(p = a, \{b\}, q, f,\{r\}, \{f_2\})$}337\li{\dots multivariate}338{parforvec$(X = v, f,\{r\}, \{f_2\}, \{\fl\})$}339\li{export $x$ to parallel world}{export$(x)$}340\li{\dots all dynamic variables}{exportall$()$}341\li{frees exported value $x$}{unexport$(x)$}342\li{\dots all exported values}{unexportall$()$}343344\section{Linear Algebra}345%346\li{dimensions of matrix $x$}{matsize$(x)$}347\li{multiply two matrices}{$x$ * $y$}348\li{\dots assuming result is diagonal}{matmultodiagonal$(x,y)$}349\li{concatenation of $x$ and $y$}{concat$(x,\{y\})$}350\li{extract components of $x$}{vecextract$(x,y,\{z\})$}351\li{transpose of vector or matrix $x$}{$x$\til, mattranspose$(x)$}352\li{adjoint of the matrix $x$}{matadjoint$(x)$}353\li{eigenvectors/values of matrix $x$}{mateigen$(x)$}354\li{characteristic/minimal polynomial of $x$}{charpoly$(x)${\rm, }minpoly$(x)$}355\li{trace/determinant of matrix $x$}{trace$(x)${\rm, }matdet$(x)$}356\li{permanent of matrix $x$}{matpermanent$(x)$}357\li{Frobenius form of $x$}{matfrobenius$(x)$}358\li{QR decomposition}{matqr$(x)$}359\li{apply \kbd{matqr}'s transform to $v$}{mathouseholder$(Q,v)$}360361\subsec{Constructors \& Special Matrices}362\li{$\{g(x)\colon x \in v~{\rm s.t.}~f(x)\}$}{[g(x) | x <- v, f(x)]}363\li{$\{x\colon x \in v~{\rm s.t.}~f(x)\}$}{[x | x <- v, f(x)]}364\li{$\{g(x)\colon x \in v\}$}{[g(x) | x <- v]}365366\li{row vec.\ of \expr\ eval'ed at $1\le i\le n$}{vector$(n,\{i\},\{\expr\})$}367\li{col.\ vec.\ of \expr\ eval'ed at $1\le i\le n$}{vectorv$(n,\{i\},\{\expr\})$}368\li{vector of small ints}{vectorsmall$(n,\{i\},\{\expr\})$}369\newcolumn370\li{$[c, c\cdot x, \dots, c\cdot x^n]$}{powers$(x,n,\{c = 1\})$}371\li{$[1, 2^x, \dots, n^x]$}{dirpowers$(n,x)$}372\li{matrix $1\le i\le m$, $1\le j\le n$}{matrix$(m,n,\{i\},\{j\},\{\expr\})$}373\li{define matrix by blocks}{matconcat$(B)$}374\li{diagonal matrix with diagonal $x$}{matdiagonal$(x)$}375\li{is $x$ diagonal?}{matisdiagonal$(x)$}376\li{$x\,\cdot\, $\kbd{matdiagonal}$(d)$}{matmuldiagonal$(x,d)$}377\li{$n\times n$ identity matrix}{matid$(n)$}378\li{Hessenberg form of square matrix $x$}{mathess$(x)$}379\li{$n\times n$ Hilbert matrix $H_{ij}=(i+j-1)^{-1}$}{mathilbert$(n)$}380\li{$n\times n$ Pascal triangle}{matpascal$(n-1)$}381\li{companion matrix to polynomial $x$}{matcompanion$(x)$}382\li{Sylvester matrix of $x$ and $y$}{polsylvestermatrix$(x,y)$}383384\subsec{Gaussian elimination}385\li{kernel of matrix $x$}{matker$(x,\{\fl\})$}386\li{intersection of column spaces of $x$ and $y$}{matintersect$(x,y)$}387\li{solve $MX = B$ ($M$ invertible)}{matsolve$(M,B)$}388\li{one sol of $M*X = B$}{matinverseimage$(M,B)$}389\li{basis for image of matrix $x$}{matimage$(x)$}390\li{columns of $x$ \emph{not} in \kbd{matimage}}{matimagecompl$(x)$}391\li{supplement columns of $x$ to get basis}{matsupplement$(x)$}392\li{rows, cols to extract invertible matrix}{matindexrank$(x)$}393\li{rank of the matrix $x$}{matrank$(x)$}394395\li{solve $MX = B$ mod $D$}{matsolvemod$(M,D,B)$}396\li{image mod $D$}{matimagemod$(M,D)$}397\li{kernel mod $D$}{matkermod$(M,D)$}398\li{inverse mod $D$}{matinvmod$(M,D)$}399\li{determinant mod $D$}{matdetmod$(M,D)$}400401\section{Lattices \& Quadratic Forms}402\subsec{Quadratic forms}403\li{evaluate $^tx Q y$}{qfeval$(\{Q=\var{id}\},x,y)$}404\li{evaluate $^tx Q x$}{qfeval$(\{Q=\var{id}\},x)$}405\li{signature of quad form $^ty*x*y$}{qfsign$(x)$}406\li{decomp into squares of $^ty*x*y$}{qfgaussred$(x)$}407\li{eigenvalues/vectors for real symmetric $x$}{qfjacobi$(x)$}408409\subsec{HNF and SNF}410\li{upper triangular Hermite Normal Form}{mathnf$(x)$}411\li{HNF of $x$ where $d$ is a multiple of det$(x)$}{mathnfmod$(x,d)$}412\li{multiple of det$(x)$}{matdetint$(x)$}413\li{HNF of $(x \mid\,$\kbd{diagonal}$(D))$}{mathnfmodid$(x,D)$}414\li{elementary divisors of $x$}{matsnf$(x)$}415\li{elementary divisors of $\ZZ[a]/(f'(a))$}{poldiscreduced$(f)$}416\li{integer kernel of $x$}{matkerint$(x)$}417\li{$\ZZ$-module $\leftrightarrow$ $\QQ$-vector space}{matrixqz$(x,p)$}418419\subsec{Lattices}420\li{LLL-algorithm applied to columns of $x$}{qflll$(x,\{\fl\})$}421\li{\dots for Gram matrix of lattice}{qflllgram$(x,\{\fl\})$}422\li{find up to $m$ sols of \kbd{qfnorm}$(x,y)\le b$}{qfminim$(x,b,m)$}423\li{$v$, $v[i]:=$number of $y$ s.t. \kbd{qfnorm}$(x,y)= i$}424{qfrep$(x,B,\{\fl\})$}425\li{perfection rank of $x$}{qfperfection$(x)$}426\li{find isomorphism between $q$ and $Q$}{qfisom$(q,Q)$}427\li{precompute for isomorphism test with $q$}{qfisominit$(q)$}428\li{automorphism group of $q$}{qfauto$(q)$}429\copyrightnotice430\newcolumn431\li{convert \kbd{qfauto} for GAP/Magma}{qfautoexport$(G,\{\fl\})$}432\li{orbits of $V$ under $G\subset \text{GL}(V)$}433{qforbits$(G,V)$}434435\section{Polynomials \& Rational Functions}436\li{all defined polynomial variables}{variables$()$}437\li{get var.~of highest priority (higher than $v$)}438{varhigher$(\var{name},\{v\})$}439\li{\dots of lowest priority (lower than $v$)}440{varlower$(\var{name},\{v\})$}441442\subsec{Coefficients, variables and basic operators}443\li{degree of $f$}{poldegree$(f)$}444\li{coef. of degree $n$ of $f$, leading coef.}{polcoef$(f,n)${\rm, }pollead}445\li{main variable / all variables in $f$}{variable$(f)${\rm, }variables$(f)$}446\li{replace $x$ by $y$ in $f$}{subst$(f,x,y)$}447\li{evaluate $f$ replacing vars by their value}{eval$(f)$}448\li{replace polynomial expr.~$T(x)$ by $y$ in $f$}{substpol$(f,T,y)$}449\li{replace $x_1,\dots,x_n$ by $y_1,\dots,y_n$ in $f$}{substvec$(f,x,y)$}450\li{$f\in A[x]$; reciprocal polynomial $x^{\deg f}f\big({1\over x}\big)$}451{polrecip$(f)$}452\li{gcd of coefficients of $f$}{content$(f)$}453\li{derivative of $f$ w.r.t. $x$}{deriv$(f,\{x\})$}454\li{\dots $n$-th derivative of $f$}{derivn$(f,n,\{x\})$}455\li{formal integral of $f$ w.r.t. $x$}{intformal$(f,\{x\})$}456\li{formal sum of $f$ w.r.t. $x$}{sumformal$(f,\{x\})$}457458\subsec{Constructors \& Special Polynomials}459interpolation polynomial at $(x[1],y[1]),\dots, (x[n],y[n])$,460evaluated at $t$, with error estimate461$e$ \hfil \kbd{polinterpolate}$(x,\{y\},\{t\},\{\&e\})$\break462\li{$T_n/U_n$, $H_n$}{polchebyshev$(n)${\rm, }polhermite$(n)$}463\li{$P_n$, $L_n^{(\alpha)}$}{pollegendre$(n)${\rm, }pollaguerre$(n,a)$}464\li{$n$-th cyclotomic polynomial $\Phi_n$}{polcyclo$(n)$}465\li{return $n$ if $f=\Phi_n$, else $0$}{poliscyclo$(f)$}466\li{is $f$ a product of cyclotomic polynomials?}{poliscycloprod$(f)$}467\li{Zagier's polynomial of index $(n,m)$}{polzagier$(n,m)$}468469\subsec{Resultant, elimination}470\li{discriminant of polynomial $f$}{poldisc$(f)$}471\li{find factors of \kbd{poldisc}$(f)$}{poldiscfactors$(f)$}472\li{resultant $R = \text{Res}_v(f,g)$}{polresultant$(f,g,\{v\})$}473\li{$[u,v,R]$, $xu + yv = \text{Res}_v(f,g)$}{polresultantext$(x,y,\{v\})$}474\li{solve Thue equation $f(x,y)=a$}{thue$(t,a,\{sol\})$}475\li{initialize $t$ for Thue equation solver}{thueinit$(f)$}476477\subsec{Roots and Factorization (Complex/Real)}478\li{complex roots of $f$}{polroots$(f)$}479\li{bound complex roots of $f$}{polrootsbound$(f)$}480\li{number of real roots of $f$ (in $[a,b]$)}{polsturm$(f,\{[a,b]\})$}481\li{real roots of $f$ (in $[a,b]$)}{polrootsreal$(f,\{[a,b]\})$}482\li{complex embeddings of \typ{POLMOD} $z$}{conjvec$(z)$}483484\subsec{Roots and Factorization (Finite fields)}485\li{factor $f\mod p$, roots}{factormod$(f,p)${\rm, }polrootsmod}486\li{factor $f$ over $\FF_p[x]/(T)$, roots}{factormod$(f,[T,p])${\rm, }polrootsmod}487\li{squarefree factorization of $f$ in $\FF_q[x]$}{factormodSQF$(f,\{D\})$}488\li{distinct degree factorization of $f$ in $\FF_q[x]$}{factormodDDF$(f,\{D\})$}489490\subsec{Roots and Factorization ($p$-adic fields)}491\li{factor $f$ over $\QQ_p$, roots}{factorpadic$(f,p,r)${\rm, }polrootspadic}492\li{$p$-adic root of $f$ congruent to $a\mod p$}{padicappr$(f,a)$}493\li{Newton polygon of $f$ for prime $p$}{newtonpoly$(f,p)$}494\li{Hensel lift $A/\text{lc}(A) = \prod_i B[i]$ mod $p^e$}495{polhensellift$(A,B,p,e)$}496\li{$T = \prod (x - z_i)\mapsto497\prod (x - \omega(z_i))] \in \ZZ_p[x]$}498{polteichmuller$(T,p,e)$}499\li{extensions of $\QQ_p$ of degree $N$}{padicfields$(p,N)$}500501\shortcopyrightnotice502\newcolumn503504\title{\TITLE}505506\centerline{(PARI-GP version \PARIversion)}507\bigskip508509\subsec{Roots and Factorization (Miscellaneous)}510\li{symmetric powers of roots of $f$ up to $n$}{polsym$(f,n)$}511\li{Graeffe transform of $f$, $g(x^2)=f(x)f(-x)$}{polgraeffe$(f)$}512\li{factor $f$ over coefficient field}{factor$(f)$}513\li{cyclotomic factors of $f\in\QQ[X]$}{polcyclofactors$(f)$}514515\section{Finite Fields}516A finite field is encoded by any element (\typ{FFELT}).\hfil\break517\li{find irreducible $T\in \FF_p[x]$, $\deg T = n$}{ffinit$(p,n,\{x\})$}518\li{Create $t$ in $\FF_q\simeq\FF_p[t]/(T)$}{t = ffgen($T$,'t)}519\li{\dots indirectly, with implicit $T$}{t = ffgen($q$,'t); T = t.mod}520\li{map $m$ from $\FF_q\ni a$ to $\FF_{q^k} \ni b$}{m = ffembed$(a,b)$}521\li{build $K=\FF_q[x]/(P)$ extending $\FF_q\ni a$, }{ffextend$(a, P)$}522\li{evaluate map $m$ on $x$}{ffmap$(m,x)$}523\li{inverse map of $m$}{ffinvmap$(m)$}524\li{compose maps $m \circ n$}{ffcompomap$(m,n)$}525\li{$x$ as polmod over codomain of map $m$}{ffmaprel$(m,x)$}526\li{$F^n$ over $\FF_q\ni a$}{fffrobenius$(a,n)$}527\li{$\#\{{\rm monic\ irred.}\ T\in \FF_q[x], \deg T = n\}$}{ffnbirred$(q,n)$}528529\section{Formal \& p-adic Series}530\li{truncate power series or $p$-adic number}{truncate$(x)$}531\li{valuation of $x$ at $p$}{valuation$(x,p)$}532\subsec{Dirichlet and Power Series}533\li{Taylor expansion around $0$ of $f$ w.r.t. $x$}{taylor$(f,x)$}534\li{Laurent series of closure $F$ up to $x^k$}{laurentseries$(f,k)$}535\li{$\sum a_kb_k t^k$ from $\sum a_kt^k$ and $\sum b_kt^k$}{serconvol$(a,b)$}536\li{$f=\sum a_k t^k$ from $\sum (a_k/k!)t^k$}{serlaplace$(f)$}537\li{reverse power series $F$ so $F(f(x))=x$}{serreverse$(f)$}538\li{remove terms of degree $<n$ in $f$}{serchop$(f,n)$}539\li{Dirichlet series multiplication / division}{dirmul{\rm,} dirdiv$(x,y)$}540\li{Dirichlet Euler product ($b$ terms)}{direuler$(p=a,b,\expr)$}541542\section{Transcendental and $p$-adic Functions}543\li{real, imaginary part of $x$}{real$(x)$, imag$(x)$}544\li{absolute value, argument of $x$}{abs$(x)$, arg$(x)$}545\li{square/nth root of $x$}{sqrt$(x)$, sqrtn$(x,n,\{$\&$z\})$}546\li{all $n$-th roots of $1$}{rootsof1$(n)$}547\li{FFT of $[f_0,\dots,f_{n-1}]$}548{$w$ = fftinit$(n)$, fft/fftinv$(w,f)$}549\li{trig functions}{sin, cos, tan, cotan, sinc}550\li{inverse trig functions}{asin, acos, atan}551\li{hyperbolic functions}{sinh, cosh, tanh, cotanh}552\li{inverse hyperbolic functions}{asinh, acosh, atanh}553\li{$\log(x)$, $\log(1+x)$, $e^x$, $e^x-1$}554{log{\rm, }log1p{\rm, }exp{\rm, }expm1}555\li{Euler $\Gamma$ function, $\log \Gamma$, $\Gamma'/\Gamma$}556{gamma{\rm, }lngamma{\rm, }psi}557\li{half-integer gamma function $\Gamma(n+1/2)$}{gammah$(n)$}558\li{Riemann's zeta $\zeta(s)=\sum n^{-s}$}{zeta$(s)$}559\li{$\sum_{n \le N} n^s$}{dirpowerssum$(N,s)$}560\li{Hurwitz's $\zeta(s,x)=\sum (n+x)^{-s}$}{zetahurwitz$(s,x)$}561\li{multiple zeta value (MZV), $\zeta(s_1,\dots,s_k)$}{zetamult$(s,\{T\})$}562\li{all MZVs for weight $\sum s_i = n$}{zetamultall$(n)$}563\li{convert MZV id to $[s_1,\dots,s_k]$}{zetamultconvert$(f,\{\fl\})$}564\li{MZV dual sequence}{zetamultdual$(s)$}565\li{multiple polylog $Li_{s_1,\dots s_k}(z_1,\dots,z_k)$}{polylogmult$(s,z)$}566\newcolumn567\li{incomplete $\Gamma$ function ($y=\Gamma(s)$)}{incgam$(s,x,\{y\})$}568\li{complementary incomplete $\Gamma$}{incgamc$(s,x)$}569\li{$\int_x^\infty e^{-t}\,dt/t$,\quad $(2/\sqrt\pi)\int_x^\infty e^{-t^2}dt$}570{eint1, erfc}571\li{elliptic integral of 1st and 2nd kind}{ellK$(k)$, ellE$(k)$}572\li{dilogarithm of $x$}{dilog$(x)$}573\li{$m$-th polylogarithm of $x$}{polylog$(m,x,\{\fl\})$}574\li{$U$-confluent hypergeometric function}{hyperu$(a,b,u)$}575\li{Hypergeometric $_pF_q(A,B;z)$}{hypergeom$(A, B, z)$}576\li{Bessel $J_n(x)$, $J_{n+1/2}(x)$}{besselj$(n,x)$, besseljh$(n,x)$}577\li{Bessel $I_\nu$, $K_\nu$, $H^1_\nu$, $H^2_\nu$, $Y_\nu$}578{(bessel)i{\rm, }k{\rm, }h1{\rm, }h2{\rm, }y}579\li{$k$-th zero of $J_\nu(x)$} {besseljzero$(nu,\{k=1\})$}580\li{$k$-th zero of $Y_\nu(x)$}{besselyzero$(nu,\{k=1\})$}581\li{Airy functions $A_i(x)$, $B_i(x)$}{airy$(x)$}582\li{Lambert $W$: $x$ s.t. $xe^x =y$}{lambertw$(y)$}583\li{Teichmuller character of $p$-adic $x$}{teichmuller$(x)$}584585\section{Iterations, Sums \& Products}586\subsec{Numerical integration for meromorphic functions}587Behaviour at endpoint for Double Exponential (DE) methods: either a scalar588($a\in\CC$, regular) or $\pm$\kbd{oo} (decreasing at least as $x^{-2}$) or589\beginindentedkeys590\li{$(x-a)^{-\alpha}$ singularity}{$[a,\alpha]$}591\li{exponential decrease $e^{-\alpha|x|}$}{$[\pm\infty,\alpha]$, $\alpha > 0$}592\li{slow decrease $|x|^{\alpha}$}{$\dots \alpha < -1$}593\li{oscillating as $\cos(kx))$}{$\alpha = k$\kbd{I}, $k > 0$}594\li{oscillating as $\sin(kx))$}{$\alpha = -k$\kbd{I}, $k > 0$}595\endindentedkeys596\li{numerical integration}{intnum$(x=a,b,f,\{T\})$}597\li{weights $T$ for \kbd{intnum}}{intnuminit$(a,b,\{m\})$}598\li{weights $T$ incl.~kernel $K$}{intfuncinit$(t=a,b,K,\{m\})$}599\li{integrate $(2i\pi)^{-1}f$ on circle $|z - a| = R$}600{intcirc$(x=a,R,f,\{T\})$}601602\subsec{Other integration methods}603\li{$n$-point Gauss-Legendre}{intnumgauss$(x=a,b,f,\{n\})$}604\li{weights for $n$-point Gauss-Legendre}{intnumgaussinit$(\{n\})$}605\li{Romberg integration (low accuracy)}{intnumromb$(x=a,b,f,\{\fl\})$}606607\subsec{Numerical summation}608\li{sum of series $f(n)$, $n\geq a$ (low accuracy)}{suminf$(n=a,\expr)$}609\li{sum of alternating/positive series}{sumalt{\rm,} sumpos}610\li{sum of series using Euler-Maclaurin}{sumnum$(n=a,f,\{T\})$}611612\li{$\sum_{n\geq a} F(n)$, $F$ rational function}{sumnumrat$(F,a)$}613\li{\dots $\sum_{p\geq a} F(p^s)$}{sumeulerrat$(F, \{s = 1\}, \{a = 2\})$}614\li{weights for \kbd{sumnum}, $a$ as in DE}615{sumnuminit$(\{\infty, a\})$}616\li{sum of series by Monien summation}{sumnummonien$(n=a,f,\{T\})$}617\li{weights for \kbd{sumnummonien}}618{sumnummonieninit$(\{\infty, a\})$}619\li{sum of series using Abel-Plana}{sumnumap$(n=a,f,\{T\})$}620\li{weights for \kbd{sumnumap}, $a$ as in DE}621{sumnumapinit$(\{\infty, a\})$}622\li{sum of series using Lagrange}{sumnumlagrange$(n=a,f,\{T\})$}623\li{weights for \kbd{sumnumlagrange}}624{sumnumlagrangeinit}625626\subsec{Products}627\li{product $a\le X\le b$, initialized at $x$}{prod$(X=a,b,\expr,\{x\})$}628\li{product over primes $a\le X\le b$}{prodeuler$(X=a,b,\expr)$}629\li{infinite product $a\le X\le\infty$}{prodinf$(X=a,\expr)$}630\li{$\prod_{n\geq a} F(n)$, $F$ rational function}{prodnumrat$(F,a)$}631\li{$\prod_{p\geq a} F(p^s)$}{prodeulerrat$(F,\{s=1\},\{a=2\})$}632633\subsec{Other numerical methods}634\li{real root of $f$ in $[a,b]$; bracketed root}{solve$(X=a,b,f)$}635\li{\dots interval splitting, step $s$}{solvestep$(X=a,b,s,f,\{\fl=0\})$}636\li{limit of $f(t)$, $t\to\infty$}{limitnum(f, \{alpha\})}637\li{asymptotic expansion of $f$ (rational)}{asympnum(f, \{alpha\})}638\li{\dots $N+1$ terms as floats}{asympnumraw(f, N, \{alpha\})}639\li{numerical derivation w.r.t $x$: $f'(a)$}{derivnum$(x=a, f)$}640\li{evaluate continued fraction $F$ at $t$}641{contfraceval$(F,t,\{L\})$}642\li{power series to cont.~fraction ($L$ terms)}643{contfracinit$(S,\{L\})$}644\li{Pad\'{e} approximant (deg.~denom.~$\leq B$)}{bestapprPade$(S,\{B\})$}645646\section{Elementary Arithmetic Functions}647\li{vector of binary digits of $|x|$}{binary$(x)$}648\li{bit number $n$ of integer $x$}{bittest$(x,n)$}649\li{Hamming weight of integer $x$}{hammingweight$(x)$}650\li{digits of integer $x$ in base $B$}{digits$(x,\{B=10\})$}651\li{sum of digits of integer $x$ in base $B$}{sumdigits$(x,\{B=10\})$}652\li{integer from digits}{fromdigits$(v,\{B=10\})$}653\li{ceiling/floor/fractional part}{ceil{\rm, }floor{\rm, }frac}654\li{round $x$ to nearest integer}{round$(x,\{$\&$e\})$}655\li{truncate $x$}{truncate$(x,\{$\&$e\})$}656\li{gcd/LCM of $x$ and $y$}{gcd$(x,y)$, lcm$(x,y)$}657\li{gcd of entries of a vector/matrix}{content$(x)$}658659\subsec{Primes and Factorization}660\li{extra prime table}{addprimes$()$}661\li{add primes in $v$ to prime table}{addprimes$(v)$}662\li{remove primes from prime table}{removeprimes$(v)$}663\li{Chebyshev $\pi(x)$, $n$-th prime $p_n$}{primepi$(x)$, prime$(n)$}664\li{vector of first $n$ primes}{primes$(n)$}665\li{smallest prime $\ge x$}{nextprime$(x)$}666\li{largest prime $\le x$}{precprime$(x)$}667\li{factorization of $x$}{factor$(x,\{lim\})$}668\li{\dots selecting specific algorithms}{factorint$(x,\{\fl=0\})$}669\li{$n=df^2$, $d$ squarefree/fundamental}{core$(n,\{fl\})${\rm, }coredisc}670\li{certificate for (prime) $N$}{primecert$(N)$}671\li{verifies a certificate $c$}{primecertisvalid$(c)$}672\li{convert certificate to Magma/PRIMO}{primecertexport}673\li{recover $x$ from its factorization}{factorback$(f,\{e\})$}674\li{$x\in\ZZ$, $|x|\leq X$, $\gcd(N,P(x)) \geq N$}675{zncoppersmith$(P,N,X,\{B\})$}676\li{divisors of $N$ in residue class $r \mod{s}$}{divisorslenstra$(N,r,s)$}677678\subsec{Divisors and multiplicative functions}679\li{number of prime divisors $\omega(n)$ / $\Omega(n)$}680{omega$(n)${\rm, }bigomega}681\li{divisors of $n$ / number of divisors $\tau(n)$}{divisors$(n)${\rm, }numdiv}682\li{sum of ($k$-th powers of) divisors of $n$}{sigma$(n,\{k\})$}683\li{M\"obius $\mu$-function}{moebius$(x)$}684\li{Ramanujan's $\tau$-function}{ramanujantau$(x)$}685686\subsec{Combinatorics}687\li{factorial of $x$}{$x$!~{\rm or} factorial$(x)$}688\li{binomial coefficient $x\choose k$}{binomial$(x,\{k\})$}689690\li{Bernoulli number $B_n$ as real/rational}{bernreal$(n)${\rm, }bernfrac}691\li{$[B_0,B_2,\dots B_{2k}]$}{bernvec$(k)$}692\li{Bernoulli polynomial $B_n(x)$}{bernpol$(n,\{x\})$}693\li{Euler numbers}{eulerfrac{\rm, }eulerreal{\rm, }eulervec}694\li{Euler polynomials $E_n(x)$}{eulerpol$(n,\{x\})$}695\li{Eulerian polynomials $A_n(x)$}{eulerianpol}696697\li{Fibonacci number $F_n$}{fibonacci$(n)$}698\li{Stirling numbers $s(n,k)$ and $S(n,k)$}{stirling$(n,k,\{\fl\})$}699\newcolumn700701\title{\TITLE}702703\centerline{(PARI-GP version \PARIversion)}704\bigskip705\li{number of partitions of $n$}{numbpart$(n)$}706\li{$k$-th permutation on $n$ letters}{numtoperm$(n,k)$}707\li{\dots index $k$ of permutation $v$}{permtonum$(v)$}708\li{order of permutation $p$}{permorder$(p)$}709\li{signature of permutation $p$}{permsign$(p)$}710\li{cyclic decomposition of permutation $p$}{permcycles$(p)$}711712\subsec{Multiplicative groups $(\ZZ/N\ZZ)^*$, $\FF_q^*$}713\li{Euler $\phi$-function}{eulerphi$(x)$}714\li{multiplicative order of $x$ (divides $o$)}{znorder$(x,\{o\})${\rm, }fforder}715\li{primitive root mod $q$ / $x$\kbd{.mod}}{znprimroot$(q)${\rm, }ffprimroot$(x)$}716\li{structure of $(\ZZ/n\ZZ)^*$}{znstar$(n)$}717\li{discrete logarithm of $x$ in base $g$}{znlog$(x,g,\{o\})${\rm, }fflog}718\li{Kronecker-Legendre symbol $({x\over y})$}{kronecker$(x,y)$}719\li{quadratic Hilbert symbol (at $p$)}{hilbert$(x,y,\{p\})$}720721\subsec{Euclidean algorithm, continued fractions}722\li{CRT: solve $z\equiv x$ and $z\equiv y$}{chinese$(x,y)$}723\li{minimal $u,v$ so $xu+yv=\gcd(x,y)$}{gcdext$(x,y)$}724\li{half-gcd algorithm}{halfgcd$(x,y)$}725\li{continued fraction of $x$}{contfrac$(x,\{b\},\{lmax\})$}726\li{last convergent of continued fraction $x$}{contfracpnqn$(x)$}727\li{rational approximation to $x$ (den. $\leq B$)}{bestappr$(x,\{B\})$}728\li{recognize $x\in\CC$ as polmod mod $T\in\ZZ[X]$}{bestapprnf$(x,T)$}729730\subsec{Miscellaneous}731\li{integer square / $n$-th root of $x$}{sqrtint$(x)$, sqrtnint$(x,n)$}732\li{largest integer $e$ s.t. $b^e \leq b$, $e = \lfloor \log_b(x)\rfloor$}733{logint$(x,b,\{\&z\})$}734735\section{Characters}736Let \var{cyc} $=[d_1,\dots,d_k]$ represent an abelian group $G = \oplus737(\ZZ/d_j\ZZ)\cdot g_j$ or any738structure $G$ affording a \kbd{.cyc} method; e.g. \kbd{znstar}$(q,1)$739for Dirichlet characters. A character $\chi$ is coded by740$[c_1,\dots,c_k]$ such that $\chi(g_j) = e(n_j/d_j)$.741\hfil\break742\li{$\chi\cdot \psi$; $\chi^{-1}$; $\chi\cdot \psi^{-1}$; $\chi^k$}743{charmul{\rm, }charconj{\rm, }chardiv{\rm, }charpow}744\li{order of $\chi$}{charorder$(\var{cyc}, \chi)$}745\li{kernel of $\chi$}{charker$(\var{cyc},\chi)$}746\li{$\chi(x)$, $G$ a GP group structure}{chareval$(G, \chi, x, \{z\})$}747\li{Galois orbits of characters}{chargalois$(G)$}748749\subsec{Dirichlet Characters}750\li{initialize $G = (\ZZ/q\ZZ)^*$}{G = znstar$(q,1)$}751\li{convert datum $D$ to $[G,\chi]$}{znchar$(D)$}752\li{is $\chi$ odd?}{zncharisodd$(G,\chi)$}753\li{real $\chi \to $ Kronecker symbol $(D/.)$}{znchartokronecker$(G,\chi)$}754\li{conductor of $\chi$}{zncharconductor$(G,\chi)$}755\li{$[G_0,\chi_0]$ primitive attached to $\chi$}{znchartoprimitive$(G,\chi)$}756\li{induce $\chi\in \hat{G}$ to $\ZZ/N\ZZ$}{zncharinduce$(G,\chi,N)$}757\li{$\chi_p$}{znchardecompose$(G,\chi, p)$}758\li{$\prod_{p\mid (Q,N)} \chi_p$}{znchardecompose$(G,\chi, Q)$}759\li{complex Gauss sum $G_a(\chi)$}{znchargauss$(G,\chi)$}760761\subsec{Conrey labelling}762\li{Conrey label $m\in (\ZZ/q\ZZ)^* \to\;$ character}{znconreychar$(G,m)$}763\li{character $\to$ Conrey label}{znconreyexp$(G,\chi)$}764\li{log on Conrey generators}{znconreylog$(G, m)$}765\li{conductor of $\chi$ ($\chi_0$ primitive)}766{znconreyconductor$(G,\chi, \{\chi_0\})$}767768\section{True-False Tests}769\li{is $x$ the disc. of a quadratic field?}{isfundamental$(x)$}770\li{is $x$ a prime?}{isprime$(x)$}771\li{is $x$ a strong pseudo-prime?}{ispseudoprime$(x)$}772\li{is $x$ square-free?}{issquarefree$(x)$}773\li{is $x$ a square?}{issquare$(x,\{\&n\})$}774\li{is $x$ a perfect power?}{ispower$(x,\{k\},\{\&n\})$}775\li{is $x$ a perfect power of a prime? ($x=p^n$)}{isprimepower$(x,\&n\})$}776\li{\dots of a pseudoprime?}{ispseudoprimepower$(x,\&n\})$}777\li{is $x$ powerful?}{ispowerful$(x)$}778\li{is $x$ a totient? ($x=\varphi(n)$)}{istotient$(x,\{\&n\})$}779\li{is $x$ a polygonal number? ($x = P(s,n)$)}{ispolygonal$(x, s, \{\&n\})$}780781\li{is \var{pol}\ irreducible?}{polisirreducible$(\var{pol})$}782783\section{Graphic Functions}784\li{crude graph of \expr\ between $a$ and $b$}{plot$(X=a,b,expr)$}785\subsec{High-resolution plot {\rm (immediate plot)}}786\li{plot \expr\ between $a$ and $b$}{ploth$(X=a,b,expr,\{\fl\},\{n\})$}787\li{plot points given by lists $lx$, $ly$}{plothraw$(lx,ly,\{\fl\})$}788\li{terminal dimensions}{plothsizes$()$}789%790\subsec{Rectwindow functions}791\li{init window $w$, with size $x$,$y$}{plotinit$(w,x,y)$}792\li{erase window $w$}{plotkill$(w)$}793\li{copy $w$ to $w_2$ with offset $(dx,dy)$}{plotcopy$(w,w_2,dx,dy)$}794\li{clips contents of $w$}{plotclip$(w)$}795\li{scale coordinates in $w$}{plotscale$(w,x_1,x_2,y_1,y_2)$}796\li{\kbd{ploth} in $w$}{plotrecth$(w,X=a,b,expr,\{\fl\},\{n\})$}797\li{\kbd{plothraw} in $w$}{plotrecthraw$(w,data,\{\fl\})$}798\li{draw window $w_1$ at $(x_1,y_1)$, \dots} {plotdraw$($[[$w_1,x_1,y_1$]$,\dots$]$)$}799%800\subsec{Low-level Rectwindow Functions}801%\li{}{plotlinetype$(w,)$}802%\li{}{plotpointtype$(w,)$}803%\li{}{plotterm$(w,)$}804\li{set current drawing color in $w$ to $c$}{plotcolor$(w,c)$}805\li{current position of cursor in $w$}{plotcursor$(w)$}806%807\li{write $s$ at cursor's position}{plotstring$(w,s)$}808\li{move cursor to $(x,y)$}{plotmove$(w,x,y)$}809\li{move cursor to $(x+dx,y+dy)$}{plotrmove$(w,dx,dy)$}810\li{draw a box to $(x_2,y_2)$}{plotbox$(w,x_2,y_2)$}811\li{draw a box to $(x+dx,y+dy)$}{plotrbox$(w,dx,dy)$}812\li{draw polygon}{plotlines$(w,lx,ly,\{\fl\})$}813\li{draw points}{plotpoints$(w,lx,ly)$}814\li{draw line to $(x+dx,y+dy)$}{plotrline$(w,dx,dy)$}815\li{draw point $(x+dx,y+dy)$}{plotrpoint$(w,dx,dy)$}816%817\subsec{Convert to Postscript or Scalable Vector Graphics}818The format $f$ is either \kbd{"ps"} or \kbd{"svg"}.\hfil\break819\li{as {\tt ploth}}{plothexport$(f,X=a,b,expr,\{\fl\},\{n\})$}820\li{as {\tt plothraw}}{plothrawexport$(f,lx,ly,\{\fl\})$}821\li{as {\tt plotdraw}}{plotexport$(f,$[[$w_1,x_1,y_1$]$,\dots$]$)$}822823% This goes at the bottom of the second page (column 6)824\copyrightnotice825\bye826827828