> 134 + 17;
(you type)
151
(Maple's answer)
Basic rules: you must end each line in Maple with a semi-colon, otherwise Maple will not do anything. After you input a line ending with a semi-colon by hitting return, Maple will either produce an output or echo command, signifying the fact that it "heard" you. Try now
> 145 * 45 + 2^8;
(you type)
6781
(Maple's answer)
The basic operations are
+ for sum,
the asterisk * for
multiplication, / for
division and the caret ^ to
indicate powers. It is important to observe the following for rational
numbers:
> 36/9;
(you type)
4
(Maple's answer)
> 36/11;
(you type)
36/11
(Maple's answer)
Maple displays the exact answers. If you want an approximation by a decimal number, you can use the Maple function evalf( );
> evalf(36/11);
(you type)
3.272727273
(Maple's answer)
> % + 5;
(you type)
8.272727273
(Maple's answer)
The operator % is simply a shorthand notation identifying the previous result. You can use parentheses as usual in algebra. Do not use square brackets [ ] or curly brackets { } as algebraic delimeters, since they have special meaning in Maple.
Maple includes all basic functions, such as sin, cos, exp, tan etc. Their arguments should be enclosed in round parentheses. For example,
> cos(0);
(you type)
1
(Maple's answer)
Maple knows the standard mathematical constants, such as pi=3.141592... denoted by Pi, and the base of natural logarithm, e = 2.718281828... It works with them as exact quantities.
> evalf(Pi);
(you type)
3.141592654
(Maple's answer)
> sin(3*Pi/2);
(you type)
-1
(Maple's answer)
> exp(1);
(you type)
e
(Maple's answer)
> ln(exp(5));
(you type)
5
(Maple's answer)
> y:= 2*cos(x)^2 + 6*x;
(you type)
y:= 2 cos(x)2 + 6x (Maple's
answer)
Entering y:= 2*cos(x)^2 + 3*x; assigns to the variable y the expression 2 cos(x)2 + 6x. Maple can differentiate the expression y with respect to x :
> diff(y,x);
(you type)
-4 cos(x) sin(x) + 6 (Maple's answer)
or integrate
> int(y,x);
(you type)
cos(x) sin(x) + x + 3x2 (Maple's answer)
> int(y, x=0..1);
(you type)
cos(1) sin(1) + 4 (Maple's answer)
> evalf(int(y, x=0..1));
(you type)
4.454648713 (Maple's
answer)
As you see, Maple's answers are not always decimal. In fact, Maple tries not to evaluate an expression until it is absolutely necessary. If you want to obtain a decimal answer, use evalf( ) as above. Maple can compute the values of the expression y for a given value of x :
> subs(x=0, y);
(you type)
2
(Maple's answer)
So the command subs(x=a,
y); substitutes
x=a in
y. Notice that the substitution
does not make Maple forget the relationship between x
and y.
> plot(x^2 - 5*x + 6,x=-1..5); (you type)
will return a graph of the function f(x) = x2 - 5x + 6 for the values of x between -1 and 5. The graph will be displayed inline or in a separate window depending on how you set up the "Plot display" option in your "Options" menu.
In general, to plot the graph of
a function of one variable, the command is
Here, "expression" can be something like x^2 - 5*x + 6, or if you have assigned this expression to a variable, say w, then "expression" can be just w. Also, "range" is the range of the independent variable, and it is entered as follows. Suppose the independent variable is x and you want a plot with x in the interval between -1 and 5. Then you type x=-1..5. For example, to plot the graph of the function g(x)= sin(2x), x=-Pi..Pi, you may type
> z:= sin(2*x);
> plot(z,x=-Pi..Pi);
or simply
> plot(sin(2*x),x=-Pi..Pi);
It is sometimes helpful to plot graphs of one or more functions simultaneously. Maple can do this, provided the range of the independent variable is the same for all functions. Here's how it is done. Suppose you have defined two functions of x, say y and z. To plot both of their graphs simultaneously, enter
> plot({y,z},range);
where range is common to both functions and to be entered as explained above. Note that the two functions go into the "expression" field of plot, inside curly brackets and separated by a comma. You can do this with more than two functions.
> y:= x^4-5x^2+4;
> z:= diff(y,x);
> plot({y,z},x=-2.1..2.1);
Notice that the local max and min of y correspond the zeroes of its derivative, y is increasing where its derivative is positive etc.
> with(plots);
Try the following exercise: enter exactly the following
> with(plots);
(return)
> polyhedraplot([0,0,0],polytype=icosahedron,
style=patch,scaling=constrained);
(return)
You should get a new window with a picture of a solid dodecahedron (instead of "icosahedron" you can also type "dodecahedron", "octahedron", "hexahedron" or "tetrahedron"). You can now rotate it in space as follows: with the pointer in the picture window, click and hold the left mouse button. Drag the pointer - this has the effect of rotating the picture.
Now try changing the style of display.
Open the "Style" menu then choose for example "Wireframe". Experiment with
the remaining styles. Try for example the style"Contour". What do you think
Maple is displaying ? Experiment with other menus. Try especially the "Axes"
menu.
> solve(x^2+3*x-10=0);
> solve(exp(2*x)+1=0);
> solve(x+y=0);
The commands simplify( ); and expand( ); are self-explanatory. Try the following:
> expand((x-2)*(x+2)*(x^2+9));
> expand(sin(x+y));
> simplify(cos(x)^2+sin(x)^2);