Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

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