Basic Syntax Review
by
Jerry G. Ianni
Mathematics Department
LaGuardia Community College
Note: This worksheet was originally created in August 1998.
Algebra
The basic arithmetic operations of addition, subtraction, multiplication, division, and exponentiation are performed with the following keystrokes: +, -, *, /, ^. Commands in Maple which are intended to be executed immediately end with a semicolon.
> 5+7-3*12/9;
> 7^2-2^3;
The assignment operator := is used to assign expressions to locations in memory.
> a:=5+7-3*12/9;
> b:=7^2-2^3;
> a+b;
> c:=x^4+3*x^2-5*x;j:=x^3-x^2+3*x;c+j;
> sort(c+j,x);
> c*j;
> expand(c*j);
> factor(j);
> solve(j=0,x);
Functions
Functions are input using the assignment operator and a "two-piece" arrow formed with the dash and the greater-than symbol.
> f:=x->x^2+2;
> f(0);f(3);f(m);f(a);
> a:='a';
> f(a);
> f(x-5);
> expand(f(x-5));
> solve(f(x)=0);
Plots
The most elementary way to plot a function is to simply refer to it by name and invoke the "plot" command.
> plot(f);
The graph of the function
If you wish to make specific reference to the input values, then assign a letter to the input axis.
> plot(f(t),t);
The graph of the function
with respect to time
If you wish to make specific reference to the output values, then assign a letter to the output axis.
> plot(f(t),t,P);
The graph of the population
with respect to time
Finally, the visible domain and range values on the graph can be adjusted easily.
> plot(f(t),t=0..5,P=0..30);
The graph of the population
over the first 5 years
There are several other two-dimensional plotting features which should be explored in more advanced settings.