Maple Tutorial
Math 1180 - Mathematics for Life
Scientists II
Spring 2006
Getting Started
Math Computer Lab
The computer lab in LCB 115 is
reserved for our class Math 1180, every Tuesday from 9:40 a.m. to
11:35 a.m. It is recommended that you attend them to get assistance
from the lab TA. Additionally, you also have access to the computer lab
located at the T. Benny Rushing Mathematics Center (located
underneath the plaze connecting JWB and LCB) Room 155C. The hours for
that lab are
Monday to Thursday - 8:00 a.m. to 8:00
p.m.
Friday - 8:00 a.m. to 6:00 p.m.
Closed on weekends and university
holidays
Computer Account
Almost all students registered in any
math class will aready have accounts set-up. These are created from
university class lists, so students who registered late may not be
included yet.
Your login name is of the form c-azbx
where azbx are as follows:
a is the first letter of your last name
z is the last letter of your last name
b is the first letter of your first name
x is your middle initial
If someone has the same initial as
you, your login may be c-azbx1 or c-azbx2, etc.
Passwords
- Your initial password is azbx (as above) followed by the last 4
digits of your student ID number. If you have a login name with
a number at the end, the number is NOT in your password.
Your login name and password are all lowercase with no spaces.
Common Desktop Environment
Once logged in, you will see the common desktop environment (CDE) which
is the default environment of our unix based system. The first thing to look
for is the computer icon towards the bottom of the screen. Click on this
icon to open an xterm window.
Changing password
- On the xterm window, type passwd then hit enter. You
will then be prompted to enter your initial password followed
by your desired new password. Your password should consist of at
least 6 characters (upper and lower case letters and digits).
Logging out
- In CDE, there is a logout or exit icon at the bottom of your desktop.
You can also logo-out by right-clicking on your mouse and then
choosing the logout option.
Printing
You can print by clicking on the printer button above (or go to File
and select Print)
Choose "Print Command" option and then type
lpr -l -P printername
That "-l" is dash-lower-case-L. Then hit "Print" button on the
bottom of the print window
Printer names are
lcb115 in room LCB 115
mc155c in the Math Center
Survival Guide
A few things to remember and
what you need to do first when things don't work out
* Command lines should begin with the
prompt ">"
* End every command with
a semicolon ";"
or a colon ":" If you end with a semicolon, you will see a visible
output while ending with a colon will suppress your output.
* Save your work before exiting.
Better yet, just save your work often.
* When you get an error message, always check if you
have the correct number of brackets. Also check if your variable is
called correctly; variable
name and function name are case-sensitive.
* You can enter explanatory comments
in a command line by inserting a "#" Any text to the left of "#"
will be disregarded .
* You can use Maple in a text editor
mode by clicking the "T" button at the very top. To go back to the
command line mode, click on the "[>" button next to the "T" .
* You can get help by clicking the
Help button on the right hand corner of the Maple window. Choose "Topic
Index" and you can search for what you are looking for.
Additionally, you can easily look up how to do certain thing if
you already know what the command is. For example, to find out
how to use the plot
command,
just type
> ?plot
A window with all the explanation will
pop up.
Answers to Frequently Asked
Questions
(courtesy of Fred Adler)
1. Why does Maple assert that my graph
is empty or plot an empty graph?
Possible reasons include
- You typed ``pi" instead of ``Pi" for
the number p (3.14159...).
- Some parameter name doesn't match.
Maple pays attention to the difference between capital letters and
small letters. And to the difference between the number 0 and the
letter o.
- You typed = instead of := when
defining a parameter.
- You tried to use curly brackets or
square brackets in defining a function. Maple only likes regular
parentheses.
- You forgot to give your function an
argument. You must include the x in
> plot (f(x),x=0..1);
to get Maple to plot the function f.
2. What's the deal with functions and
expressions?
An expression is a shorthand name for a combination of letters. A
function defines an operation. You can define an expression g by
> g := k*x*(1-x);
and a function f by
> f := x -> k*x*(1-x);
Never use expressions unless you have a very good reason (they have
some quirks).
3. How do I type Greek letters?
Type them in English, remembering to leave a space at the end. For
example a is typed ``alpha", b is typed ``beta", g is typed ``gamma", l
is typed ``lambda", and t is typed ``tau". To set a = 5, type
> alpha := 5;
4. Why does my graph
look wrong?
Make sure that you used the right kind of brackets. Remember that a
graph of f and g can be plotted together with
> plot ([f(x),g(x)],x=0..1);
If f or g is defined wrong (see 2) it will not be plotted.
5. Why won't my exponential functions
compute?
Maple doesn't know what to do with ex.
You've got to use the name of the function, exp(x).
6. Why does it say
``syntax error" when my line is perfect?
Move back to it with the mouse or the
arrows and hit return to try it again. Maple may just be acting moody.
Working with Maple
It is a good habit to begin
with a restart command. It will
clear all the memory so you can easily redo things
Arithmetic operation
Use evalf to compute decimal
values
You can specify the number of digits
of accuracy by using [ ] after evalf. Below, we evaluate to 3 digits
accuracy
Some Important Numbers
The number
. Note
that you need to type it with capital P.
The number e. In Maple, you call
it by using the
exp
function
Defining Functions and Variables
Define a variable/parameter by using
":=" not just "=".
You can just refer back to the
variable from now on. Maple will remember that a has the value of 3.5
It is useful to know how to define a function. You will use this
often when trying to graph, when doing calculus (differentiating and
integrating) and also while working with differential equations.
The arrow is typed with a dash
followed by a "greater than" sign (no space between them). This
represents the function as an operation, taking x and mapping it to
x*(1-x).
Now evaluate f at x=0.5
You can study a family of functions by
including a parameter which you will need to
define i.e give it a numerical value. Below, we use the parameter k.
Now, define what k is supposed to be.
Then change it and see what happens.
Differentiation and Integration
Use the command diff to differentiate an
expression.
You can also take higher order
derivative. For example, take the second derivative
Specify the n-th derivative with
respect to x, by typing x n time. The fifth order derivative of sin(x)
is
| >
|
diff(sin(x),x,x,x,x,x); |
You can also take derivative of a
function. For example, define this nasty looking functionand then
differentiate it with respect its argument x.
| >
|
f:= x -> exp(sin(x^5))*x^3;
|
To integrate, use the command int. Note that below, the
integration constant is dropped.
You can also compute definite
integral. For example let's compute the integral below
Maple is not god. Sometimes, it does
not know how to do things either. Below for example, Maple just return
the exact expression, i.e. it cannot find an elementary function for
the anti-derivative.
| >
|
int(t^3*exp(sin(t)),t);
|
You can still compute a numerical
approximation for a definite integral
| >
|
evalf(int(t^3*exp(sin(t)),t=0..1));
|
You can even integrate to infinity for
some nice functions.
| >
|
evalf(int(exp(-x),x=0..infinity));
|
Plotting
First, load the plot library
Warning, the name changecoords has been
redefined
To plot something, use the command plot
![[Plot]](images/maple_tutorial_30.gif)
You can also change the color of the
plot and put title as shown below. Note that the title need to be put
using single quote mark
'....' instead of the double quotation mark "
| >
|
plot(x^2,x=-1..1,
color=blue,title='parabola'); |
![[Plot]](images/maple_tutorial_31.gif)
You can plot multiple curves on the
same figure plot by using the square brackets [ ].
| >
|
plot([x^2, x^3, x], x=-1..1,
color=[blue,red,green]); |
![[Plot]](images/maple_tutorial_32.gif)
You can plot a function as well
![[Plot]](images/maple_tutorial_34.gif)
Solving Differential Equations
On your first assignment, you will
learn how to use the dsolve command to solve a
differential equation. First, learn how to write a differential
equation. You can define an equation using the ":=" like usual.
| >
|
eqn1:= diff(y(t),t)=3*y(t)+t;
|
Now, solve the differential equation.
Note that because no initial condition is specified, there is an
arbitrary integration constant included.
Of course, you can also solve the
equation directly without naming it first.
| >
|
dsolve(diff(y(t),t)=3*y(t)+t, y(t));
|
Note that you have to refer to the
argument of your state variable. That is, you need to use y(t) not just
y when writing your equation, otherwise, Maple will not solve it for
you. See below
| >
|
dsolve(diff(y(t),t)=3*y+t, y(t)); |
Error, (in ODEtools/info) y(t) and y cannot
both appear in the given ODE.
You can solve using an initial
condition by defining your problem as a system using the curly bracket
{your equation, initial condition}
| >
|
dsolve({eqn1, y(0)=1}, y(t));
|