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

Basic Maple Commands

This document provides a summary of basic Maple commands organized into 10 categories: 1) General commands and conventions 2) Elementary number theory 3) Sets and lists structure 4) Operations on sets and lists 5) Character strings 6) Boolean expressions 7) Looping control 8) Conditionals 9) Complex numbers 10) Polynomials The document describes common Maple commands for each of these categories to perform basic computations and operations.

Uploaded by

Andrea Fields
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)
47 views4 pages

Basic Maple Commands

This document provides a summary of basic Maple commands organized into 10 categories: 1) General commands and conventions 2) Elementary number theory 3) Sets and lists structure 4) Operations on sets and lists 5) Character strings 6) Boolean expressions 7) Looping control 8) Conditionals 9) Complex numbers 10) Polynomials The document describes common Maple commands for each of these categories to perform basic computations and operations.

Uploaded by

Andrea Fields
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

Basic Maple Commands

Command

Description
1. General Commands and Conventions

f (a)

evaluating a function f at a; e.g. sin(P i)

command end/result displayed

/result not displayed

% (previously: )

output of previous line

cursor on name, click on help

help for name

settime := time(); expression;


time() settime;
a := expression;

to get elapsed time for computing an expression

an;

n-th power of a

sqrt(a);

the (exact) square root of a

evalf (expression, n);

numerical value of expression to n-digit accuracy

evalb(a = b);

logical comparison (gives true or f alse)

a[n];

n-th element of list a

plot(expression, x = a..b);

2-dim plot of expression for x between a and b

plot3d(expr, x = a..b, y = c..d);

3-dim plot of expr for x between a and b and y between c and d

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

assignment

2. Elementary Number Theory


iquo(a, b); or f loor(a/b);

integral part of the quotient a/b

irem(a, b); or modp(a, b);

remainder of division of a by b

f rac(x);

the fractional part of x

igcd(a, b);

the gcd of a and b

igcdex(a, b,0 x0 ,0 y 0 );

the extended gcd

x; y;

to extract the values of the above extended gcd

ithprime(n);

the n-th prime number

isprime(n);

test whether or not n is prime (gives true or f alse)

if actor(n);

factor n into its prime factors

a& n mod m; or P ower(a, n) mod m;

compute an mod m efficiently


mpl1

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 s consisting of the elements f (1),. . . ,


f (5); here f is an expression (depending on i)

a := [seq(f, i = 1..5)];

create the list a consisting of the elements f (1), . . . ,


f (5); here f is 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 i through j (inclusive)

select(k> k < m or k > n, a);

list a with elements m through n dropped

member(e, a);

test whether e occurs in list a (true or f alse)

member(e, a, p ); p;

the position(s) at which e occurs in a

type(s, set);

check whether s is a set (has type set); gives true


or f alse

type(a, list);

check whether s is a list (has type list); gives true


or f alse
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 s and t

s minus t

the set of elements which are in s but not in t

[op(a), op(b), . . .]

concatenate (join) the lists a, b, . . .

a := [e, op(a)];

add element e at the beginning of list a

a := [op(a), e];

add element e at the end of list a

a := subsop(i = e, a);

replace the ith element of the list a by e

a := subsop(i = N U LL, a);

delete ith element from list a

[a[1..n 1], e, a[n..nops(a)];

insert e at position n in list a

sort(a);

sort the elements of list a (into a standard order)

[select(bool, a)];

list consisting of the elements of a for which the


boolean-valued function bool is true

map(f, a);

apply the function f to each element of the list a

mpl2

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 str starting 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 st occurs in string str

s1.s2. . . . or 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 str is a string (true or f alse)


6. Boolean expressions

b := true; b := f alse;

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


f alse)

type(b, boolean)

check whether b is a boolean expression (true or


f alse)
7. Looping control

f or i to m do; expr; od;

evaluate expr repeatedly with i varying from 1 to m


in steps of 1

f or i f rom n to m by s do; expr; od;

evaluate expr repeatedly with i varying from n to m


in steps of s

while test do; expr; od;

evaluate expr until test becomes false

f or i f rom n to m by s while test


do; expr; od;

evaluate expr repeatedly with i varying from n to m


in steps of s as long as test is true

RET U RN (expr)

(explicit) return from a subroutine, assigning the


value expr to the subroutine
8. Conditionals

if test then statmt f i;

execute the statement (sequence) statmt only if test


is true

if test then statmt1 else statmt2 f i;

execute the statement (sequence) statmt1 if test is


true, otherwise execute statmt2

mpl3

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 x has


no value)

type(f, polynom(integer, x))

check that f is an integer polynomial in x

degree(f, x)

degree of f in x

coef f (f, x, n)

extract the coefficient of xn in f

coef f s(f, x)

list of coefficients of f (x)

lcoef f (f, x)

the leading (highest) coefficient of f (x)

tcoef f (f, x)

the constant (trailing) coefficient of f (x)

collect(f, x)

collect all coefficients of f which have the same powers in x

expand(expr)

distribute products over sums

sort(f )

sort into decreasing order

subs(x = a, f )

evaluate f (x) at x = a

Eval(f, x = a) mod p;

evaluate f (x) (mod p) at x = a

f mod n;

reduce the coefficients of f modulo n

quo(f, g, x); rem(f, g, x);

the quotient and remainder of division of f by g


(viewed as polynomials in x)

gcd(f, g, x)

the greatest common divisor of f (x) and g(x)

0 0 0 0

gcd(f, g, x, s , t )

the extended Euclidean algorithm of f (x) and g(x);


i.e. s, t satisfy f s + g t = g := gcd(f, g)

f actor(f )

factor f into its irreducible factors

F actor(f ) mod p

factor f modulo p

roots(f )

find the rational roots of f

interp(x, y, t)

The Lagrange Interpolation polynomial


mpl4

You might also like