Starting from:

$24.99

MAST90104 Lab 2 Solution

Week 2 Workshop/Lab
Workshop questions
1. (a) Find the eigenvalues, and an associated eigenvector for each eigenvalue, of the matrix
.
(b) Find an orthogonal matrix P such that PTAP is diagonal.
(c) Write down PTAP for the P given in part (b). 2. Let
.
(a) Write down the trace of A.
(b) Are the columns of A linearly independent? Justify your answer.
(c) Find the rank of A.
3. Show that if X is of full rank, then
I − X(XTX)−1XT
is an idempotent matrix.
4. Consider the matrix

(a) Show that X is idempotent.
(b) What is the rank of X ?
5. Prove that for any matrix A r(A) = r(AT) = r(ATA).
Practical questions
1. Use R to find the number of integers that are divisible by 17 between 1 and 500
2. Suppose that queue <- c("Steve", "Russell", "Alison", "Liam") and that queue represents a supermarket queue with Steve first in line. Using R expressions update the supermarket queue as successively:
(a) Barry arrives;
(b) Steve is served;
(c) Pam talks her way to the front with one item;
(d) Barry gets impatient and leaves;
(e) Alison gets impatient and leaves.
1
For the last case you should not assume that you know where in the queue Alison is standing.
Finally, using the function which(x), find the position of Russell in the queue.
Note that when assigning a text string to a variable, it needs to be in quotes.
3. The table below is taken from a clinic’s database, that records the patients’ name, age, and their waiting time. Create an R data frame with these information. Find the patient(s) with the longest waiting time
Name Age Waiting time
Ron 23 5
Steve 24 7
Barry 20 2
Louise 30 3
Ann 25 5
Kristen 24 4
Emma 21 6
4. Let

(a) Give R expression that return A and B
(b) Use R to compute AB, BTA
(c) Use R to find det(A) and r(B)
5. Use R to create 3 vectors
x
(a) Create matrix A x2 x3 (Hint: use function cbind )
(b) Create a vector of length 3, call it z
(c) Add z to A as the last row (Hint: use function rbind )
6. Write a program to read in a square matrix and return its trace. Hint: We first need to check whether the input is a square matrix.
2

More products