Chapter 3: Linear Transformations

MA 237

Richard Hitt

Matrix Transformations

We can watch what happens to the unit square in [Graphics:Images/chapter3_gr_1.gif]under matrix transformations.  First, we need to describe the unit square parametrically.

[Graphics:Images/chapter3_gr_2.gif]
[Graphics:Images/chapter3_gr_3.gif]

[Graphics:Images/chapter3_gr_4.gif]

[Graphics:Images/chapter3_gr_5.gif]
[Graphics:Images/chapter3_gr_6.gif]
[Graphics:Images/chapter3_gr_7.gif]
[Graphics:Images/chapter3_gr_8.gif]
[Graphics:Images/chapter3_gr_9.gif]

[Graphics:Images/chapter3_gr_10.gif]

[Graphics:Images/chapter3_gr_11.gif]

In order to keep track of what gets transformed where, it would be better to color code the lines.

[Graphics:Images/chapter3_gr_12.gif]
[Graphics:Images/chapter3_gr_13.gif]
[Graphics:Images/chapter3_gr_14.gif]

[Graphics:Images/chapter3_gr_15.gif]

[Graphics:Images/chapter3_gr_16.gif]
[Graphics:Images/chapter3_gr_17.gif]
[Graphics:Images/chapter3_gr_18.gif]
[Graphics:Images/chapter3_gr_19.gif]
[Graphics:Images/chapter3_gr_20.gif]

[Graphics:Images/chapter3_gr_21.gif]

[Graphics:Images/chapter3_gr_22.gif]

Multiplication of Matrices

We can set Mathematica so that it displays matrices in a more human readable form using the following trick.

[Graphics:Images/chapter3_gr_23.gif]
[Graphics:Images/chapter3_gr_24.gif]

So if we enter a matrix like

[Graphics:Images/chapter3_gr_25.gif]
[Graphics:Images/chapter3_gr_26.gif]

the result is displayed in matrix form rather than as a list of lists.

[Graphics:Images/chapter3_gr_27.gif]
[Graphics:Images/chapter3_gr_28.gif]
[Graphics:Images/chapter3_gr_29.gif]

[Graphics:Images/chapter3_gr_30.gif]

[Graphics:Images/chapter3_gr_31.gif]

We can rotate the square by any given angle about the x-axis using the following matrix transformation.

[Graphics:Images/chapter3_gr_32.gif]

So, for example, if we use a specific angle, we get

[Graphics:Images/chapter3_gr_33.gif]
[Graphics:Images/chapter3_gr_34.gif]

We can define

[Graphics:Images/chapter3_gr_35.gif]
[Graphics:Images/chapter3_gr_36.gif]

[Graphics:Images/chapter3_gr_37.gif]

[Graphics:Images/chapter3_gr_38.gif]

We can spin the square around the x-axis by graphing many different images as θ varies from 0 to 2π.  This can be somewhat automated by loading an animation package.

[Graphics:Images/chapter3_gr_39.gif]

This package contains an Animate command that we can use to assemble the different graphs in a table.  If you then select the entire table of output by clicking the mouse on the grouping bar on the right, Control-y (or Cell->Animate Selected Graphics) will begin the animation.  The animation controls are in the lower left of the window.

[Graphics:Images/chapter3_gr_40.gif]

[Graphics:Images/chapter3_gr_41.gif]

[Graphics:Images/chapter3_gr_42.gif]

[Graphics:Images/chapter3_gr_43.gif]

[Graphics:Images/chapter3_gr_44.gif]

[Graphics:Images/chapter3_gr_45.gif]

[Graphics:Images/chapter3_gr_46.gif]

[Graphics:Images/chapter3_gr_47.gif]

[Graphics:Images/chapter3_gr_48.gif]

[Graphics:Images/chapter3_gr_49.gif]

[Graphics:Images/chapter3_gr_50.gif]

[Graphics:Images/chapter3_gr_51.gif]

[Graphics:Images/chapter3_gr_52.gif]

[Graphics:Images/chapter3_gr_53.gif]

[Graphics:Images/chapter3_gr_54.gif]

[Graphics:Images/chapter3_gr_55.gif]

[Graphics:Images/chapter3_gr_56.gif]

[Graphics:Images/chapter3_gr_57.gif]

[Graphics:Images/chapter3_gr_58.gif]

[Graphics:Images/chapter3_gr_59.gif]

[Graphics:Images/chapter3_gr_60.gif]

[Graphics:Images/chapter3_gr_61.gif]

[Graphics:Images/chapter3_gr_62.gif]

[Graphics:Images/chapter3_gr_63.gif]

[Graphics:Images/chapter3_gr_64.gif]

[Graphics:Images/chapter3_gr_65.gif]

[Graphics:Images/chapter3_gr_66.gif]

[Graphics:Images/chapter3_gr_67.gif]

[Graphics:Images/chapter3_gr_68.gif]

[Graphics:Images/chapter3_gr_69.gif]

[Graphics:Images/chapter3_gr_70.gif]

[Graphics:Images/chapter3_gr_71.gif]

[Graphics:Images/chapter3_gr_72.gif]

[Graphics:Images/chapter3_gr_73.gif]

[Graphics:Images/chapter3_gr_74.gif]

[Graphics:Images/chapter3_gr_75.gif]

[Graphics:Images/chapter3_gr_76.gif]

[Graphics:Images/chapter3_gr_77.gif]

[Graphics:Images/chapter3_gr_78.gif]

[Graphics:Images/chapter3_gr_79.gif]

[Graphics:Images/chapter3_gr_80.gif]

[Graphics:Images/chapter3_gr_81.gif]

[Graphics:Images/chapter3_gr_82.gif]

[Graphics:Images/chapter3_gr_83.gif]

[Graphics:Images/chapter3_gr_84.gif]

[Graphics:Images/chapter3_gr_85.gif]

[Graphics:Images/chapter3_gr_86.gif]

[Graphics:Images/chapter3_gr_87.gif]

[Graphics:Images/chapter3_gr_88.gif]

Images

We will need the following package.

[Graphics:Images/chapter3_gr_89.gif]

You may find it useful to use the AppendRows or AppendColumns commands in the MatrixManipulation package.

[Graphics:Images/chapter3_gr_90.gif]
[Graphics:Images/chapter3_gr_91.gif]

We can generate random numbers in the range 0 to 1 using the Random[] function (the range can be adjusted if desired).  So putting three of these Random commands together will generate random vectors in 3-space.  Then we can form their images my multiplying by M.  Since the list will be long, you can suppress the output using a semi-colon at the end.

[Graphics:Images/chapter3_gr_92.gif]
[Graphics:Images/chapter3_gr_93.gif]

[Graphics:Images/chapter3_gr_94.gif]

[Graphics:Images/chapter3_gr_95.gif]

This shows that if you take points out of the unit cube in 3-space, their images under M all lie on a straight line going through the origin in the plane.  
Notice that M has rank 1 and a 2-dimensional null space.  These facts can be illustrated as follows.

Write the first column of M as a row vector

[Graphics:Images/chapter3_gr_96.gif]

[Graphics:Images/chapter3_gr_97.gif]

[Graphics:Images/chapter3_gr_98.gif]
[Graphics:Images/chapter3_gr_99.gif]
[Graphics:Images/chapter3_gr_100.gif]

The rows of this matrix form a basis for the nullspace of M, so we can depict random linear combinations of the rows to get a graphical representation of the nullspace.

[Graphics:Images/chapter3_gr_101.gif]

[Graphics:Images/chapter3_gr_102.gif]

[Graphics:Images/chapter3_gr_103.gif]

Inverses

The inverse of a square matrix can be computed with the Inverse command.  We begin with a 5x5 matrix built from random integers selected between -10 and 10.

[Graphics:Images/chapter3_gr_104.gif]
[Graphics:Images/chapter3_gr_105.gif]

The inverse is:

[Graphics:Images/chapter3_gr_106.gif]
[Graphics:Images/chapter3_gr_107.gif]

If you prefer a decimal approximation, try

[Graphics:Images/chapter3_gr_108.gif]
[Graphics:Images/chapter3_gr_109.gif]

To check that we have the inverse, we can compute:

[Graphics:Images/chapter3_gr_110.gif]
[Graphics:Images/chapter3_gr_111.gif]
[Graphics:Images/chapter3_gr_112.gif]

Solving Linear Systems

Here is a review of the different methods we have for solving linear systems in the context of Mathematica commands.  Much of this material comes directly from the Mathematica help facility.We begin with a 2x2 coefficient matrix.  Much of this material comes directly from the Mathematica help facility.

m = {{1, 5}, {2, 1}}
[Graphics:Images/chapter3_gr_113.gif]

This gives two linear equations.

m . {x, y} == {a, b}
[Graphics:Images/chapter3_gr_114.gif]

You can use Solve directly to solve these equations.

Solve[ %, {x, y} ]
[Graphics:Images/chapter3_gr_115.gif]

You can also get the vector of solutions by calling LinearSolve. The result is equivalent to the one you get from Solve.

LinearSolve[m, {a, b}]
[Graphics:Images/chapter3_gr_116.gif]

Another way to solve the equations is to invert the matrix m, and then multiply {a, b} by the inverse. This is not as efficient as using LinearSolve.

Inverse[m] . {a, b}
[Graphics:Images/chapter3_gr_117.gif]

RowReduce performs a version of Gaussian elimination and can also be used to solve the equations.

RowReduce[{{1, 5, a}, {2, 1, b}}]
[Graphics:Images/chapter3_gr_118.gif]

If you have a square matrix [Graphics:Images/chapter3_gr_119.gif] of maximal rank (and thus nullspace dimension 0), then you can always find a unique solution to the matrix equation [Graphics:Images/chapter3_gr_120.gif] for any [Graphics:Images/chapter3_gr_121.gif]. If, however, the matrix [Graphics:Images/chapter3_gr_122.gif] has a non-trivial nullspace, then there may be either no vector, or an infinite number of vectors [Graphics:Images/chapter3_gr_123.gif] which satisfy [Graphics:Images/chapter3_gr_124.gif] for a particular [Graphics:Images/chapter3_gr_125.gif]. This occurs when the linear equations embodied in [Graphics:Images/chapter3_gr_126.gif] are not independent.  
When [Graphics:Images/chapter3_gr_127.gif] has non-trivial nullspace, then it is always possible to find non­zero vectors [Graphics:Images/chapter3_gr_128.gif] that satisfy [Graphics:Images/chapter3_gr_129.gif]. The set of vectors [Graphics:Images/chapter3_gr_130.gif] satisfying this equation form the null space of the matrix [Graphics:Images/chapter3_gr_131.gif] by definition. Any of these vectors can be expressed as a linear combination of a particular set of basis vectors, which can be obtained using NullSpace[m].

Here is a simple matrix, corresponding to two identical linear equations.

m = {{1, 2}, {1, 2}}
[Graphics:Images/chapter3_gr_132.gif]

LinearSolve cannot find a solution to the equation [Graphics:Images/chapter3_gr_133.gif] in this case.

LinearSolve[m, {a, b}]
[Graphics:Images/chapter3_gr_134.gif]
[Graphics:Images/chapter3_gr_135.gif]

There is a single basis vector for the null space of m.

NullSpace[ m ]
[Graphics:Images/chapter3_gr_136.gif]

Multiplying the basis vector for the null space by m gives the zero vector.

m . %[[1]]
[Graphics:Images/chapter3_gr_137.gif]

Here is a simple symbolic matrix with determinant zero.

m = {{a, b, c}, {2 a, 2 b, 2 c}, {3 a, 3 b, 3 c}}
[Graphics:Images/chapter3_gr_138.gif]

The basis for the null space of m contains two vectors. Any linear combination of these vectors gives zero when multiplied by m.

NullSpace[ m ]
[Graphics:Images/chapter3_gr_139.gif]

An important feature of LinearSolve and NullSpace is that they work with rectangular, as well as square, matrices.  
When you represent a system of linear equations by a matrix equation of the form [Graphics:Images/chapter3_gr_140.gif], the number of columns in [Graphics:Images/chapter3_gr_141.gif] gives the number of variables, and the number of rows gives the number of equations. There are a number of cases.

[Graphics:Images/chapter3_gr_142.gif]

Classes of linear systems represented by rectangular matrices.

This asks for the solution to the inconsistent set of equations [Graphics:Images/chapter3_gr_143.gif] and [Graphics:Images/chapter3_gr_144.gif].

LinearSolve[{{1}, {1}}, {1, 0}]
[Graphics:Images/chapter3_gr_145.gif]
[Graphics:Images/chapter3_gr_146.gif]

This matrix represents two equations, for three variables.

m = {{1, 3, 4}, {2, 1, 3}}
[Graphics:Images/chapter3_gr_147.gif]

LinearSolve gives one of the possible solutions to this underdetermined set of equations.

v = LinearSolve[m, {1, 1}]
[Graphics:Images/chapter3_gr_148.gif]

When a matrix represents an underdetermined system of equations, the matrix has a non­trivial null space. In this case, the null space is spanned by a single vector.

NullSpace[m]
[Graphics:Images/chapter3_gr_149.gif]

If you take the solution you get from LinearSolve, and add any linear combination of the basis vectors for the null space, you still get a solution.

m . (v + 4 %[[1]])
[Graphics:Images/chapter3_gr_150.gif]

Exercises

Here are the four On Line exercises from section 3.4 in the text translated in Mathematica.

Exercise 1

Let A be the matrix from exercise 2a on page 177.  Use  LinearSolve to solve the system A.X=B where

[Graphics:Images/chapter3_gr_151.gif]
[Graphics:Images/chapter3_gr_152.gif]

Exercise 2

Read the exercise in the text on page 182 and solve it in Mathematica.

Exercise 3

Again, read the problem and solve in Mathematica.  Be sure to enter the matrix using fractions rather than decimals to maintain the exactness in the calculations.

Exercise 4

In this problem, you may find it useful to measure the magnitude of a vector (also called the norm).  You can build a function for doing this.

[Graphics:Images/chapter3_gr_153.gif]

Now you can work the problem.


Converted by Mathematica      October 26, 2001