# Math 2270 # PROJECT 1 # September 2000 # In this project you will log onto the Math Lab machines, # familiarize yourself with how they operate, introduce yourself to the # software MAPLE, and use it to do some computations related to the # linear algebra in chapter 1 of our text. Depending on your previous # eperience you may want to skip various sections. It is only material # from section (6) that you will be asked to hand in. # # 0) A preliminary word of Advice: Students often approach the task of # reading mathematical material as if they were reading a novel; they # sort of skim along quickly. That approach is O.K. to get an # overview, but in order to have a chance at real understanding you must # be prepared to proceed much more slowly, sentence by sentence and # thought by thought. Otherwise you will almost certainly find yourself # partly lost after several paragraphs and completely lost after several # more. (This might happen anyway.) If you are working properly it can # easily take half an hour to read through one page of mathematical # text. This takes a certain amount of discipline, patience, and # practice. With the computer projects there is the added temptation # of having Maple execute commands in successive command sections by # repeatedly hitting the enter (return) key, without pausing to digest # the interlaced text or the meaning of the commands. There is a # seductive appeal in having this capability. Resist it. # 1a) Logging in to a Math Lab machine: The Math Department Computer # Lab is located in the South Physics 205, i.e. inside the 2-story # brick building just north of the Math building JWB, and south-east of # the physics classrooms in the circular part of JFB. Room 205 is in # the back (East) of the building, on the second floor (from the west), # which equals the level of the ground on the uphill, east entrance. # The following information about logging in and your initial # password is summarized from the handout Introduction to the # Undergraduate Computer Lab Department of Mathematics, University of # Utah, SLC, Utah 84112 . This and other useful handouts are available # on a table in the front of the lab. # Everyone who is registered in Math 2270 should have an account # set up in our lab already. These accounts are created from University # class lists so it sometimes happens that late-registering people don't # have accounts yet. If you turn out to be one of these people you will # need to consult the lab assistant about getting an account. Make sure # to bring your student I.D. because the first thing the assistant must # do is verify that you are a University student. # If your machine looks asleep jiggle the mouse or hit any key to # wake it back up. A window should appear which asks you to select a # server. Since the Math Department is sharing this lab with Physics, # there are physics and math server computers. You want to select one # from the list of choices which has ".math" in its name. If a # ".physics" computer is highlighted, use your cursor to choose one of # the ".math" computers, and then O.K. your choice by clicking in the # "accept" box. In a few seconds a login window should appear, asking # for your login name and password, and have "Mathematics" written in # red on the top. (If the login window says "Physics" you have # accidently chosen a physics server, and you should type "control C" to # go back to the previous step.) # Your default login name is made out of your student I.D. number # and your actual name, as follows. All names from classes begin with # ``c-''. If your name is Karl Fred GausS, then your login name is # c-gskf, following the recipe: c-(first letter of last name)(last # letter of last name)(first letter of first name)(middle initial). If # there are multiple people registered this term who would have the same # login name, say c-gskf, then they are instead assigned login names as # c-gskf1, c-gskf2, c-gskf3, etc. Mr. Gauss would not know beforehand # which case he fell into, so would probably try c-gskf first, followed # by his password. In case of failure he would then try c-gskf1, then # c-gskf2, etc, through c-gskf4. Then he would find a lab assistant. # After entering your try at a login name, type the ``return'' key and # the cursor should be in the password box. # Your initial password is just the c-gskf part of your login name # followed by the last four digits of your student I.D. number. If Mr. # Gauss has ID number 000735421 then his initial password is gskf5421, # regardless whether his login name was c-gskf or c-gskf3. If the # login fails try again and then try the different login names suggested # above. Another possibility is that your account was created using # your social security number (which used to be used for student ID # number). If failure continues find a lab assistant and he/she will # help you. # Once you are logged in successfully a ``local'' window should # appear. Notice that it has various parts: borders on the top (title # bar), borders on the side (scroll bar), etc. If you move your mouse # on its pad your pointer (called cursor) moves around the screen. If # you want to work in a window, the cursor should be in it. # # 1b) Changing password: Sometime within the first two weeks of # classes (now would be a good time) you must change your default # password into a personal one. You do this as follows: # # Get your cursor into a local window. Type the unix command passwd, # followed by return, and follow the directions. Your new password # should be exactly 8 characters long. Don't choose a word in the # dictionary or a proper name. Composites of dictionary words, like # strawdog, are good. Even better is to use one or two upper case # letters, e.g. strAwdog. For still more security, use some digits, # e.g. strAw4o9. Note that it takes about 30 minutes for a new # password to take effect. Also, you should be aware that if a password # is not changed within the first two weeks of class, then your computer # account will be disabled for security reasons. Write your password # down somewhere in case you forget it. # # 1c) Logging out: Move the cursor out of all windows (into the # background), press the left mouse button and choose the last menu # item: Exit X-Windows. (You probably don't want to do this now, but at # least locate the menu item for later.) # At this point you are ready to get used to the X-windows: # # # 2) X-windows, opening netscape, maple, mail, more: Go through the # document Introduction to Xwindows in the Lab, which you should have a # copy of. There should also be copies of this document in the front of # the room. Xwindows are like most windows in most ways; your aim here # is to experiment to see how to open and close windows, resize them, # move them about, and find them if they happen to get hidden. When you # get to the end of the document you should also have opened a NETSCAPE # window and a MAPLE window. Note: The command for the current # (default) version of Maple is xmaple &, which you can type into a # local window, followed by . This is version 6, and you can # also find it as an option on one of your mouse buttons, it's your # choice. If you are using an earlier version of Maple (V5 or V4, for # example), there are slight differences in commands and syntax, and # they may confuse you once or twice. # # Further information: If you want more in-depth information about the # computing facilities in this lab, you might pick up a copy of the # handout A Crash Course on CSC Facilities, from the front table. # # # 3a) Math Department Maple resources: There is introductory material # about Maple on our web pages. If you wish to see what's available use # the browser window you made in step (2) above, and go to the Math # Department home page http://www.math.utah.edu/. By following links # from here you can find current and future course offerings, faculty # information, and much more. Since you are students, interested in # Maple information, click on "students" (at the upper left of the # page), and you are directed to http://www.math.utah.edu/ugrad/, the # undergraduate home page. If you choose "Undergraduate Computer Lab", # followed by "Selected software and tools", you will find some links to # Maple information. # 3b) More Information. Maple has its own introduction, as well as a # new user's tour, see item 5 below. # # # 4a) Maple commands: Move your cursor into the "Untitled" (new) Maple # window which you created in step (2). Maple is partly just a very # fancy calculator; it can do practically any undergraduate mathematics # computation or symbolic manipulation. You can write programs in Maple # and draw pictures as well. If you are doing a homework assignment you # can intersperse text with computations using the toolbar: to get a # computation prompt click on the ``[>'' box near the top. To insert # text click on the ``T'' box. Or you can change command fields # (starting with "[>") into text fields by putting the cursor into them # and then choosing "T". You can use the mouse to cut, paste, and edit # a document. You can change fonts, formats, and use other standard # text editing tools by choosing appropriate menue items. This document # you are reading is a Maple document even though it is largely text. # To give you a flavor of what Maple can do, we will try a few # commands. They should begin on a line having a command prompt ``>'', # and should be ended with either a semicolon ; or a colon : If you end # with a semicolon you will see visible output, if you end with a colon # the output will be suppressed even though the command is executed. # Maple will not execute a command until you type the ``return'' or # ``enter'' key. If you have a multiline command use ``shift-return'' # to change lines without executing. If you mess up your parentheses or # brackets or do something else which makes your command unexecutable # you will get a ``syntax error'' message and Maple will try to point # out your mistake. After a while you will become good at fixing these # mistakes but they can be annoying at first. Spaces are ignored in # Maple, so you may use them to make input easier to read. You can # enter explanatory comments in a command line by inserting a ``#'' to # the left of the comments; Maple ignores any text after the #. # Sometimes this is more informative then entering nearby explanatory # text, especially if you are explaining various steps in a subroutine. # Now, let's try some commands. (You try just the math commands, # the editorial comments were only added to explain what the particular # commands are illustrating ! ) Check that you understand what each # command is doing. # > 3+4; 4+5: 6 * 7; #one of these computations will not be shown > #even though all three will be done. > > (3+4)7; #if you want to multiply you must use *, so after > #trying the command as given insert a * to fix the > #resulting syntax error. You can execute a line or > #execution group (bracketed on the left) if > #your cursor is anywhere in it. You can move the > #cursor with the mouse or the arrow keys. Maple will > #try to put it in a good place if it detects an error. > (3+4)^2/7; 3+4^2/7; evalf(3+4^2/7); #the evalf command gives a > decimal > #approximation instead of an algebraic expression. > #Notice that if given a choice, Maple computes powers > #first, then multiplies and divides, and finally > #adds or subtracts. > diff(x^2,x); #``differentiate x^2 with respect to x'' > diff(exp(sin(x))*x^3,x); #a harder differentiation problem > #you should get output: 3 2 cos(x) exp(sin(x)) x + 3 exp(sin(x)) x > f:= x-> exp(sin(x))*x^3; > diff(f(x),x); #the same problem done in two steps. > #The first line shows the format for defining > #functions in Maple. (Did you use ``shift-ret''?) 3 f := x -> exp(sin(x)) x 3 2 cos(x) exp(sin(x)) x + 3 exp(sin(x)) x > int(t^2*exp(t),t); #``integrate (t^2)*exp(t) with respect > #to t'' (Maple doesn't put in the integration constant.) 2 t exp(t) - 2 t exp(t) + 2 exp(t) > int(t^3*exp(sin(t)),t); #this shows that Maple is not God: > #If it can't find an elementary-function > #antiderivative it just echos what you put in. > #you should get: / | 3 | t exp(sin(t)) dt | / > evalf(int(t^3*exp(sin(t)),t=0..1)); #But you could do > #a definite integral numerically even if Maple > #can't compute an elementary antiderivative .5112814089 > sum(3^(-n),n=1..100); #add a geometric series part way, > #this is the series 1/3 +1/9 +1/27 + ... > evalf(%); #get its decimal value > Sum(3^(-n),n=1..infinity); evalf(%); #add the series > # all the way to infinity. Sum with captial > #S writes the sum but doesn't evaluate it, > #but then evalf(%) does. > # infinity ----- \ (-n) ) 3 / ----- n = 1 .5000000000 > Sum((.001)*(n/1000)^2, n=1..1000); evalf(%); > #This is a Riemann sum for the integral of x^2 > #from 0 to 1, with 1000 equal subdivisions. > #Sum with capital S writes the summation, but > #doesn't evaluate it. evalf(%) gives its value. > 1000 ----- \ -8 2 ) (.1000000000 10 n ) / ----- n = 1 .3338335000 > int(x^2,x=0..1); #this is the exact value of the integral > Pi;exp(1);evalf(Pi);evalf(exp(1));infinity; > #some important numbers # # # 4b) Saving your file: It is always a good idea to save your Maple # file periodically. Do this now using the tool bar, using the "save" # option under the "File" menu item. The first time you save a new file, # and any time you use the "save as" option, you will be asked to name # your file and say where you want to keep it. You name it in the left # part of the box, being careful to keep the suffix ".mws" so that Maple # knows this file is a Maple Work Sheet. If your directory is new you # probably haven't made any subdirectories yet (unix command mkdir, in a # local window), but as you create more files you may wish to organize # where you save them using the tree structure of Unix directories, # which you can follow in the right side of your saving box. If you # need more help saving your file see the instructions in the # Introduction to Maple V.4 in the Undergraduate Computer Lab handout at # the front of the lab, or ask an assistant. It will probably happen # some time that you will crash Maple long after your last save. This # will not make you feel happy. # # 4c) Text editing: First, scroll to somewhere in your worksheet and # add some text with the ``T'' menu item. Maybe scroll to the top and # put the title ``My first Maple worksheet'' (center it with the menu # option on the right side of the toolbar), as well as your name and # today's date. When you are doing your Maple projects you will be # expected to hand in more than a page of computations: You will be # expected to add text explanations of what you've been doing. You can # highlight text with the mouse, and then delete it or copy it # elsewhere. Sometimes if you are having trouble adding text in a # particular place you can use the Maple command button "[>" first to # get a command field, and then turn it into a text field by putting # your cursor into it and using the "T" button. # # 4d) Printing your file: Go to the file menu option and choose the # print option. You get a little printer setup box. If you then click # on the print command diamond, followed by ``enter'' or by a click on # the print box at the bottom of the window, a paper copy will come out # of one of the printers at the side of the lab. Do this now. # Alternately, if you want to use a different printer, you can use the # output to file diamond to create a postscript file which you can then # print anywhere, using the appropriate unix commands. For example, to # print a postscript file to the lab printers from a local window, the # command would be "lpr -P b129lab1", or "lpr -P b129lab2", followed by # the return key. You do not put in the quote marks, but you should be # careful to leave spaces exactly as indicated. The lpr stands for line # printer, the -P stands for print, and the b129lab1 or b129lab2 are the # names of the two printers. If you have trouble printing ask a lab # assistant for help. # # 5) Linear Algebra, and using Maple's help windows: So, it looks # like Maple might be interesting to use in Calculus, but how do we find # out what it can do for us in that subject, or in another subject, say # linear algebra? It is instructive to use the Help directory located # at the upper right-hand corner of the maple window. That's what # you're going to do now. # # 5a) In mapleV6 and V5 (but not in mapleV4) there's an online # tutorial! Click on the ``Help'' box, and then on the choice ``New # User's Tour''. Probably this tour will superimpose onto your current # Maple session. Or maybe you can't see the new tour because it's # hidden behind your current window. In the latter case use the # ``window'' menu option to change windows. The tutorial give examples # from many areas of mathematics, including linear algebra, which you # can peruse at your leisure. In this tour you will be able to put your # cursor onto any command line, type return, and see what the command # does. If you wish you can explore now, or you can continue with these # notes below and come back to the tour later. There are not very many # examples in the subheading ``linear algebra'', and they might not all # make sense to you this early in our course, but you might want to look # at them anyway. To close the new tour (or any other top window), use # the ``close'' option inside the ``file'' menu item, or use an option # in the ``window'' box to return to your current session. # # 5b) Getting an on-line copy of this Math 2270 project: This # xeroxed project has been saved in two different formats, at # http:/www.math.utah.edu/~korevaar/2270fall00proj1.txt and # http:/www.math.utah.edu/~korevaar/2270fall00proj1.mws . The first # file is in "Maple text" format, and will be easier to read from your # browser. The second file is in "Maple work sheet" format, and will # look ugly in your browser, but if you're lucky (or working in the # computer lab) your own Maple will be able to open it directly once you # save it from the internet. The advantage of the second (".mws") # format is that plots, formatting and output are reproduced exactly as # in your xerox copy. The disadvantage is that some computers may not # be able to understand it. The advantage of the first (".txt") format # is that it is more universal. The disadvantage is that Maple output # and formatting often lost. # For now, go to the second web address ("....mws") using your # browser window. Then, if you're using netscape as your browser, # pick the ``file'' menu option, choosing ``save as''. Unless you give # another name for it you will now save this document with the same # name it has on the web, namely ``2270fall00proj1.mws''. It creates a # copy of this file in your home directory. Do it. # Now return to your Maple window and use the ``file'' menu item to # open``2270fall00proj1.mws'': Choose open from the file menu option. # The default expectation of Maple is Maple Worksheet Documents, so # "2270proj1.mws" should appear as a choice in the central box. (If you # don't see this file, make sure that in the open file dialog box the # filetype at the bottom is "Maple Worksheet".) Click on # "2270proj1.mws" with the mouse to highlight it and then click ``OK'' # or type ``return''. A copy of this project should then appear in your # Maple window, as a Maple document that you can work in. Possibly # Maple has hidden it behind another file, in which case you can use the # "Window" menu item to bring it forward. # # (Only follow the directions in this paragraph if you could not # open the ".mws" file: Save "2270fall00proj1.txt" from the internet. # Then return to your Maple window and use the ``file'' menu item to # open``2270fal00proj1.txt''. In order to open a ``Maple text'' # document, which this is, you must chose open from the file menu # option. In the resulting open file dialog box go to the filetype box # at the bottom, click on the triangle to see the list of choices, and # use your mouse to choose ``Maple text.'' At this point # ``2270fall00proj1.txt" should appear as a choice in the central box. # Click on it with the mouse to highlight it and then click ``OK'' or # type ``return''. A copy of this project should then appear in your # Maple window, as a Maple document that you can work in. The copy is # not as pretty as your xerox (the execution groups are all single # lines, and the text formatting is not as neat, and some output may be # lost), but it is O.K. It has text and it has Maple input.) # # 5c) Using help, an example : You may proceed whether or not you # created a copy of 2270fall00proj1.mws in your own directory and opened # from Maple. In future projects you will want to be able to work off # of the web, however, as indicated in (5b). # # Let's illustrate some material from chapter 1, and the # usefulness of help windows. Can Maple do matrix operations, or even # define matrices???? Of course!!! # Let's try to find the right commands: # # Click on the Help option at the upper right corner of your Maple # window. A little window opens with further choices. Pick the Using # Help choice, click on it, and a help window should appear. (If it # doesn't, it's hidden behind your worksheet; use the ``window'' option # in your menu to bring it to the front.) Click on Mathematics from # your choices at the top left of the help window (use scroll bar if # necessary), then make successive choices so that you've done: # Mathematics/Linear Algebra/linalg.../matrix. At this point you should # get a help window about the matrix command. It is often helpful to # skim to the bottom of such windows to look at examples, and then to # return to the detailed instructions above as necessary. At the # bottom of this window you will see that there are at least two ways to # enter matrices, and that matrix operations are a subset of a library # of commands from the package ``linalg''. We load this package with # the command # > with(linalg); #to hide the list of commands in this > #package use a colon instead of a semicolon # # And now we copy the commands from the help window: (For long ones we # would use our mouse!) > matrix(2,2,[5,4,6,3]); #a 2 by 2 matrix with > #successive entries as indicated [5 4] A := [ ] [6 3] > matrix([[5,4],[6,3]]); #same matrix [5 4] [ ] [6 3] # So that's how to make a matrix. To find out more about the help # windows, click on Help/Using Help/Help Guide. You can use the index, # as we did above, or you can do various key-word searches. # To close the help files after you've used them use the # ``file/close '' sequence in the toolbar, or the equivalent key stroke # given next to it, which is simultaneous ``control-F4'' on my work # station. Or you can keep them around and return to your worksheet # with the ``window'' menu option. # # 5d) Some Linear Algebra computations: Can you figure out the syntax # of the commands and their meanings? Some of these commands will be # useful in part 6 below, where you are to do actual problems. Use the # help windows for more details about the commands. This example is # worked on page 55 of the text, by hand. Of course, the computer could # work much larger systems almost as easily as this one. When systems # get too large, working them by hand becomes cumbersome. > A:=matrix([[1,2,3],[2,-1,1],[3,0,-1]]); > #coefficient matrix for a linear system, > #``:='' is used to define the object on > #its left by the construction on its right > A[2,3]; #one of the entries of A > b:=vector([9,8,3]); #the right-hand side for > #a linear system Ax=b > augAb:=augment(A,b); #the augmented matrix > C:=rref(augAb); #compute the reduced row echelon form > #of the augmented matrix > x:=col(C,4); #read off the solution vector to Ax=b > evalm(A&*x)=evalm(b); #check your answer > #NOTE to do matrix operations use the evalm > #command. Addition is +, but matrix multiplication > #is &*. (Scalar times matrix is *.) > x:=linsolve(A,b); another way to solve linear systems. > > Ainv:=inverse(A); #the inverse matrix (it it exists)! > x:=evalm(Ainv &* b); #yet another way, for nonsingular matrices, > #to solve Ax=b > evalm(A&*Ainv); evalm(Ainv&*A); #just checking! > evalm(A^3); evalm(A&*A&*A), evalm(A+3*A); > transpose(A); > #matrix powers, multiplications, addition, > #transpose > # # # 6) Your actual homework on Maple: (These are modified from problems # on page 27 of the text Multivariable Mathematics with Maple, by J.A. # Carlson and J.M Johnson.) You are to create a document in which you # answer the following questions, via a mixture of Maple computations # and textual insertions. You are to print out a copy of this document # to hand in, as your first Maple project. Don't forget to put your # name and section number on it! # Define [1 2 3] [ ] A := [4 5 6] [ ] [7 8 9] [2 1 0] [ ] B := [1 2 1] [ ] [0 1 2] # # # 1a) Compute AB and BA. Are they the same? # 1b) Compute A+B and B+A. Are they the same? # 1c) Define C to be A+B. Compute C^2 and compare it to A^2 + 2AB + # B^2. Are they the same? Can you think of a small change you could # make in the expression ``A^2 + 2AB + B^2'' in order to make it equal # to C^2? Justify your answers! # 1d) Compute the transpose of AB and compare it to the product of the # transpose of A with the transpose of B, multiplied in the correct # order so that you expect equality. # 1e) Define v=(1,2,3) to be a vector. Compute Av. What does Maple # give you when you try vA? # 1f) Solve Bx=v for x, where v is the vector in (1d). Get your # solution all three ways that were indicated in section (5d): by # row-reducing the augmented matrix, by using the command ``linsolve'', # and by using the inverse matrix to B. # # 2a) Solve Ax=v for x, where A and v are as indicated above. Verify, # with Maple, that your solution x actually solves the equation Ax=v. # 2b) Repeat your work above in order to solve Ax=w, where w=(-1,4,1). # Explain your answer.