# Activity 10/18/2021

## STAT 445 / 645 -- Section 1001 <br> Instructor: Colin Grudzien<br>

## Instructions:
We will work through the following series of activities as a group and hold small group work and discussions in Zoom Breakout Rooms.  Follow the instructions in each sub-section when the instructor assigns you to a breakout room.

## Activities:

To perform some matrix operations, it can be helpful to use some non-base functions designed for this.  We will require the library `matlab`

```{r}
require("matlab")
```


### Activity 1: Diagonalization

Suppose we are given the following matrix
```{r}
A <- matrix(seq(3, 27, by=3), nrow=3, ncol=3)
```

#### Question 1:
Compute the rank of the matrix `A` . Then compute the eigen values of the matrix `A`.  How is the rank related to the eigenvalues of the matrix?

#### Question 2:
Use the  eigen decomposition as follows: extract the matrix of the eigenvectors by calling the variable `$vectors` and assign these vectors to a matrix called `C`.  Check if it is possible to invert this matrix and if so, define the inverse `C_inv`.  Explain why this is possible or why not.


#### Question 3: 
Now try the following, multiply `A` by `C_inv` on the left and `C` on the right.  What do you notice about the values off diagonal? 

Try using the following comparison to see how close the elements are to the value zero,
```{r, eval=FALSE}
abs(product) <= ones(3) * 10e-14
```

Take the diagonal elements of the product above and find the absolute difference of these from the eigenvalues of `A`. What do you notice about the result.

