### Elina Azrilyan

September 11th, 2019

##### Packages Installation:
#install.packages('pracma')
library(pracma)
## Warning: package 'pracma' was built under R version 3.5.2

#### Problem Set 1

1. What is the rank of the matrix A?
A <- matrix(c(1,-1,0,5,2,0,1,4,3,1,-2,-2,4,3,1,-3), nrow=4)

A
##      [,1] [,2] [,3] [,4]
## [1,]    1    2    3    4
## [2,]   -1    0    1    3
## [3,]    0    1   -2    1
## [4,]    5    4   -2   -3

All 4 rows of the matrix are linearly independent and the matrix is square with 4 rows and columns - so the rank is 4.

Here is validation in R:

Rank(A)
## [1] 4
1. Given an mxn matrix where m > n, what can be the maximum rank? The minimum rank, assuming that the matrix is non-zero?

Maximum rank is n, since for rectangular matrices the rank has to be no greater than the smaller of the row or column dimension. The minimum rank is 1. The rank of a matrix would be zero only if the matrix had no elements. If a matrix had even one element, its minimum rank would be one.

1. What is the rank of matrix B?
B <- matrix(c(1, 3, 2, 2, 6, 4, 1, 3, 2), nrow=3)

B
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    3    6    3
## [3,]    2    4    2

The rank if 1 - none of the rows of this matrix are linearly independent.

Here is validation in R:

Rank(B)
## [1] 1

### Problem Set 2

Compute the eigenvalues and eigenvectors of the matrix A. You’ll need to show your work. You’ll need to write out the characteristic polynomial and show your solution.

A <- matrix(c(1, 0, 0, 2, 4, 0, 3, 5, 6), nrow=3)

A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    0    4    5
## [3,]    0    0    6
##### Calculating eigenvalues:

det(lambda*I - B) =

= det (

((lambda - 1)      (0-2)         (0-3))

(   (0-0)      (lambda - 4)      (0-5))

(   (0-0)          (0-0)     (lambda - 6))

) =


= det (

((lambda - 1)     (-2)         (-3))

(    (0)      (lambda - 4)     (-5))

(    (0)          (0)      (lambda - 6))

) = 

We will use 1st column to calculate the deteminant manually:

det = (lambda - 1) x (lambda - 4) x (lambda - 6) - (-5 x 0) = 0

(lambda - 1) x (lambda - 4) x (lambda - 6) = 0

#### Eigenvalues:

lambda1 = 1

lambda2 = 4

lambda3 = 6

##### Calculating eigenvectors:
((lambda - 1)     (-2)         (-3))

(    (0)      (lambda - 4)     (-5))

(    (0)          (0)      (lambda - 6))

Let’s plug in our 1st Eigenvalue: lambda1 = 1

  0    -2    -3
0    -3    -5
0     0    -5

z = 1

-3y - 5z = 0 -3y - 5*(1)=0 -3y = 5 y = -5/3

x = 0

Span of (1 -5/3 0)

Let’s plug in our 2nd Eigenvalue: lambda1 = 4

  3    -2    -3
0     0    -5
0     0    -2


Let’s simplify

  3    -2     2
0     0    -5
0     0    -2

3    -2     0
0     0    -5
0     0    -2


v3 = 1

3v1 - 2v2 = 0 v1 = 2/3v2

Span of (2/3 0 0)

Let’s plug in our 3rd Eigenvalue: lambda1 = 6

  5    -2    -3
0     2    -5
0     0     0


Let’s simplify

  5     0    -8
0     2    -5
0     0     0


v3 = t

2v2 - 5t = 0 v2 = 5/2t

5v1 - 8t = 0

v1 = 8/5t

Span of (8/5 5/2 1)

Here is validation in R:

# Find eigenvalues
eigen(A)$values ## [1] 6 4 1 #Eigenvectors and geometric multiplicities eigen(A)$vectors
##           [,1]      [,2] [,3]
## [1,] 0.5108407 0.5547002    1
## [2,] 0.7981886 0.8320503    0
## [3,] 0.3192754 0.0000000    0