# Math 2270 # Maple Project 2 # October 14, 20002. # # A Maple text version of this project may be found at the web site # http://www.math.utah.edu/~kapovich/teaching11.html/ # Go to that page and click on the "2-nd maple assignment". # I recommend saving the file from the website onto you home directory, # and then # opening it from Maple, as a ``Maple text'' document. You can then do # the assignment by inserting the proper commands as well as italicized # textual comments in answer to the various questions. In order to # execute multiline commands from the version you get from the web, you # should use the ``Edit'' option in your maple window to ``join'' # execution groups which you have highlighted with your mouse. # # I remind that in each problem you should use Maple # to solve the problem, not pen-and-paper computations! # # PART 1. # # In the first part of the assignment we will study the geometric # meaning of linear (hence matrix) maps # f(x)=Ax, from R^n to R^m. We will focus on maps from R^2 to R^2 to # illustrate more general properties. # Of course, computer graphics are most concerned with those maps and # with R^3 # rotation maps and projection maps from R^3 to R^2. # # The very definition of a linear map, namely that f(u+v)=f(u)+f(v) # and f(su)=sf(u), for all vectors u,v and scalars s, has the following # geometric consequences: # # Lines are mapped to lines, and parallel lines are mapped to # parallel lines: This is because a line can be described as a set # L={u + t v , where t is in R}, where u is a point on the line and v # is # a direction vector. Therefore the image set # f(L):={f(u+tv)}={f(u)+tf(v)} # is also a line, going through f(u) with direction f(v). (If the # directions # f(v) turns out to be 0, then the line degenerates into a point.) # # Therefore, line segments are mapped to line segments, polygons are # mapped to polygons, and regions bounded by polygons are mapped to # regions bounded by polygons; if we know where the vertices go, we know # everything. Let's use these facts to draw the images of some # polygonal regions under a matrix map. # # First load the linear algebra and plotting libraries # > with(plots):with(linalg): > > verts0:=[[0,0],[1,0],[1,1],[0,1]]; > > #corners of unit square > > unitsquare:=polygonplot(verts0, color=`yellow`): > > #this command make a polygon and colors > > #the region inside it yellow. Make sure > > #to end this command with a colon! > > display(unitsquare); #Now semicolon! this command > > #shows the square > # When you executed the sequence of commands above you should have # gotten a picture of a yellow unit square. Now we will use a linear # map with matrix A defined below to map this square to a parallelegram # > A:=matrix([[3,2],[-1,1]]); #the matrix of our > > #random linear transformation > > f:=x->evalm(A&*x); #our linear map > # Problem 1. # # 1a) Assignment: For our map f(x)=Ax defined above, what are the # images of the # points e1=[1,0] and e2=[0,1]? How do you find these images from the # rows or columns of A? # # We use the ``map'' command below to see where the vertices of the unit # square are sent by f. The syntax is to put the mapping function in as # the first argument, and the list of input points as the second # argument. The result of the command will be the list of output # points. Check (not to hand in) that this is what happens below to # the four points in the list verts0. # # Note that here we are conflating points and vectors in R^2, namely we # identify each point P with its coordinates, i.e. with the vector # --> # OP # # > verts1:=map(f,verts0); > > image1:=polygonplot(verts1, color=`red`): > > display({unitsquare,image1}); > # 1b) Assignment: Explain where f(e1) and f(e2) are represented in the # picture you # just made. (Mark them by hand on the picture.) # # By the way, if you click on the plot you can choose to # have the projection ``constrained '', in which case Maple will use the # same scales for the vertical and horizontal axis. Otherwise it scales # the x and y-axes to make the picture fit nicely onto your screen. # # 1c) Assignment: If we compute f(f(x)):=f^2(x), then what will the # matrix be for # the resulting linear transformation? After answering that question, # make the vertices for f(f(unitsquare)) as follows, and draw the # corresponding image polygons. # > verts2:=map(f,verts1); > image2:=polygonplot(verts2,`color`=blue): > display({unitsquare,image1,image2}); # # 1d) Assignment: Explain what the columns of the matrix for f^2 have # to do with # the picture you just made above. # # 1e) Assignment: What is the inverse function to f ? (Hint : what is # its matrix? ) # Verify that the inverse mapping takes image1 back to the unit square # by using the method # from 1c). # # # Problem 2. # # Translations of objects are mapped to translations of the image # objects and scalings of objects are mapped to scalings of the image # objects: # # First let's review what do we mean by an ``object'' and # by translations and scalings of an object. An object is some set S # # of points s. By the image of S we mean the collection of image # points f(s) . We write f(S) for this image (like we did for the # line # L and its image f(L) in problem 1). Similarly if b is a # translation # vector, then the object S+b means all points of the form s+b where # s # is in S. If c is a scalar, then the scaled (or dilated) set cS # means # all points of the form cs , where s is in S. # # Now, if we apply the linear map f to the translated object S+b we # get all points of the form f(s+b)=f(s)+ f(b), where s is in S # (since f is # linear), i.e. exactly the set f(S)+f(b) , which is the translation of # # the image f(S) by the vector f(b). Similarly, if we apply f to # the # scaled set cS we get f(cS) to be the set of all points f(cs)=cf(s) # (since f is linear), i.e. the scaling cf(S) of the image set f(S). # # Here's how to translate and scale the unit square from #1: # Let's translate it by the vector b=[2,3]: # > b:=[2,3]; > > trans:=x->evalm(x+b); > > verts3:=map(trans,verts0); > > image3:=polygonplot(verts3,color=`yellow`): > > #colon! > > display(unitsquare,image3); > # Here's how to scale it by a factor of 0.2: # > c:=0.2; > > shrink:=x->evalm(c*x); > > verts4:=map(shrink,verts0); > > image4:=polygonplot(verts4,color=`red`): > > display({image4,unitsquare}); > # # # 2a) Assignment: Describe where you expect the translated unit square, # image3 # above, to be mapped by our linear map f from problem 1. Then use # the ``map'' command and the ``trans'' command, as well as polygonplot # and display, to make a picture of the images of the unit square and # its translation when they are mapped by f . Verify that the images # differ by the expected translation. # # # 2b) Assignment: Describe what you expect the image of the scaled # down square # above to be when you apply f , and then draw (using MAPLE!) a picture # illustrating this. # # # Problem 3. Special linear transformations in R^2 (rotations, # reflections, projections, shears): # # 3a) Rotations: The matrix for rotating by an angle theta is: # > Rot:=theta->matrix([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]) > ; > # so to rotate the vector (2,3) by Pi/3, we would command # > theta:=Pi/3; > > evalm(Rot(theta)&*[2,3]); > > > # Assignment for 3a): Draw a picture of the unit square rotated by Pi/3 # radians. # # 3b) Reflections (see section 2.2 of the textbook). # # Assignment: Define matrices which give reflections across the # x-axis, across the line y=-2x, and across the line y=x. # Illustrate what each of these linear maps does to the unit square (as # we did in 1a). # Finally, verify (using MAPLE computation) that reflecting across the # line y=x is the # composition of first rotating by Pi/4 in the clockwise direction, # then reflecting across # the x-axis, then rotating (back ) Pi/4 in the counterclockwise # direction. # # Hint: if L: x --> y and M: y--> z are linear transformations # and N: x--> y=L(x) --> z= M(y) is their composition, and the matrix # of L is A, the matrix for M is B, then the matrix for N is A&*B. # # # # 3c) You can scale by different factors in the x and y-directions. # Assignment: define a matrix expands the x-direction by 3 and the # y-direction by 2? (This is an analogue of the "Procustes" # transformation discussed in the class). # Make a picture of what this transformation does to the unit square # similarly to 1a). # # 3d) Projections. Assignment: Write down the matrix which projects # points onto # the line y=2x. Illustrate what this projection map does to the unit # square. Is there an inverse map? # # 3e) Shears: Recall that a shear of strength k in the x-direction # is defined by the matrix # > Shear:=k->matrix([[1,k],[0,1]]); > # Assignment: For k=1 explore what the shear map does to the unit # square. What # happens if you apply the shear map twice? Three times? Make pictures # using MAPLE. # # # PART 2. # # This part of the project is about the fundamental subspaces associated # with # matrices and about coordinates with respect to different bases. # # Here's the matrix we will work with. We will keep it moderately # sized, but of course we could make it much bigger without causing # Maple any problems. # > A:=matrix([[1,1,1,2,6],[2,3,-2,1,-3],[3,5,-5,1,-8],[4,3,8,2,3]]); [1 1 1 2 6] [ ] [2 3 -2 1 -3] A := [ ] [3 5 -5 1 -8] [ ] [4 3 8 2 3] > b:=vector([0,0,0,0]); b := [0, 0, 0, 0] # We will think of this as the matrix of a linear transformation > L: R^5-> R^4# , > L(x)=Ax.# # # Problem 4. Assignment: Compute rank and nullity of A using reduction # # of A to row echelon form. # # # Problem 5. Assignment: Find a basis for the kernel of A. # To solve this problem you can either use the "rref" command or # "linsolve": # > linsolve(A, b); # In this command A is the matrix, b is the vector # of the right-hand side (in the present problem you will use "zero" # vector). # If you do not want to use the symbols like _t_1 as your parameters # you can use the command: # > linsolve(A, b, 'r', s); # Now the names of the parameters will be s_1, s_2,... Type # >r; # to see what the rank of the matrix is. # # Problem 6. Assignment: Use Maple to find a basis v1, v2, v3 for the # column space of A # (i.e. of the image of L). Recall that one way to find this basis is # to do # row operations, putting your matrix into reduced column echelon # form. # # Problem 7. Maple will compute bases for these spaces with single # commands. # Assignment: Compare the answers you've gotten above with Maple's # answers: Since # you know bases are not unique, you can pretty well guess that Maple is # using methods close to the ones we used, since its answers should be # quite similar to some of yours: # > rowspace(A); # Gives a basis for the space spanned by row vectors. > nullspace(A);#nullspace basis > colspace(A); #nice column space basis, i.e. a basis for the image of > L. > v:=convert(colspace(A),list); # #The above command is making a list of vectors in the basis. This # keeps track of order in the set v # #of vectors which form basis of the image of L. > v1:=v[1]; v2:= v[2]; v3:= v[3] # These vectors form a basis of the image of L. Compare these vectors # with vectors from the problem 6. > r1:=row(rref(A),1); #r_1,r_2,r_3 basis for rowspace(A) > r2:=row(rref(A),2); > r3:=row(rref(A),3); > G:=convert(nullspace(A),list); #making a list > #keeps track of order in a set > n1:=G[1];n2:=G[2]; #nullspace basis. # # # Problem 8. Assignment: Use Maple to verify that the vectors r1, r2, # r3, n1, n2 form a basis of R^5. # Hint: use reduced row echelon form or the determinant. # Explain your solution: namely, how the value of the determinant or # shape of the reduced echelon form is # related to the fact that we have a basis. Check that each of the # vectors r1, r2, r3 is orthogonal to each of the vectors n1,n2. # I.e. the row-space is orthogonal to the kernel of the matrix. # # Problem 9. Assignment: Let us call E={e1,e2,e3,e4,e5}, i.e. the set # of standard basis # vectors in R^5. Let us call our new basis S={r1,r2,r3,n1,n2}. # Find the transition matrices > P_{E <-S}# and > P_{S<-E}# , which # convert S coordinates to E-coordinates and vice-versa. Recall that the # matrix > P_{E <-S}# # is very easy to find and the matrix > P_{S<-E}# is easily obtained from the matrix > P_{E <-S}. # # Problem 10. Using transition matrix find the coordinates of the # following vectors with respect to # the S-basis: # 10a) a=(0,1,-4,0,-3), # 10b) b=(1,0,0,0,0). #