0% found this document useful (0 votes)
71 views4 pages

Help Reserved Variable Names: C 2018 Karim Belabas. Permissions On Back. v2.35

This document provides a reference card for the PARI/GP calculator. It lists the main data types like integers, reals, matrices and lists. It also summarizes basic operations, functions for random numbers, conversions and programming constructs available in PARI/GP.

Uploaded by

lyz lee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views4 pages

Help Reserved Variable Names: C 2018 Karim Belabas. Permissions On Back. v2.35

This document provides a reference card for the PARI/GP calculator. It lists the main data types like integers, reals, matrices and lists. It also summarizes basic operations, functions for random numbers, conversions and programming constructs available in PARI/GP.

Uploaded by

lyz lee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Pari-GP reference card t VECSMALL.

Vector of small ints Vecsmall([x, y, z]) Conjugates and Lifts


(PARI-GP version 2.11.0) t MAT. Matrices [a, b;c, d] conjugate of a number x conj(x)
Note: optional arguments are surrounded by braces {}. t LIST. Lists List([x, y, z]) norm of x, product with conjugate norm(x)
To start the calculator, type its name in the terminal: gp t STR. Strings "abc" Lp norm of x (L∞ if no p) normlp(x, {p})
To exit gp, type quit, \q, or <C-D> at prompt. t INFINITY. ±∞ +oo, -oo square of L2 norm of x norml2(x)
Help Reserved Variable Names lift of x from Mods and p-adics lift, centerlift(x)
recursive lift liftall
describe function ?function π = 3.14 . . ., γ = 0.57 . . ., C = 0.91 . . . Pi, Euler, Catalan
lift all t INT and t PADIC (→t INT) liftint
extended description ??keyword square root of −1 I
lift all t POLMOD (→t POL) liftpol
list of relevant help topics ???pattern Landau’s big-oh notation O
name of GP-1.39 function f in GP-2.* whatnow(f ) Lists, Sets & Maps
Information about an Object Sets (= row vector with strictly increasing entries w.r.t. cmp)
Input/Output PARI type of object x type(x) intersection of sets x and y setintersect(x, y)
previous result, the result before %, %‘, %‘‘, etc. length of x / size of x in memory #x, sizebyte(x) set of elements in x not belonging to y setminus(x, y)
n-th result since startup %n real precision / bit precision of x precision(x), bitprecision union of sets x and y setunion(x, y)
separate multiple statements on line ; p-adic, series prec. of x padicprec(x), serprec does y belong to the set x setsearch(x, y, {flag})
extend statement on additional lines \ Operators set of all f (x, y), x ∈ X, y ∈ Y setbinop(f, X, Y )
extend statements on several lines {seq1 ; seq2 ;} is x a set ? setisset(x)
basic operations +, - , *, /, ^, sqr
comment /* . . . */ Lists. create empty list: L = List()
i=i+1, i=i-1, i=i*j, . . . i++, i--, i*=j,. . .
one-line comment, rest of line ignored \\ . . . append x to list L listput(L, x, {i})
euclidean quotient, remainder x\/y, x\y, x%y, divrem(x, y)
Metacommands & Defaults shift x left or right n bits x<<n, x>>n or shift(x, ±n) remove i-th component from list L listpop(L, {i})
set default d to val default({d}, {val}) multiply by 2n shiftmul(x, n) insert x in list L at position i listinsert(L, x, i)
toggle timer on/off # comparison operators <=, <, >=, >, ==, !=, ===, lex, cmp sort the list L in place listsort(L, {flag})
print time for last result ## boolean operators (or, and, not) ||, &&, ! Maps. create empty dictionnary: M = Map()
print defaults \d bit operations bitand, bitneg, bitor, bitxor, bitnegimply attach value v to key k mapput(M, k, v)
set debug level to n \g n maximum/minimum of x and y max, min(x, y) recover value attach to key k or error mapget(M, k)
set memory debug level to n \gm n sign of x = −1, 0, 1 sign(x) is key k in the dict ? (set v to M (k)) mapisdefined(M, k, {&v})
set n significant digits / bits \p n, \pb n binary exponent of x exponent(x) remove k from map domain mapdelete(M, k)
set n terms in series \ps n derivative of f f’ GP Programming
quit GP \q differential operator diffop(f, v, d, {n = 1}) User functions and closures
print the list of PARI types \t quote operator (formal variable) ’x x, y are formal parameters; y defaults to Pi if parameter opitted;
print the list of user-defined functions \u assignment x = value z, t are local variables (lexical scope), z initialized to 1.
read file into GP \r filename simultaneous assignment x ← v1 , y ← v2 [x,y] = v fun(x, y=Pi) = my(z=1, t); seq
Debugger / break loop Select Components fun = (x, y=Pi) -> my(z=1, t); seq
attach a help message to f addhelp(f )
get out of break loop break or <C-D> n-th component of x component(x, n)
undefine symbol s (also kills help) kill(s)
go up/down n frames dbg up({n}), dbg down n-th component of vector/list x x[n]
Control Statements (X: formal parameter in expression seq)
set break point breakpoint() components a, a + 1, . . . , b of vector x x[a..b]
examine object o dbg x(o) (m, n)-th component of matrix x x[m, n] if a 6= 0, evaluate seq1 , else seq2 if(a, {seq1 }, {seq2 })
current error data dbg err() row m or column n of matrix x x[m,], x[, n] eval. seq for a ≤ X ≤ b for(X = a, b, seq)
number of objects on heap and their size getheap() numerator/denominator of x numerator(x), denominator . . . for primes a ≤ X ≤ b forprime(X = a, b, seq)
total size of objects on PARI stack getstack() . . . for primes ≡ a (mod q) forprimestep(X = a, b, q, seq)
Random Numbers . . . for composites a ≤ X ≤ b forcomposite(X = a, b, seq)
PARI Types & Input Formats random integer/prime in [0, N [ random(N ), randomprime . . . for a ≤ X ≤ b stepping s forstep(X = a, b, s, seq)
t INT. Integers; hex, binary ±31; ±0x1F, ±0b101 get/set random seed getrand, setrand(s) . . . for X dividing n fordiv(n, X, seq)
t REAL. Reals ±3.14, 6.022 E23 Conversions . . . X = [n, f actor(n)], a ≤ n ≤ b forfactored(X = a, b, seq)
t INTMOD. Integers modulo m Mod(n, m) . . . as above, n squarefree forsquarefree(X = a, b, seq)
to vector, matrix, vec. of small ints Col/Vec,Mat,Vecsmall
t FRAC. Rational Numbers n/m . . . X = [d, f actor(d)], d | n fordivfactored(n, X, seq)
to list, set, map, string List, Set, Map, Str
t FFELT. Elt in finite field Fq ffgen(q,’t) multivariable for, lex ordering forvec(X = v, seq)
create PARI object (x mod y) Mod(x, y)
t COMPLEX. Complex Numbers x+y∗ I loop over partitions of n forpart(p = n, seq)
make x a polynomial of v Pol(x, {v})
t PADIC. p-adic Numbers x + O(p^k) . . . permutations of S forperm(S, p, seq)
as Pol, etc., starting with constant term Polrev, Vecrev, Colrev
t QUAD. Quadratic Numbers x + y ∗ quadgen(D,’w) . . . subsets of {1, . . . , n} forsubset(n, p, seq)
make x a power series of v Ser(x, {v})
t POLMOD. Polynomials modulo g Mod(f, g) . . . k-subsets of {1, . . . , n} forsubset([n, k], p, seq)
string from bytes / from format+args Strchr, Strprintf
t POL. Polynomials a ∗ x^n + · · · + b . . . vectors v, q(v) ≤ B; q > 0 forqfvec(v, q, b, seq)
TeX string Strtex(x)
t SER. Power Series f + O(x^k) . . . H < G finite abelian group forsubgroup(H = G)
convert x to simplest possible type simplify(x)
t RFRAC. Rational Functions f /g
object x with real precision n precision(x, n) evaluate seq until a 6= 0 until(a, seq)
t QFI/t QFR. Imag/Real binary quad. form Qfb(a, b, c, {d})
object x with bit precision n bitprecision(x, n) while a 6= 0, evaluate seq while(a, seq)
t VEC/t COL. Row/Column Vectors [x, y, z], [x, y, z]~
set precision to p digits in dynamic scope localprec(p) exit n innermost enclosing loops break({n})
t VEC integer range [1..10]
set precision to p bits in dynamic scope localbitprec(p) start new iteration of n-th enclosing loop next({n})

c 2018 Karim Belabas. Permissions on back. v2.35 return x from current subroutine return({x})
Exceptions, warnings Pari-GP reference card Gaussian elimination
raise an exception / warn error(), warning() (PARI-GP version 2.11.0) kernel of matrix x matker(x, {flag})
type of error message E errname(E) get $VAR from environment getenv("VAR") intersection of column spaces of x and y matintersect(x, y)
try seq1 , evaluate seq2 on error iferr(seq1 , E, seq2 ) expand env. variable in string Strexpand(x) solve M X = B (M invertible) matsolve(M, B)
Functions with closure arguments / results Parallel evaluation one sol of M ∗ X = B matinverseimage(M, B)
select from v according to f select(f, v) basis for image of matrix x matimage(x)
These functions evaluate their arguments in parallel (pthreads or
apply f to all entries in v apply(f, v) columns of x not in matimage matimagecompl(x)
MPI); args. must not access global variables and must be free of
evaluate f (a1 , . . . , an ) call(f, a) supplement columns of x to get basis matsupplement(x)
side effects. Enabled if threading engine is not single in gp header.
evaluate f (. . . f (f (a1 , a2 ), a3 ) . . . , an ) fold(f, a) rows, cols to extract invertible matrix matindexrank(x)
evaluate f on x[1], . . . , x[n] parapply(f, x)
calling function as closure self() rank of the matrix x matrank(x)
evaluate closures f [1], . . . , f [n] pareval(f )
Sums & Products solve M X = B mod D matsolvemod(M, D, B)
as select parselect(f, A, {flag})
sum X = a to X = b, initialized at x sum(X = a, b, expr, {x}) image mod D matimagemod(M, D)
as sum parsum(i = a, b, expr , {x})
sum entries of vector v vecsum(v) kernel mod D matkermod(M, D)
as vector parvector(n, i, {expr })
product of all vector entries vecprod(v) inverse mod D matinvmod(M, D)
eval f for i = a, . . . , b parfor(i = a, {b}, f, {r}, {f2 })
sum expr over divisors of n sumdiv(n, X, expr) determinant mod D matdetmod(M, D)
. . . for p prime in [a, b] parforprime(p = a, {b}, f, {r}, {f2 })
. . . assuming expr multiplicative sumdivmult(n, X, expr) Lattices & Quadratic Forms
. . . multivariate parforvec(X = v, f, {r}, {f2 }, {flag})
product a ≤ X ≤ b, initialized at x prod(X = a, b, expr, {x})
declare x as inline (allows to use as global) inline(x) Quadratic forms
product over primes a ≤ X ≤ b prodeuler(X = a, b, expr)
stop inlining uninline() evaluate t xQy qfeval({Q = id}, x, y)
Sorting
Linear Algebra evaluate t xQx qfeval({Q = id}, x)
sort x by k-th component vecsort(x, {k}, {f l = 0})
signature of quad form t y ∗ x ∗ y qfsign(x)
min. m of x (m = x[i]), max. vecmin(x, {&i}), vecmax dimensions of matrix x matsize(x)
decomp into squares of t y ∗ x ∗ y qfgaussred(x)
does y belong to x, sorted wrt. f vecsearch(x, y, {f }) multiply two matrices x * y
eigenvalues/vectors for real symmetric x qfjacobi(x)
Input/Output . . . assuming result is diagonal matmultodiagonal(x, y)
HNF and SNF
print with/without \n, TEX format print, print1, printtex concatenation of x and y concat(x, {y})
upper triangular Hermite Normal Form mathnf(x)
pretty print matrix printp extract components of x vecextract(x, y, {z})
HNF of x where d is a multiple of det(x) mathnfmod(x, d)
print fields with separator printsep(sep, . . .),, printsep1 transpose of vector or matrix x mattranspose(x) or x~
multiple of det(x) matdetint(x)
formatted printing printf() adjoint of the matrix x matadjoint(x)
HNF of (x | diagonal(D)) mathnfmodid(x, D)
write args to file write, write1, writetex(file, args) eigenvectors/values of matrix x mateigen(x)
elementary divisors of x matsnf(x)
write x in binary format writebin(file, x) characteristic/minimal polynomial of x charpoly(x), minpoly
elementary divisors of Z[a]/(f 0 (a)) poldiscreduced(f )
read file into GP read({file}) trace/determinant of matrix x trace(x), matdet
integer kernel of x matkerint(x)
. . . return as vector of lines readvec({file}) permanent of matrix x matpermanent(x)
Z-module ↔ Q-vector space matrixqz(x, p)
. . . return as vector of strings readstr({file}) Frobenius form of x matfrobenius(x)
Lattices
read a string from keyboard input() QR decomposition matqr(x)
LLL-algorithm applied to columns of x qflll(x, {flag})
Files and file descriptors apply matqr’s transform to v mathouseholder(Q, v)
. . . for Gram matrix of lattice qflllgram(x, {flag})
File descriptors allows efficient small consecutive reads or writes Constructors & Special Matrices
find up to m sols of qfnorm(x, y) ≤ b qfminim(x, b, m)
from or to a given file. The argument n below is always a descriptor, {g(x): x ∈ v s.t. f (x)} [g(x) | x <- v, f(x)]
v, v[i] :=number of y s.t. qfnorm(x, y) = i qfrep(x, B, {flag})
attached to a file in r(ead), w(rite) or a(ppend) mode. {x: x ∈ v s.t. f (x)} [x | x <- v, f(x)]
perfection rank of x qfperfection(x)
get descriptor n for file path in given mode fileopen(path, mode) {g(x): x ∈ v} [g(x) | x <- v]
find isomorphism between q and Q qfisom(q, Q)
. . . from shell cmd output (pipe) fileextern(cmd) row vec. of expr eval’ed at 1 ≤ i ≤ n vector(n, {i}, {expr})
precompute for isomorphism test with q qfisominit(q)
close descriptor fileclose(n) col. vec. of expr eval’ed at 1 ≤ i ≤ n vectorv(n, {i}, {expr})
automorphism group of q qfauto(q)
commit pending write operations fileflush(n) vector of small ints vectorsmall(n, {i}, {expr})
convert qfauto for GAP/Magma qfautoexport(G, {flag})
read logical line from file fileread(n) [c, c · x, . . . , c · xn ] powers(x, n, {c = 1})
orbits of V under G ⊂ GL(V ) qforbits(G, V )
. . . raw line from file filereadstr(n) matrix 1 ≤ i ≤ m, 1 ≤ j ≤ n matrix(m, n, {i}, {j}, {expr})
write s\n to file filewrite(n, s) define matrix by blocks matconcat(B) Polynomials & Rational Functions
. . . write s to file filewrite1(n, s) diagonal matrix with diagonal x matdiagonal(x) all defined polynomial variables variables()
Timers is x diagonal? matisdiagonal(x) get var. of highest priority (higher than v) varhigher(name, {v})
x · matdiagonal(d) matmuldiagonal(x, d) . . . of lowest priority (lower than v) varlower(name, {v})
CPU time in ms and reset timer gettime()
n × n identity matrix matid(n)
CPU time in ms since gp startup getabstime()
Hessenberg form of square matrix x mathess(x)
time in ms since UNIX Epoch getwalltime()
n × n Hilbert matrix Hij = (i + j − 1)−1 mathilbert(n)
timeout command after s seconds alarm(s, expr)
n × n Pascal triangle matpascal(n − 1)
Interface with system
companion matrix to polynomial x matcompanion(x)
allocates a new stack of s bytes allocatemem({s})
Sylvester matrix of x polsylvestermatrix(x) Based on an earlier version by Joseph H. Silverman
alias old to new alias(new , old)
July 2018 v2.35. Copyright c 2018 K. Belabas
install function from library install(f, code, {gpf }, {lib}) Permission is granted to make and distribute copies of this card provided the
execute system command a system(a) copyright and this permission notice are preserved on all copies.
. . . and feed result to GP extern(a) Send comments and corrections to [email protected]
. . . returning GP string externstr(a)
Pari-GP reference card Finite Fields Iterations, Sums & Products
(PARI-GP version 2.11.0) A finite field is encoded by any element (t FFELT). Numerical integration for meromorphic functions
find irreducible T ∈ Fp [x], deg T = n ffinit(p, n, {x}) Behaviour at endpoint for Double Exponential (DE) methods: ei-
Coefficients, variables and basic operators Create t in Fq ' Fp [t]/(T ) t = ffgen(T, 0 t) ther a scalar (a ∈ C, regular) or ±oo (decreasing at least as x−2 ) or
degree of f poldegree(f ) . . . indirectly, with implicit T t = ffgen(q, 0 t); T = t.mod (x − a)−α singularity [a, α]
coef. of degree n of f , leading coef. polcoef(f, n), pollead map m from Fq 3 a to Fq k 3 b m = ffembed(a, b) exponential decrease e−α|x| [±∞, α], α > 0
main variable / all variables in f variable(f ), variables(f ) build K = Fq [x]/(P ) extending Fq 3 a, ffextend(a, P ) slow decrease |x|α . . . α < −1
replace x by y in f subst(f, x, y) evaluate map m on x ffmap(m, x) oscillating as cos(kx)) α = kI, k > 0
evaluate f replacing vars by their value eval(f ) inverse map of m ffinvmap(m) oscillating as sin(kx)) α = −kI, k > 0
replace polynomial expr. T (x) by y in f substpol(f, T, y) compose maps m ◦ n ffcompomap(m, n) numerical integration intnum(x = a, b, f, {T })
replace x1 , . . . , xn by y1 , . . . , yn in f substvec(f, x, y) F n over Fq 3 a fffrobenius(a, n) weights T for intnum intnuminit(a, b, {m})
reciprocal polynomial xdeg f f (1/x) polrecip(f ) #{monic irred. T ∈ Fq [x], deg T = n} ffnbirred(q, n) weights T incl. kernel K intfuncinit(a, b, K, {m})
gcd of coefficients of f content(f ) Formal & p-adic Series integrate (2iπ)−1 f on circle |z − a| = R intcirc(x = a, R, f, {T })
derivative of f w.r.t. x deriv(f, {x}) Other integration methods
truncate power series or p-adic number truncate(x)
formal integral of f w.r.t. x intformal(f, {x}) n-point Gauss-Legendre intnumgauss(x = a, b, f, {n})
valuation of x at p valuation(x, p)
formal sum of f w.r.t. x sumformal(f, {x}) weights for n-point Gauss-Legendre intnumgaussinit({n})
Dirichlet and Power Series
Constructors & Special Polynomials Romberg integration (low accuracy)intnumromb(x = a, b, f, {flag})
Taylor expansion around 0 of f w.r.t. x taylor(f, x)
interpolating pol. eval. at a polinterpolate(X, {Y }, {a}) Numerical summation
Laurent series expansion around 0 up to xk laurentseries(f, k)
Pn , Tn /Un , Hn pollegendre, polchebyshev, polhermite sum of series f (n), n ≥ a (low accuracy) suminf(n = a, expr)
ak bk tk from a tk and bk tk
P P P
serconvol(a, b)
n-th cyclotomic polynomial Φn polcyclo(n, {v}) P k Pk k
sum of alternating/positive series sumalt, sumpos
return n if f = Φn , else 0 poliscyclo(f ) f = ak t from (ak /k!)t serlaplace(f ) sum sumnum(n = a, f, {T })
reverse power series F so F (f (x)) = x serreverse(f ) P of series using Euler-Maclaurin
is f a product of cyclotomic polynomials? poliscycloprod(f ) n≥a F (n), F rational function sumnumrat(F, a)
Zagier’s polynomial of index (n, m) polzagier(n, m) remove terms of degree < n in f serchop(f, n) . . . n≥a (−1)n F (n)
P
sumaltrat(F, a)
Dirichlet series multiplication / division dirmul, dirdiv(x, y)
Resultant, elimination . . . p≥a F (ps )
P
sumeulerrat(F, {s = 1}, {a = 2})
discriminant of polynomial f poldisc(f ) Dirichlet Euler product (b terms) direuler(p = a, b, expr)
weights for sumnum, a as in DE sumnuminit({∞, a})
find factors of poldisc(f ) poldiscfactors(f ) Transcendental and p-adic Functions sum of series by Monien summation sumnummonien(n = a, f, {T })
resultant R = Resv (f, g) polresultant(f, g, {v}) real, imaginary part of x real(x), imag(x) weights for sumnummonien sumnummonieninit({∞, a})
[u, v, R], xu + yv = Resv (f, g) polresultantext(x, y, {v}) absolute value, argument of x abs(x), arg(x) sum of series using Abel-Plana sumnumap(n = a, f, {T })
solve Thue equation f (x, y) = a thue(t, a, {sol}) square/nth root of x sqrt(x), sqrtn(x, n, {&z}) weights for sumnumap, a as in DE sumnumapinit({∞, a})
initialize t for Thue equation solver thueinit(f ) trig functions sin, cos, tan, cotan, sinc sum of series using Lagrange sumnumlagrange(n = a, f, {T })
Roots and Factorization (Complex/Real) inverse trig functions asin, acos, atan weights for sumnumlagrange sumnumlagrangeinit
complex roots of f polroots(f ) hyperbolic functions sinh, cosh, tanh, cotanh Products
bound complex roots of f polrootsbound(f ) inverse hyperbolic functions asinh, acosh, atanh product a ≤ X ≤ b, initialized at x prod(X = a, b, expr, {x})
number of real roots of f (in [a, b]) polsturm(f, {[a, b]}) log(x), log(1 + x), ex , ex − 1 log, log1p, exp, expm1 product over primes a ≤ X ≤ b prodeuler(X = a, b, expr)
real roots of f (in [a, b]) polrootsreal(f, {[a, b]}) Euler Γ function, log Γ, Γ0 /Γ gamma, lngamma, psi infinite product a ≤ X ≤ ∞ prodinf(X = a, expr)
complex embeddings of t POLMOD z conjvec(z) half-integer gamma function Γ(n + 1/2) gammah(n)
Q
F (n), F rational function prodnumrat(F, a)
P −s n≥a
Roots and Factorization (Finite fields) Riemann’s zeta ζ(s)P = n zeta(s) . . . p≥a F (ps )
Q
prodeulerrat(F, {s = 1}, {a = 2})
factor f mod p, roots factormod(f, p), polrootsmod Hurwitz’s ζ(s, x) = (n + x)−s zetahurwitz(s, x) Other numerical methods
factor f over Fp [x]/(T ), roots factormod(f, [T, p]), polrootsmod multiple zeta value (MZV), ζ(s1 , . . . , sk ) zetamult(s, {T }) real root of f in [a, b]; bracketed root solve(X = a, b, f )
squarefree factorization of f in Fq [x] factormodSQF(f, {D}) ... init T for MZV with sP 1 + . . . + sk ≤ w zetamultinit(w) . . . by interval splitting solvestep(X = a, b, f, {flag = 0})
distinct degree factorization of f in Fq [x] factormodDDF(f, {D}) all MZVs for all weights si ≤ n zetamultall(n) limit of f (t), t → ∞ limitnum(f, {k}, {alpha})
Roots and Factorization (p-adic fields) convert MZV id to [s1 , . . . , sk ] zetamultconvert(f, {flag}) asymptotic expansion of f at ∞ asympnum(f, {k}, {alpha})
factor f over Qp , roots factorpadic(f, p, r), polrootspadic incomplete Γ function (y = Γ(s)) incgam(s, x, {y}) numerical derivation w.r.t x: f 0 (a) derivnum(x = a, f )
p-adic root of f congruent to a mod p padicappr(f, a) complementary incomplete Γ incgamc(s, x) evaluate continued fraction F at t contfraceval(F, t, {L})
Newton polygon of f for prime p newtonpoly(f, p) R ∞ −t √ R 2
x e dt/t, (2/ π) x∞ e−t dt eint1, erfc power series to cont. fraction (L terms) contfracinit(S, {L})
Hensel lift A/lc(A) = i B[i] mod pe
Q
polhensellift(A, B, p, e) dilogarithm of x dilog(x) Padé approximant (deg. denom. ≤ B) bestapprPade(S, {B})
extensions of Qp of degree N padicfields(p, N ) m-th polylogarithm of x polylog(m, x, {flag})
Roots and Factorization (Miscellaneous) U -confluent hypergeometric function hyperu(a, b, u)
symmetric powers of roots of f up to n polsym(f, n) Bessel Jn (x), Jn+1/2 (x) besselj(n, x), besseljh(n, x)
Graeffe transform of f , g(x2 ) = f (x)f (−x) polgraeffe(f )
factor f over coefficient field factor(f ) Bessel Iν , Kν , Hν1 , Hν2 , Nν (bessel)i, k, h1, h2, n
cyclotomic factors of f ∈ Q[X] polcyclofactors(f ) Lambert W : x s.t. xex = y lambertw(y)
Teichmuller character of p-adic x teichmuller(x)


c 2018 Karim Belabas. Permissions on back. v2.35
Elementary Arithmetic Functions Miscellaneous Rectwindow functions
vector of binary digits of |x| binary(x) integer square / n-th root of x sqrtint(x), sqrtnint(x, n) init window w, with size x,y plotinit(w, x, y)
bit number n of integer x bittest(x, n) largest integer e s.t. be ≤ b, e = blogb (x)c logint(x, b, {&z}) erase window w plotkill(w)
Hamming weight of integer x hammingweight(x) CRT: solve z ≡ x and z ≡ y chinese(x, y) copy w to w2 with offset (dx, dy) plotcopy(w, w2 , dx, dy)
digits of integer x in base B digits(x, {B = 10}) minimal u, v so xu + yv = gcd(x, y) gcdext(x, y) clips contents of w plotclip(w)
sum of digits of integer x in base B sumdigits(x, {B = 10}) continued fraction of x contfrac(x, {b}, {lmax}) scale coordinates in w plotscale(w, x1 , x2 , y1 , y2 )
integer from digits fromdigits(v, {B = 10}) last convergent of continued fraction x contfracpnqn(x) ploth in w plotrecth(w, X = a, b, expr, {flag}, {n})
ceiling/floor/fractional part ceil, floor, frac rational approximation to x (den. ≤ B) bestappr(x, {B}k) plothraw in w plotrecthraw(w, data, {flag})
round x to nearest integer round(x, {&e}) recognize x ∈ C as polmod mod T ∈ Z[X] bestapprnf(x, T ) draw window w1 at (x1 , y1 ), . . . plotdraw([[w1 , x1 , y1 ], . . .])
truncate x truncate(x, {&e}) Characters Low-level Rectwindow Functions
gcd/LCM of x and y gcd(x, y), lcm(x, y) set current drawing color in w to c plotcolor(w, c)
Let cyc = [d1 , . . . , dk ] represent an abelian group G = ⊕(Z/dj Z) ·
gcd of entries of a vector/matrix content(x) current position of cursor in w plotcursor(w)
gj or any structure G affording a .cyc method; e.g. znstar(q, 1)
Primes and Factorization write s at cursor’s position plotstring(w, s)
for Dirichlet characters. A character χ is coded by [c1 , . . . , ck ] such
extra prime table addprimes() move cursor to (x, y) plotmove(w, x, y)
that χ(gj ) = e(nj /dj ).
add primes in v to prime table addprimes(v) move cursor to (x + dx, y + dy) plotrmove(w, dx, dy)
χ · ψ; χ−1 ; χ · ψ −1 ; χk charmul, charconj, chardiv,, charpow draw a box to (x2 , y2 ) plotbox(w, x2 , y2 )
remove primes from prime table removeprimes(v)
order of χ charorder(cyc, χ) draw a box to (x + dx, y + dy) plotrbox(w, dx, dy)
Chebyshev π(x), n-th prime pn primepi(x), prime(n)
kernel of χ charker(cyc, χ) draw polygon plotlines(w, lx, ly, {flag})
vector of first n primes primes(n)
χ(x), G a GP group structure chareval(G, χ, x, {z}) draw points plotpoints(w, lx, ly)
smallest prime ≥ x nextprime(x)
Galois orbits of characters chargalois(G) draw line to (x + dx, y + dy) plotrline(w, dx, dy)
largest prime ≤ x precprime(x)
Dirichlet Characters draw point (x + dx, y + dy) plotrpoint(w, dx, dy)
factorization of x factor(x, {lim})
. . . selecting specific algorithms factorint(x, {flag = 0}) initialize G = (Z/qZ)∗ G = znstar(q, 1) draw point (x + dx, y + dy) plotrpoint(w, dx, dy)
n = df 2 , d squarefree/fundamental core(n, {f l}), coredisc convert datum D to [G, χ] znchar(D) Convert to Postscript or Scalable Vector Graphics
certificate for (prime) N primecert(N ) is χ odd? zncharisodd(G, χ) The format f is either "ps" or "svg".
verifies a certificate c primecertisvalid(c) real χ → Kronecker symbol (D/.) znchartokronecker(G, χ) as ploth plothexport(f, X = a, b, expr, {flag}, {n})
convert certificate to Magma/PRIMO primecertexport conductor of χ zncharconductor(G, χ) as plothraw plothrawexport(f, lx, ly, {flag})
recover x from its factorization factorback(f, {e}) [G0 , χ0 ] primitive attached to χ znchartoprimitive(G, χ) as plotdraw plotexport(f,[[w1 , x1 , y1 ], . . .])
x ∈ Z, |x| ≤ X, gcd(N, P (x)) ≥ N zncoppersmith(P, N, X, {B}) induce χ ∈ Ĝ to Z/N Z zncharinduce(G, χ, N )
divisors of N in residue class r mod s divisorslenstra(N, r, s) χ
Q p znchardecompose(G, χ, p)
Divisors and multiplicative functions p|(Q,N ) χp znchardecompose(G, χ, Q)
number of prime divisors ω(n) / Ω(n) omega(n), bigomega complex Gauss sum Ga (χ) znchargauss(G, χ)
divisors of n / number of divisors τ (n) divisors(n), numdiv Conrey labelling
sum of (k-th powers of) divisors of n sigma(n, {k}) Conrey label m ∈ (Z/qZ)∗ → character znconreychar(G, m)
Möbius µ-function moebius(x) character → Conrey label znconreyexp(G, χ)
Ramanujan’s τ -function ramanujantau(x) log on Conrey generators znconreylog(G, m)
Combinatorics conductor of χ (χ0 primitive) znconreyconductor(G, χ, {χ0 })
factorial of x x! or factorial(x) True-False Tests
binomial coefficient x

k binomial(x, {k}) is x the disc. of a quadratic field? isfundamental(x)
Bernoulli number Bn as real/rational bernreal(n), bernfrac is x a prime? isprime(x)
Bernoulli polynomial Bn (x) bernpol(n, {x}) is x a strong pseudo-prime? ispseudoprime(x)
n-th Fibonacci number fibonacci(n) is x square-free? issquarefree(x)
Stirling numbers s(n, k) and S(n, k) stirling(n, k, {flag}) is x a square? issquare(x, {&n})
number of partitions of n numbpart(n) is x a perfect power? ispower(x, {k}, {&n})
k-th permutation on n letters numtoperm(n, k) is x a perfect power of a prime? (x = pn ) isprimepower(x, &n})
convert permutation to (n, k) form permtonum(v) . . . of a pseudoprime? ispseudoprimepower(x, &n})
order of permutation p permorder(p) is x powerful? ispowerful(x) Based on an earlier version by Joseph H. Silverman
signature of permutation p permsign(p) is x a totient? (x = ϕ(n)) istotient(x, {&n}) July 2018 v2.35. Copyright c 2018 K. Belabas
Multiplicative groups (Z/N Z)∗ , F∗ q is x a polygonal number? (x = P (s, n)) ispolygonal(x, s, {&n}) Permission is granted to make and distribute copies of this card provided the
Euler φ-function eulerphi(x) copyright and this permission notice are preserved on all copies.
is pol irreducible? polisirreducible(pol)
multiplicative order of x (divides o) znorder(x, {o}), fforder Send comments and corrections to [email protected]

primitive root mod q / x.mod znprimroot(q), ffprimroot(x)


Graphic Functions
structure of (Z/nZ)∗ znstar(n) crude graph of expr between a and b plot(X = a, b, expr)
discrete logarithm of x in base g znlog(x, g, {o}), fflog High-resolution plot (immediate plot)
Kronecker-Legendre symbol ( x y) kronecker(x, y) plot expr between a and b ploth(X = a, b, expr, {flag}, {n})
quadratic Hilbert symbol (at p) hilbert(x, y, {p}) plot points given by lists lx, ly plothraw(lx, ly, {flag})
terminal dimensions plothsizes()

You might also like