-------------------------------------------------------------------------
PHYS210 2009-09-24 LAB SUMMARY
Brief introduction to use of xmaple & maple
-------------------------------------------------------------------------
1) Open a terminal window, and within it change to your home directory,
create a sub-directory called 'maple' and cd to it
% cd
% pwd
/home2/phys210t
% mkdir maple
% cd maple
% pwd
/home2/phys210t/maple
Also ensure that proper aliases for maple and xmaple are defined
% alias maple xmaple
alias maple='maple32'
alias xmaple='xmaple32 -cw'
If you don't see the above output, get help immediately!!
************************************************************************
2) Within your new 'maple' directory (~/maple), and using your text-editor
of choice, create and save the file 'mapletest', having contents given
by the lines between the two dashed lines that follow.
For the purpose this lab exercise, you don't have to type the comments, i.e.
any lines that begin with '#', so there are only 5 lines (commands)
that you need to type. BE SURE THAT EACH LINE/COMMAND ENDS WITH A
SEMI-COLON (;)
Make sure the file is saved as 'mapletest' in the 'maple' directory.
-------------------------------------------------------------------------
#######################################################
# This is a simple file containing Maple commands that
# can be read into a Maple session (either the command-
# line or GUI-version)
#######################################################
#######################################################
# Compute a reasonably nasty indefinite integral
# (anti-derivative) and assign the result to the
# variable 'ans1'. Note the use of ^ for exponentiation,
# and ensure that each Maple command ends with a
# semi-colon, so that each command is properly
# terminated and so that you will see the results
# as they are executed. Also note that when computing
# anti-derivatives Maple does NOT include the arbitrary
# constant that typically appears; i.e. it chooses
# the specific anti-derivative for which the arbitrary
# constant of integration has been set to 0.
#######################################################
integrand := cos(x)^3 * sin(x)^2;
ans1 := int( integrand, x );
#######################################################
# Differentiate 'ans1' and assign the result to 'ans2'
#######################################################
ans2 := diff( ans1, x);
#######################################################
# Verify that 'ans2' and 'integrand' are equal ... You
# might think that the following should evaluate
# to 0 ...
#######################################################
res1 := integrand - ans2;
#######################################################
# ... but it doesn't! So try simplifying the last
# result ...
#######################################################
res2 := simplify(%);
#######################################################
# Bingo!
#######################################################
-------------------------------------------------------------------------
************************************************************************
3) Start maple (NOT xmaple) from the command line
% maple
|\^/| Maple 12 (IBM INTEL LINUX)
._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2008
\ MAPLE / All rights reserved. Maple is a trademark of
<____ ____> Waterloo Maple Inc.
| Type ? for help.
>
Then type the following at the prompt
> read mapletest;
You should the following output: again, if you don't, ask for help!
3 2
integrand := cos(x) sin(x)
4 2
ans1 := -1/5 cos(x) sin(x) + 1/15 cos(x) sin(x) + 2/15 sin(x)
3 2 5 2 3
ans2 := 4/5 cos(x) sin(x) - 1/5 cos(x) - 2/15 cos(x) sin(x) + 1/15 cos(x)
+ 2/15 cos(x)
3 2 5 2 3
res1 := 1/5 cos(x) sin(x) + 1/5 cos(x) + 2/15 cos(x) sin(x) - 1/15 cos(x)
- 2/15 cos(x)
res2 := 0
Note how upon simplification, 'res1' evaluates to 0, verifying that the
derivative of the anti-derivative is 0, as it should be
Now exit maple ...
> quit;
... and you should be returned to the Linux command-line prompt.
%
************************************************************************
4) Now, remaining in your 'maple' subdirectory, invoke 'xmaple' from
the command line
You should see something like the windows shown in
http://laplace.physics.ubc.ca/210/xmaplefirst.jpg
appear. Close the "Welcome to Maple 12!" window by double clicking
with the left mouse on the upper left button that looks like a - sign.
This should leave you with a a Window with a title
"Untitled(1) - [Server 1]".
Position the mouse pointer in that window and you should see a
flashing vertical-bar cursor in front of the Maple prompt, '>'.
If the flashing cursor is NOT in front of the '>', position the mouse
pointer directly in front of the '>' and click the left mouse button.
Enter the following at the prompt
> read mapletest;
This will again execute the commands contained in the file
mapletest, and you should see something like that shown in
http://laplace.physics.ubc.ca/210/xmapletest.jpg
Now from the File menu at the top of the Maple 12 GUI, choose Save As.
The Save As window should pop up: In the Filename type-in, replace
*.mws
with
mapletest.mws
(Note: the .mws suffix means "Maple Work Sheet"
The Save As window should look like
http://laplace.physics.ubc.ca/210/xmaplesave.jpg
Click on OK in the Save As window, then choose
File -> Exit
from the menu bar
Now, return to your terminal, and ensuring that you are still in ~/maple,
get a directory listing
% cd ~/maple
% ls
mapletest mapletest.mws
Note that the directory now contains the worksheet 'mapletest.mws'
Observe that .mws files are not for "human consumption" ...
% cat mapletest.mws
{VERSION 6 0 "IBM INTEL LINUX" "6.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0
0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 }
{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1
{CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0
.
.
.
\"\"&F(*&)-%$cosG6#%\"xG\"\"$F()-%$sinGF.\"\"#F(F(F(*&F'F(*$)F,F)F(F(F
(*&#F4\"#:F(*&F,F(F1F(F(F(*&#F(F:F(*$F+F(F(!\"\"*&#F4F:F(F,F(F?" }}
{PARA 11 "" 1 "" {XPPMATH 20 "6#>%%res2G\"\"!" }}}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "1 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803
1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }
... rather, the worksheet files are in a special format that Maple
understands and which, for long and/or complicated calculations,
can be loaded in much less time than it would take to repeat all the
calculations in the worksheet from scratch.
Once you have saved a worksheet, you can invoke 'xmaple' with the
name of a worksheet as an argument, and then carry on with calculations
in the worksheet.
% cd ~/maple
% xmaple mapletest.mws
Since you are now working with an EXISTING worksheet, if you make modifications
to it, you can use
File -> Save
or simply type
Ctrl-s
or click on the "diskette" icon (fourth from left in the row of icons
below the menu bar) to update the saved copy of the worksheet.
IMPORTANT!! As already mentioned, to guard against loss of work due to
software/hardware crashes, you should get in the habit of saving the
worksheet FREQUENTLY---e.g. every few commands, type Ctrl-s. It'll
take a LITTLE more time to do your work, but will save you a LOT of
grief / frustration if the GUI crashes (which it has been known to
do from time to time) after you've entered a lot of new stuff into
the worksheet!
Again, choose
File -> Exit
or type
Alt-F4
to exit the GUI
************************************************************************
FINAL NOTE: Although we could have done this exercise by directly
typing expressions "interactively" into maple / xmaple, the process
used above in which one types the maple commands into a text file
and then loads them into a maple/xmaple session using the 'read'
command is a useful strategy in many instances.
This is particularly the case when writing Maple procedures
(i.e. programming in Maple), since you will generally want the
procedures/programs to be stored in text files. You CAN type procedure
definitions interactively, and save them as part of a worksheet, but
then modification of the procedure tends to be much more cumbersome
than modifying a definition in a text file.
************************************************************************