MAST10008 Accelerated Mathematics 1 - Lab 3: Command Meaning Result of Calculation
MAST10008 Accelerated Mathematics 1 - Lab 3: Command Meaning Result of Calculation
1. Introduction
In this class we will further investigate the determinant of a matrix and use some of the graphics capabilities of
MATLAB.
A fundamental property of determinants is that they are unchanged by the elementary row operation of adding a
multiple of one row to another row. We will make use of this property to investigate how determinants relate to areas
and volumes. MATLAB allows us to explore this from graphical, numerical and symbolic perspectives.
Before starting the exercises, start MATLAB and load this week’s m-files:
• Open the Lab Materials folder: Start menu → Computer → Lab-materials (L:) → MAST10008
• Right-click on 10008lab3 in the Current Folder window and choose Add to Path → Selected folder and
subfolders.
2. Basic Commands
The table below lists some commands that you will need today plus others that relate to the material in lectures.
To complete the table, you will need to enter the following matrices into MATLAB:
2 3
2 1
A= x = −2 y = −1
3 −1
1 2
u= 2 3 v = 1 −1 w = −3 1 z = −2 1
Then use the command B=[u;v] and C=[w;z] to obtain two 2 × 2 matrices.
1
2
As well as the commands above you may find the following useful. (Do not test them now.)
Command Meaning
Reminder You will be using commands more than once in this Lab. Remember that in MATLAB you can use the up
arrow to select a previous command, changing some of it if necessary. Also you can copy and paste from the command
history window to the command window.
3. Exercises
Thinking of u as the base of the parallelograms what do you notice about the height and hence
the areas of the two parallelograms?
3
(c) Repeat part (b) with three other values of α in the range −2 to 2.
α B det B
What do you notice about the determinants of all the matrices found?
(d) Leave A fixed, and form a new matrix C by adding a multiple of row 2 to row 1:
• let z = u − βv
Repeat this for two or three values of β and fill in the spaces below.
β B det B
What do you notice about the determinants of all the matrices found?
(e) Start with the matrix A and do a single row operation (by hand) to make the bottom-left entry become 0.
Call this matrix B. Fill in your matrix B and row operation below:
" #
4 2
B= R2 − ___ R1
0 ___
Now do another single row operation on B to make the top-right entry become 0. Call this matrix C.
" #
____ 0
C= R1 − ___ R2
0 ___
(f) If you swap the rows of A how does this affect the area spanned by the vectors in the rows of A? How does it
affect the determinant?
(g) Based on your experiment above, develop a working hypothesis as to the relationship between determinant of
2 × 2 matrices and the area of the parallelogram spanned by the vectors in the rows of the matrix.
First clear the workspace by clicking ‘Clear workspace’ in the MATLAB toolbar, Home tab. This will clear out any
variables we have defined previously.
The symbolic toolbox provided as part of MATLAB enables you to do symbolic calculations as well as numeric
calculations. In order to use this toolbox you first need to specify which variables are to be treated as symbolic. This
is done with the syms command.
Enter
»syms s r x y x1 x2 y1 y2 real
This declares these variables to be symbolic rather than numeric.
5
Try the following commands, noticing that the result of your entries are formulae.
y= [ y1 y2 ] abs(-10)
s∧ 2 sqrt(2)
Area of a parallelogram in R2
In this section we show how one can use MATLAB to do algebraic calculations. We will prove the hypothesis from
Exercise 1, that is,
(1) First create some symbolic variables in MATLAB with the command
»syms x1 x2 y1 y2 real
(2) Then, in MATLAB define x = [x1 x2] and similarly for y and A = [x; y].
» d=det(A)
(5) Show that w = (x2, −x1) is perpendicular to x = (x1, x2) using MATLAB.
» dot(x,w)
(6) Draw (by hand) a parallelogram P determined by vectors x and y, and add the vector w perpendicular to x
(hint: draw x going horizontally). Indicate the projection of y onto w.
6
(7) Observe that the magnitude of the projection of y onto w is the height of the parallelogram P . The magnitude
of the projection is given by:
w·y
kwk
»height=abs(dot(w,y)/sqrt(dot(w,w)))
»base=sqrt(dot(x,x))
(10) The area of the parallelogram is base times height. Calculate this in MATLAB and check that it is the same
(up to sign) as the determinant of A.
det(A) =
base × height =
Choose Clear Workspace from the toolbar so that all previous vectors and matrices are deleted.
To draw the parallelepiped spanned by the vectors that make up the rows of A try the command ppped1(A)
(b) Add any multiple of u to w to get a new vector x. Put u, v and x into the rows of a matrix B.
What is det(B)? det(B) =
Try the command ppped2(A,B) If you click on at the top of the figure window, you can use the mouse to
rotate the figure to see it more clearly.
Notice that the base and height of A and B are the same. What do you conclude about the volumes of the
two parallelepipeds?
Try adding a multiple of v to w to get x and again draw the parallelepipeds and find the determinants.
Use a few other multiples of u and v and see what happens. What do you notice?
7
(c) Try other elementary row operations on A where you either (1) add a multiple of one row to another, or (2)
swap rows. Use ppped2(A,B), det(A) and det(B) to estimate the effect on volume at each stage and to find
the determinants.
What do you notice?
(d) Use a row operation of type (1) on A, changing row 3 to get a new matrix A1. For example, the commands:
replace row 3 by row 3 −2× (row 2). Then ppped2(A,A1) will enable you to compare volumes.
Use row operation (1) on A1 changing row 2 to get A2. Draw the parallelepipeds to compare volumes.
Use row operation (1) on A2 changing row 1 to get A3. Draw the parallelepipeds to compare volumes.
Note that your experiment does not constitute a proof. You need to use methods such as those in Exercise 2 for a
rigorous proof.