Linear Algebra Powertool
Visualizing Linear Transformatio
ns in
OnLine 3.1
Worksheet by Michael K. May, S.J., revised by Russell Blyth
> restart: with(linalg): with(plots): with(plottools):
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
Warning, the name arrow has been redefined
Outline
This worksheet covers material similar to the On Line 3.1 section.
The basic objectives are:
Drawing Stick Figures
To see the action of linear transformations on objects, we first want to be able to easily draw objects, which we do by specifying outlines. In this worksheet we work with figures in 2 dimensions. The techniques will be extended in the next worksheet to look at figures in 3 dimensions. We draw a polygon by plotting a list of points that outline the shape we are drawing.
We start with a set of points that outline the letter M.
> mlist := [[0,0], [0,5], [1,5], [2,3], [3,5], [4,5], [4,0], [3,0], [3,3], [2,1], [1,3], [1,0], [0,0]];
If we simply plot the points we see that they form a large block M in a 5 by 4 square with legs having thickness one. (Notice that the ending point repeats the starting point to close the outline.)
> plot(mlist, view=[-2..6, -2..6], axes=boxed);
Exercise:
1) Create three lists of points that define a block polygon descriptions of three distinct letters in your last name (at this point you may want to avoid letter like A and R that would need two polygons to describe them). Have Maple draw the letters in separate plots.
>
Once we have plotted the outline of a polygon, we want to be able to systematically make modifications to our list of points and see how the changes modify the pictures. The most obvious transformation to start with is a translation. We first define a function to carry out a translation:
> addvectolist :=(addvec, listofvecs)->map(`+`,listofvecs,addvec):
We can use this command to move the corners of M right 5 and up 1.
> addvectolist([5,1],mlist);
To plot several letters together, we use the display command. First we create named plots of each letter. Then we display the list of plots. (Note that when we name a plot, we end the command with a colon rather than a semicolon, so that we don't get a printout of the formal plot structure.)
>
m1 := plot(mlist):
m2 := plot(addvectolist([5,1],mlist)):
m3 := plot(addvectolist([-5, -6],mlist)):
display({m1,m2,m3},view=[-10..10,-10..10], axes=boxed);
Exercises:
2) Use the lists created in exercise 1 above to plot the first three letters of your last name in a single plot.
>
3) Replot the same letters, but put them in a more interesting arrangement this time. (They should not be in a flat line.)
>
4) Translate the letters you plotted in exercise 3 so that they are balanced around the origin.
>
Linear Transformations in
In section 3.1 of our book, we learn that maps of vector spaces that satisfy the linearity properties can be represented as multiplication by a matrix. We follow the book's convention, treating vectors as column vectors so that the matrix is always on the left and the vector is on the right.
>
A := matrix(2,2,[[1,0],[-2,1]]);
b := [1,3];
evalm(A&*b);
>
multmatbylist :=(multmat, listofvecs)->
map((x,y)->convert(evalm(y&*x),list),listofvecs,multmat):
>
mlistA := multmatbylist(A,mlist):
plot(mlistA,x=-10..10,y=-10..10, color=black,axes=boxed);
The transformation produced by multiplication by A can either be described by saying that it is a shear in the y direction by a factor of -2 (a wholistic geometric description), or by saying that the first element of the standard basis is taken to [1, -2] and the second element of the standard basis is taken to [0, 1].
An important example discussed in the text is rotation around the origin by angle
radians. We see that this rotation takes [1, 0] to [cos(
), sin(
)] and takes [0, 1] to [-sin(
), cos(
)]. This allows us to produce a matrix that can be used for the rotation (these two images are placed into the matrix as its columns).
>
rotmat := alpha -> matrix(2,2,[[cos(alpha), -sin(alpha)], [sin(alpha), cos(alpha)]]);
Rot30 := rotmat(Pi/6);
> plot(multmatbylist(Rot30, mlist),x=-10..10,y=-10..10, color=black,axes=boxed, scaling=constrained);
Exercise:
5)Find matrices to achieve the following actions. Verify the actions by applying them to the three letter combinations used in exercise 4 above:
Mata flips the letters upside down (reflection in x-axis).
>
Matb flips the letters right-to-left (reflection in y-axis).
>
Matc rotates the object by an angle of 2Pi/3 (around the origin)
>
Macd shears along the y axis by a factor of 2.
>
>
>
>