What is Maple and what can it do?

First, Maple is a glorified calculator and it can do arithmetic operations.

> 3+4;

[Maple Math]

> 37*555;

[Maple Math]

> 2^1024;

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]


Every object in Maple is essentially one of: a number, a name, a list, a set, or a procedure. Some examples of valid expressions are below. Pressing enter evaluates the expression and the symbol "%" refers to the last expression evaluated.

> sort([5,2,1,5,4,3,1,3,2]);

[Maple Math]

> sort({5,2,1,5,hi,3,1,3,2,4,bye});

[Maple Math]

> din:=1363/144.;

[Maple Math]

> din^4;

[Maple Math]

> sqrt(sqrt(%));

[Maple Math]


The language of Maple is based on PASCAL. It has many of the same elements but there are major differences. The following is a list of commands that I use on a regular basis:

seq- create a sequence of expressions separated by commas

> seq(i^2-10*i+20,i=1..10);

[Maple Math]

> mylst:=[seq(i^2-10*i+20,i=1..10)];

[Maple Math]

> myset:={seq(i^2-10*i+20,i=1..10)};

[Maple Math]

> [seq(evalb(x<0),x=mylst)];

[Maple Math]

nops - number of operations - returns the length of a list or size of a set

> nops(mylst);

[Maple Math]

> nops(myset);

[Maple Math]

for ### do od; - this is the for loop. You can either loop "for each element in a list or set" or "for a variable running from a value to a value." The word "od" marks the end of the for-do loop (alternatively, od can be replaced by "end do").

> for i from 1 to 10 do
evalb(i^2-10*i+20<0);
od;

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

if ### then else fi; - if an expression evauates to true then execute the first statement, otherwise execute the second statement

> d:=5;
if d<6
then print("less");
else print("more");
fi;

[Maple Math]

[Maple Math]

proc( names ) local vars; ### end; - this is the notation for a procedure the last line of the procedure is the value that is returned (unless a RETURN(####); command is encountered).

> myfunc:=proc(x);
evalb(x<0);
end;

[Maple Math]

> myfunc(4);

[Maple Math]

(names)-> ####; - This is a shorthand notation for a procedure, there can be no local variables using this shorthand notation

> myfunc2:=x->evalb(x<0);

[Maple Math]

> myfunc2(-4);

[Maple Math]

map - applys a function to every element in a list

> map(myfunc,mylst);

[Maple Math]

> map(myfunc2,mylst);

[Maple Math]

>