> restart:
MAPLE: A QUICKIE COURSE
Probably the best way to organize a course in Maple is around the data types. I do not know how many data types there are, but many things not usually thought of as a data type (a graph, for instance) are data types in Maple. Data types are not type declared in maple. The type is recognized by form or usage. Also Maple is not a compiled, but rather an interactive language, meaning, that one gives a command, executes it, gives another command, executes it ,etc.
The symbol := (colon equal) should be read "is the name of". This is the closest thing Maple has to an assignment operator, though that is not precisely what it is. Any object (including for example a graph) may be named using this symbol. The symbol = is used in equations and options, but is not an assignment operator. Also it is helpful to know that the symbol % serves as a name for the output of the previous command. Weird, but the return (enter) key serves as the EXCUTE key, and thus can not be used in editing.
1. Rational type
Maple prefers the rational type and will always do arithmetic with rational numbers if it can.
> 2/3 + 4/7;
> 23/78+(45/89)*(16/13);
2. Floating point type
A decimal point anywhere in an expression makes that expression floating point (real). A rational number may also be converted to floating point with the evalf command.
> 1.34*6.87;
> 4.^2;
> 2./3 + 4/7;
> Pi;
> evalf(Pi,22);
> evalf(2/3,5);
The above command evaluates as floating point (hence evalf) the rational number 2/3 to 5 significant digits.
3. Complex type
> (11-4*I) / (5+7*I);
> evalf(%);
The imaginary unit is represented by I in Maple. The evalf converts the output of the above division ( % ) to floating point. We could have done it this way:
> (11.-4.*I) / (5. + 7.*I);
>
4. Equation
Read the following as: eq6 is the name of the equation x^2 - 2*x - 24 = 0. Having named this equation, we can refer to it by name. For example, solve eq6 for x.
> eq6 := x^2 - 2*x - 24 = 0;
> solve(eq6,x);
5. Expression
The following gives the name ex3 to the expression x^3 - 4*x. We can then refer to it by name. For example, we can factor the expression.
> ex3 := x^3 - 4*x;
> factor(ex3);
> ex3*ex3 - 5*ex3 + ex3^3;
> expand(%);
6. System of equations
A system of equations consists of equations written within braces separated by commas. The following system named sys32 is solved using the solve command. The solve command must state what variables are to be solved for.
> sys32 := {2*x - 3*y = 5, -6*x + 7*y = 2};
> solve(sys32, {x,y});
> sys := {y = 2 + 3*x, x^2 + y^2 = 25};
> solve(sys,{x,y});
> allvalues(%);
> evalf(%);
Sometimes Maple does not give all solutions to a system. Clearly the system above has 2 solutions. The command allvalues(%) says: I want all the solutions of the previous ( % ) system! Note that Maple does its best to give the solutions as rational numbers and surds. The command evalf(%) says: I want all these answers given in floating point form.
>
7. Function
The standard form f(x) = x^4 -7*x^3+8*x^2-13*x+8 does not work as a function definition in Maple. The form should be read: f is the name of the function such that if I input x I will get back out x^4 -7*x^3+8*x^2-13*x+8. That is, the form is
name of function := what goes in -> what comes out.
The arrow is a minus followed by a greater than.
> f:= x -> x^4 - 7*x^3 + 8*x^2 - 13*x + 8;
Once the function is defined, however, one can use the f(x) notation in the usual way for evaluation.
> f(3); f(-6.78); f(c^2-1); expand(%);(f(x+h)-f(x))/h; expand(%);
Maple is organised into packages so that one need not have everything in memory at one time. All the above is in the basic package. To do calculus one must call up the student package. I have no idea why it is called student.
> with(student):
> f(x);
The derivative command diff does not operate on functions, but on expressions. For example
> Diff(x^2*exp(.5*x^2),x) = diff(x^2*exp(.5*x^2),x);
Note that Diff spelled with a capital does not do anything, but can be useful for writing out what the problem is. But diff with lower case is active. That is, it actually computes the derivative. Same with int. Both diff and int must have a variable at the end which says what the derivative and integral are with respect to (equivalent to the dx in Leibnitz's notation). Also one might notice from a few lines up that if f is a function, then f(x) has type expression and may be differentiated or integrated.
>
> Diff(f(x),x) = diff(f(x),x);
> Diff(f(x),x,x) = diff(f(x),x,x);
> int(x^2*sin(3*x),x);
> Int(x^3,x) = int(x^3,x) + c;
> Int(sin(x),x=0..Pi); `Value of integral is:`,evalf(%);
8. Multivariate function
This section should be self-explanatory if you understood the previous section.
> g:= (x,y) -> x^2*y + 3*x*y - 87*y^3;
> diff(g(x,y),x);
> diff(g(x,y),y);
> Diff(g(x,y),x,y) = diff(g(x,y),x,y);
> Diff(g(x,y),y,y)=diff(g(x,y),y,y);
9. Graph
It struck me as a bit weird at first to consider a graph as a data type. there are several ways to plot graphs, but as far as I can tell, they are all the same type since they can all be displayed together. Graphs computed certain ways require plots, stats,statplots, fit and possibly other packages.
> with(plots):with(stats):with(statplots):with(fit):
> h:=x->x^3-2*x^2+5;
> plot(h(x),x=-3..4,color=green);
> pic1:=%: #NAMES THE OUTPUT OF THE LAST COMMAND (a graph) pic1
> k:=x->10*sin(3*x);
> plot(k(x),x=-5..5,color=blue);
> pic2:=%:
> display(pic1,pic2); #DISPLAYS THE TWO GRAPHS pic1 and pic2 TOGETHER.
> x := t -> 5*cos(t) + 2;
> y :=t -> 4*sin(3*t);
This is how a parametric plot is done. This is the example I did in class but was not quite prepared for. For graphs that represent trajectories (orbits) in space one should use the option scaling=CONSTRAINED so that x and y axes have the same scale. Otherwise, the orbits will be distorted.
> plot([x(t),y(t),t=0..5], color=blue,scaling=CONSTRAINED,labels=[`X`,`Y`]);
> pic_orbit:=%:
Parametric graphs do not allow for time tags. This can be remedied by plotting the set of points on the orbit at times 0, 1, 2, 3, 4, 5 and adding them to the graph. Points in Maple use brackets rather than parentheses.
> Tags:=[ [7.,0],[4.70,.56],[-.08,-1.12],[-2.95,1.65],[-1.27,-2.15],[3.42,2.60] ];
> plot(Tags,style=point,symbol=circle,color=red,title=`The circles represent the position on the orbit at t=0,1,2,3,4,5. t=0 is at[7,0]`);
> pic_tags:=%:
> display(pic_orbit,pic_tags);
A Maple worksheet can be saved as an html file so that it may be used as a web page and seen with Explorer or Netscape. All outputs from Maple are displayed as .gif files when a Maple worksheet is saved as html. This means that each graph can be edited with photo software. The following had the time tags and arrows added by Paintshop Pro8.

A curve which is not a function of x (such as a circle) may be parameterized and plotted as parametric or plotted by implicitplot. Since x and y have acquired values earlier in the program, they need to be reset before using them again as variables. This what x:='x' and y:='y' does.
> x:='x':y:='y':equat45 := (x-1)^2 + (y-2)^2 = 22;`equat45 is a circle centered at [1,2] with radius`,sqrt(22);
> implicitplot(equat45,x=-10..10,y=-10..10,color=magenta,scaling=CONSTRAINED);