maple-1
PDF · 4 pages · 61.3 KB
Open PDF file
A four-page quick-reference table of Maple commands, each with a short description. Sections cover general conventions, elementary number theory (gcd, primes, modular powers), sets and lists, character strings, boolean expressions, loops, conditionals, complex numbers, and polynomial operations including factoring mod p and interpolation. It sits in the Galois book update files from July 2013 and appears to be a supporting handout for computations; the author is not stated in the text.
AI-written summary; may contain errors.
Extracted text (machine-read; may contain errors)
Basic Maple Commands
Command Description
1. General Commands and Conventions
P i,exp(1),I the constants π,eandi
f(a) evaluating a function fata; e.g. sin(P i)
; command end/result displayed
: ” ” /result not displayed
% output of previous line
cursor on name , click on help help for name
settime :=time ();expression ;
time ()−settime ;to get elapsed time for computing an expression
a:=expression ; assignment
a+b, a−b, a∗b, a/b Addition, subtraction, mulitplication, division of a
byb
aˆn; n-th power of a
sqrt(a); the (exact) square root of a
evalf (expression, n ); numerical value of expression ton-digit accuracy
evalb (a=b); logical comparison (gives true orfalse )
a[n]; n-th element of list a
plot(expression, x =a..b); 2-dim plot of expression forxbetween aandb
plot3d(expr, x =a..b, y =c..d); 3-dim plot of expr forxbetween aandbandybe-
tween candd
f:=x−> expr definition of a one-variable function f(x)
f:= (x, y, . . . )−> expr definition of multi-variable function f(x, y, . . . )
a:=proc(x, y)local z, w ;...;end; definition of subroutine a
2. Elementary Number Theory
iquo(a, b); or floor (a/b); integral part of the quotient a/b
irem (a, b); or modp (a, b); remainder of division of abyb
frac (x); the fractional part of x
igcd(a, b); the gcd of aandb
igcdex (a, b,/primex/prime,/primey/prime); the extended gcd
x;y; to extract the values of the above extended gcd
ithprime (n); then-th prime number
isprime (n); test whether or not nis prime (gives true orfalse )
ifactor (n); factor ninto its prime factors
a&∧n mod m ; orP ower (a, n)mod m ; compute anmod mefficiently
mpl–1
Command Description
3. Sets and Lists: Basic Structure
s:={1,2,3,4,5}; defines a set s: an unordered sequence of elements
a:= [1 ,2,3,4,5]; defines a list a: an ordered sequence of elements
s:={seq(f, i= 1..5)}; create the set sconsisting of the elements f(1),. . . ,
f(5); here fis an expression (depending on i)
a:= [seq(f, i= 1..5)]; create the list aconsisting of the elements f(1), . . . ,
f(5); here fis an expression (depending on i)
nops (a); the number of elements in list a
a[i] the ith element of the list a
a[i..j] or [ op(i..j, a )] the list consisting of elements ithrough j(inclusive)
a[select (k−> k < m or k > n ,
1..nops (a))];listawith elements mthrough ndropped
member (e, a); test whether eoccurs in list a(true orfalse )
member (e, a,/primep/prime);p; the position(s) at which eoccurs in a
type(s, set ); check whether sis a set (has type “set”); gives true
orfalse
type(a, list ); check whether sis a list (has type “list”); gives true
orfalse
4. Operations on Sets and Lists
s:=convert (a, set ); convert a list to a set
a:=convert (s, list ); convert a set to a list
s union t ; or ` union `(s, t, . . . ) combine sets s,t, . . . , removing repeated elements
s intersect t ; intersection of sets sandt
s minus t the set of elements which are in sbut not in t
[op(a), op(b), . . .] concatenate (join) the lists a, b, . . .
a:= [e, op(a)]; add element eat the beginning of list a
a:= [op(a), e]; add element eat the end of list a
a:=subsop (i=e, a); replace the ith element of the list abye
a:=subsop (i=NULL, a ); delete ith element from list a
[op(a[1..n−1]), e, op (a[n..nops (a)])]; insert eat position nin list a
sort(a); sort the elements of list a(into a standard order)
[select (bool, a )]; list consisting of the elements of afor which the
boolean-valued function bool is true
map(f, a); apply the function fto each element of the list a
mpl–2
Command Description
5. Character Strings
str:= ”T his is a string ”; defining a character string
length (str); the number of characters in a string
substring (str, m..n ); extract a substring from string strstarting with the
mth and ending with the nth character
[seq(substring (str, k..k ), k= 1..
length (str)]give the list of characters in a string
searchtext (st, str ) find the place where stoccurs in string str
cat(s1, s2, . . .) join the strings s1,s2, . . . together
convert (expr, string ); convert an expression to a string (textual form)
type(str, string ) check whether stris a string ( true orfalse )
6. Boolean expressions
b:=true;b:=false ; assigning true/false to the variable b
=, <>, <, < =, >, > = relation operators (equal, not equal, less than, etc.);
can be used to form boolean expressions
and, or, not logical operators ( →boolean expressions)
evalb (bool) evaluate the boolean expression bool (gives true or
false )
type(b, boolean ) check whether bis a boolean expression ( true or
false )
7. Looping control
for i to m do ;expr ;od; evaluate expr repeatedly with ivarying from 1 to m
in steps of 1
for i from n to m by s do ;expr ;od;evaluate expr repeatedly with ivarying from ntom
in steps of s
while test do ;expr ;od; evaluate expr until test becomes false
for i from n to m by s while test
do;expr ;od;evaluate expr repeatedly with ivarying from n to m
in steps of sas long as test is true
RET URN (expr ) or return (expr ) (explicit) return from a subroutine, assigning the
value expr to the subroutine
8. Conditionals
if test then statmt fi ; execute the statement (sequence) statmt only if test
is true
if test then statmt 1else statmt 2fi;execute the statement (sequence) statmt 1iftest is
true, otherwise execute statmt 2
mpl–3
Command Description
9. Complex Numbers
z:=x+y∗I; defining a complex number
abs(expr ); the absolute value of expr
argument (expr ) the argument of expr
Re(expr );Im(expr ); the real and imaginary part of expr
conjugate (expr ); the complex conjugate of expr
evalc (expr ) evaluating an expression (as a complex number)
convert (expr, polar ) convert expr to its polar form
type(expr, complex ) check that expr has type “complex”
10. Polynomials
f:=x∧n+a1∗x∧(n−1) + . . .; defining a polynomial f=f(x) (assuming that xhas
no value)
type(f, polynom (integer, x )) check that fis an integer polynomial in x
degree (f, x) degree of finx
coeff (f, x, n ) extract the coefficient of xninf
coeffs (f, x) list of coefficients of f(x)
lcoeff (f, x) the leading (highest) coefficient of f(x)
tcoeff (f, x) the constant (trailing) coefficient of f(x)
collect (f, x) collect all coefficients of fwhich have the same pow-
ers in x
expand (expr ) distribute products over sums
sort(f) sort into decreasing order
subs(x=a, f) evaluate f(x) atx=a
Eval (f, x=a)mod p ; evaluate f(x) (mod p) atx=a
f mod n ; reduce the coefficients of fmodulo n
quo(f, g, x );rem(f, g, x ); the quotient and remainder of division of fbyg
(viewed as polynomials in x)
gcd(f, g, x ) the greatest common divisor of f(x) and g(x)
gcd(f, g, x,/primes/prime,/primet/prime) the extended Euclidean algorithm of f(x) and g(x);
i.e.s,tsatisfy f∗s+g∗t=g:=gcd(f, g)
factor (f) factor finto its irreducible factors
F actor (f)mod p factor fmodulo p
roots (f) find the rational roots of f
interp (x, y, t ) The Lagrange Interpolation polynomial
mpl–4