# Math 2270 # PROJECT 1, August 31, 1999 # 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 # experience you may want to skip various sections. It is only material # from section (5) that you will be asked to hand in. # 1a) Logging in to a Math Lab machine: The Math Department Computer # Lab is located in Building 129, the small, 1-story plus basement, # off-white building immediately east (uphill) from the Math building # JWB on president's circle. (There are two such buildings, you want # the one closest to JWB.) The lab is at the north end of the upper # floor. (So the Engineering Math tutoring room is at the opposite # end.) 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 should be # available on a table at the back 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 to wake it back up. # If necessary type a ``return'' (or ``enter'') key to get the cursor # into the ``login name'' box. Your login name is made out of your # social security 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 of 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. For most # of you this is your new I.D. number, for some of you it is your social # security number. If Mr. Gauss has I.D. number 00371234 then his # initial password is gskf1234, 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. If failure continues find a # lab assistant. # 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 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. # # 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, editing windows: 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 at the # back 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 most # recent version of Maple is mapleV5 &, or xmapleV5 &. Use one of # these commands in a local window rather than the mouse menu button. # If you can find a mapleV5 mouse menu button (as opposed to mapleV4), # that is also fine. # # 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 back table. # # 3) Starting a Maple session: There is introductory material about # Maple on our departmental web pages. If you wish to see what's # available you may use the netscape window you made in step (2) above, # and go to the address http://www.math.utah.edu/lab/ms/maple. Among # other things, you will find the documents Introduction to MapleV.4 in # the Undergraduate Computer Lab (even though you will be using V5) and # Maple Examples. There may be copies of these in the back of the room # as well. Refer to Introduction to MapleV.4 in the Undergraduate # Computer Lab, for what follows. You may use either a paper copy or a # web-page copy. # Move your cursor into the Maple window which you created in step # (2). Maple is partly just a very fancy calculator; it can do # practically any undergraduate mathematics computation. 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. To # insert text click on the ``T'' box. You can use the mouse to cut, # paste, and edit a document. In fact, 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, try the following # 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 (or by using an appropriate menu option). # 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 ! ) # > 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 # # It is always a good idea to save your maple file periodically. Do # this now using the tool bar, and the instructions in the Introduction # to Maple V.4 in the Undergraduate Computer Lab handout. As the handout # explains, the first time you save your file you will be asked to give # it a name. You can call your file whatever you want, as long as you # end the name with ``.mws'' (stands for maple worksheet). It will # probably happen some time that you will crash Maple long after your # last save. This will not make you feel happy. While you're at it, # read the directions in that handout having to do with printing a file, # and try to print out a copy of your worksheet so far. Before you # print out, scroll to somewhere in your worksheet and add some text # with the ``T'' menu item. To let Maple decide where to put the line # breaks in a paragraph, don't put any in yourself. 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 textual explanations of # what you've been doing. # # 4) 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. # # 4a) In mapleV5 (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 the Math 2250 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. # # 4b) Getting an on-line copy of this Math 2270 project: The web # address of this xeroxed project is # http:/www.math.utah.edu/~kapovich/proj1.txt. #You may use your # netscape window to view it. Unfortunately it does not seem possible # to use the mouse to highlight and copy pieces of such a web document # directly into a maple worksheet. (You could copy pieces into other # files, however.) Here's a good thing to do: Make copy of the web # document in your own directory. You do this by using the netscape # ``file'' menu option, choosing ``save as''. Unless you give other # directions, the document will be saved under the same name it has on # the web, namely ``proj1.txt''. Now return to your Maple window # and use the ``file'' menu item to open``proj1.txt''. In order to # open a ``Maple text'' document, which this is, you must open the # ``filetype'' box at the bottom of the ``open'' menu, and use your # mouse to choose ``Maple text.'' At this point ``proj1.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 # tutorial 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, but on # the other hand you will be able to execute the Maple commands in this # document without typing them in first. # # 4c) Using help, an example : You may proceed whether or not you # created a copy of proj1.txt 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 (4b). # # 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 see all the commands in this > #package use a semicolon instead of a colon # # 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. # # 4d) 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 5 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 (if 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 > # # # 5) 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? # 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 (4d): by using #the reduced row echelon form of 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 # 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.