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;

[Maple Math]

> 7^2-2^3;

[Maple Math]

The assignment operator := is used to assign expressions to locations in memory.

> a:=5+7-3*12/9;

[Maple Math]

> b:=7^2-2^3;

[Maple Math]

> a+b;

[Maple Math]

> c:=x^4+3*x^2-5*x;j:=x^3-x^2+3*x;c+j;

[Maple Math]

[Maple Math]

[Maple Math]

> sort(c+j,x);

[Maple Math]

> c*j;

[Maple Math]

> expand(c*j);

[Maple Math]

> factor(j);

[Maple Math]

> solve(j=0,x);

[Maple Math]

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;

[Maple Math]

> f(0);f(3);f(m);f(a);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> a:='a';

[Maple Math]

> f(a);

[Maple Math]

> f(x-5);

[Maple Math]

> expand(f(x-5));

[Maple Math]

> solve(f(x)=0);

[Maple Math]

Plots

The most elementary way to plot a function is to simply refer to it by name and invoke the "plot" command.

> plot(f);

[Maple Plot]

The graph of the function [Maple Math]

If you wish to make specific reference to the input values, then assign a letter to the input axis.

> plot(f(t),t);

[Maple Plot]

The graph of the function [Maple Math] with respect to time [Maple Math]

If you wish to make specific reference to the output values, then assign a letter to the output axis.

> plot(f(t),t,P);

[Maple Plot]

The graph of the population [Maple Math] with respect to time [Maple Math]

Finally, the visible domain and range values on the graph can be adjusted easily.

> plot(f(t),t=0..5,P=0..30);

[Maple Plot]

The graph of the population [Maple Math] over the first 5 years

There are several other two-dimensional plotting features which should be explored in more advanced settings.